Skip to content

feat: (issue 2429) read gRPC hiero-correlation-id header and prefix publisher handler logs#2534

Open
a-saksena wants to merge 6 commits intomainfrom
feat/2429-publisher-correlation-id
Open

feat: (issue 2429) read gRPC hiero-correlation-id header and prefix publisher handler logs#2534
a-saksena wants to merge 6 commits intomainfrom
feat/2429-publisher-correlation-id

Conversation

@a-saksena
Copy link
Copy Markdown
Contributor

@a-saksena a-saksena commented Apr 9, 2026

Reviewer Notes

Related Issue(s)

Use keywords Fix, Fixes, Fixed, Close, Closes, Closed, Resolve, Resolves, Resolved
to connect an issue to be closed by this pull request.

@a-saksena a-saksena requested review from a team as code owners April 9, 2026 17:54
@a-saksena a-saksena requested a review from AlfredoG87 April 9, 2026 17:54
@a-saksena a-saksena force-pushed the feat/2429-publisher-correlation-id branch from 7ca55b6 to 00245da Compare April 9, 2026 17:56
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 9, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@a-saksena a-saksena self-assigned this Apr 9, 2026
@a-saksena a-saksena added this to the 0.32.0 milestone Apr 9, 2026
@a-saksena a-saksena force-pushed the feat/2429-publisher-correlation-id branch from 658508e to a221322 Compare April 9, 2026 18:34
@a-saksena a-saksena added the Block Node Issues/PR related to the Block Node. label Apr 9, 2026
@a-saksena a-saksena force-pushed the feat/2429-publisher-correlation-id branch 2 times, most recently from 239da61 to dce9517 Compare April 9, 2026 18:57
@a-saksena a-saksena changed the title feat: (issue 2429) read gRPC hiero-correlation-id header and prefix publisher hand… feat: (issue 2429) read gRPC hiero-correlation-id header and prefix publisher handler logs Apr 9, 2026
Copy link
Copy Markdown
Contributor

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this was added isn't good and breaks some important metrics.

Copy link
Copy Markdown
Contributor

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start including passing through call chain and pre-computing correlationIdPrefix, character truncations and test additions.

@jsync-swirlds covered most of the cases I'm concerned about with respect to perf and breaking log layouts for other telemetry.
Also kindly add a PR description that makes it easier for reviewers to understand what they are reviewing and the impact

…ler logs

Signed-off-by: a-saksena <anurag@swirldslabs.com>
…ublisher handler logs.

Signed-off-by: a-saksena <anurag@swirldslabs.com>
Signed-off-by: a-saksena <anurag@swirldslabs.com>
Signed-off-by: a-saksena <anurag@swirldslabs.com>
…orrelation-id header and prefix publisher handler logs

Signed-off-by: a-saksena <anurag@swirldslabs.com>
@a-saksena a-saksena force-pushed the feat/2429-publisher-correlation-id branch from c8b1a3b to 48c46a3 Compare April 10, 2026 01:50
Signed-off-by: a-saksena <anurag@swirldslabs.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 88.15789% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../block/node/stream/publisher/PublisherHandler.java 85.48% 9 Missing ⚠️
@@             Coverage Diff              @@
##               main    #2534      +/-   ##
============================================
+ Coverage     81.27%   81.47%   +0.19%     
- Complexity     1512     1526      +14     
============================================
  Files           139      139              
  Lines          7131     7162      +31     
  Branches        754      757       +3     
============================================
+ Hits           5796     5835      +39     
- Misses         1010     1012       +2     
+ Partials        325      315      -10     
Files with missing lines Coverage Δ Complexity Δ
...e/stream/publisher/LiveStreamPublisherManager.java 84.50% <100.00%> (+0.56%) 69.00 <0.00> (+3.00)
.../node/stream/publisher/StreamPublisherManager.java 100.00% <ø> (ø) 0.00 <0.00> (ø)
...k/node/stream/publisher/StreamPublisherPlugin.java 98.73% <100.00%> (+0.20%) 15.00 <5.00> (+5.00)
.../block/node/stream/publisher/PublisherHandler.java 91.98% <85.48%> (+5.14%) 77.00 <11.00> (+9.00)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

LOGGER.log(TRACE, ackMessage, newLastAcknowledgedBlockNumber, handlerId);
LOGGER.log(
TRACE,
"metric-end-to-end-latency-by-block-end block={0,number,#} nsTimestamp={1,number,#} handlerId={2} correlationId=[{3}]",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we must not include the [] characters; it breaks parsing in Loki.

LOGGER.log(TRACE, traceMessage, blockNumber, currentStreamingBlockHeaderReceivedTime, handlerId);
LOGGER.log(
TRACE,
"metric-end-to-end-latency-by-block-start block={0,number,#} nsTimestamp={1,number,#} handlerId={2} correlationId=[{3}]",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this is a metric value, so we must not add extra characters that cause parsing issues.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a gap in our documentation but basically anywhere you see the format = is an instance of logs that Loki can convert into telemetry and we can use to create adhoc telemetry.
As such we don't want to break those but you can add key-value pairs to them

assertThat(responsePipeline.getClientEndStreamCalls().get()).isEqualTo(0);
}

/// Verifies that a failed [PersistedNotification] (succeeded = false)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These coverage tests will probably conflict with @ata-nas latest changes; so we should be careful about what order we merge the two PRs.


SDK_DIR=""
TCK_DIR=""
TEST_FILE="src/tests/crypto-service/test-transfer-hbar-transaction.ts src/tests/crypto-service/test-account-create-transaction.ts src/tests/crypto-service/test-account-update-transaction.ts src/tests/token-service/test-token-create-transaction.ts src/tests/token-service/test-token-update-transaction.ts src/tests/topic-service/test-topic-create-transaction.ts src/tests/topic-service/test-topic-update-transaction.ts src/tests/contract-service/test-contract-delete-transaction.ts"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove these?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert

Comment on lines -95 to -103
if [[ "${TEST_FILE}" == "all" ]]; then
echo "Running all TCK tests (test:serial)"
npm run test:serial
else
echo "Running TCK tests: $TEST_FILE"
# shellcheck disable=SC2086
# Word splitting is intentional — TEST_FILE may contain multiple space-separated file paths
npm run test:file $TEST_FILE
fi
Copy link
Copy Markdown
Contributor

@jsync-swirlds jsync-swirlds Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar concern, this seems to remove the option to run "all" tests.

cc: @Nana-EC

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, please revert all changes in this file for this PR.
If we want to streamline anything here let's do it separately so this PR doesn't get held up

manager.getBlockMessagingFacility().getSentNewestBlockKnownToNetworkNotifications();
assertThat(sentNotifications).hasSize(0);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should also be examined by @ata-nas to ensure they aren't conflicting with his recent changes.

Copy link
Copy Markdown
Contributor

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple changes needed for the metric logs.
These are log statements we use Loki to parse into metrics because they're cross-plugin telemetry data we cannot easily turn into useable metrics otherwise.

Copy link
Copy Markdown
Contributor

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some mote items.
We should scope this to the necessary changes needed but also watch out for the value pairs in logs, those are logs that Loki can turn into telemetry that we specifcally formatted for

Comment on lines -95 to -103
if [[ "${TEST_FILE}" == "all" ]]; then
echo "Running all TCK tests (test:serial)"
npm run test:serial
else
echo "Running TCK tests: $TEST_FILE"
# shellcheck disable=SC2086
# Word splitting is intentional — TEST_FILE may contain multiple space-separated file paths
npm run test:file $TEST_FILE
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, please revert all changes in this file for this PR.
If we want to streamline anything here let's do it separately so this PR doesn't get held up


SDK_DIR=""
TCK_DIR=""
TEST_FILE="src/tests/crypto-service/test-transfer-hbar-transaction.ts src/tests/crypto-service/test-account-create-transaction.ts src/tests/crypto-service/test-account-update-transaction.ts src/tests/token-service/test-token-create-transaction.ts src/tests/token-service/test-token-update-transaction.ts src/tests/topic-service/test-topic-create-transaction.ts src/tests/topic-service/test-topic-update-transaction.ts src/tests/contract-service/test-contract-delete-transaction.ts"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert

LOGGER.log(TRACE, traceMessage, blockNumber, currentStreamingBlockHeaderReceivedTime, handlerId);
LOGGER.log(
TRACE,
"metric-end-to-end-latency-by-block-start block={0,number,#} nsTimestamp={1,number,#} handlerId={2} correlationId=[{3}]",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a gap in our documentation but basically anywhere you see the format = is an instance of logs that Loki can convert into telemetry and we can use to create adhoc telemetry.
As such we don't want to break those but you can add key-value pairs to them

context.configuration().getConfigData(ServerConfig.class).maxMessageSizeBytes() - 16384;

final String rawCorrelationId = options.metadata().getOrDefault("hiero-correlation-id", "");
if (rawCorrelationId.length() > MAX_CORRELATION_ID_LENGTH) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic is repeated in truncateCorrelationId so you can get rid of it and just call the method

if (rawCorrelationId.length() > MAX_CORRELATION_ID_LENGTH) {
LOGGER.log(
System.Logger.Level.WARNING,
"Received hiero-correlation-id header exceeds {0} characters and will be truncated: {1}",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May also be worth logging the size that came in so it's clear how much over the limit we're observing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Block Node Issues/PR related to the Block Node.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants