Skip to content

[Issue 1154][consumer] Fix bogus values in the processing time metric - #1550

Merged
nodece merged 1 commit into
apache:masterfrom
Thanatos9404:fix/consumer-processing-time-metric
Oct 24, 2026
Merged

nodece merged 1 commit into
apache:masterfrom
Thanatos9404:fix/consumer-processing-time-metric

Conversation

@Thanatos9404

@Thanatos9404 Thanatos9404 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1154

Motivation

pulsar_client_consumer_processing_time_seconds should measure the time from receiving a message to acking it, but almost every observation is about 8.5e9 seconds. ackIDCommon observes the metric from a rebuilt tracking ID whose receivedTime is zero. Chunked messages, and IDs the consumer never received, produced bogus values too.

Modifications

  • Add partitionConsumer.observeProcessingTime(msgID), which reads the receive time from the acked tracking or chunk message ID and records nothing when there is none.
  • Use it in ackIDCommon (with the acked ID), AckIDList and internalAckIDCumulative, so a chunked message is observed once on every ack path.
  • Compute the duration with time.Since. A batch is still observed once.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Added TestProcessingTimeMetric, TestProcessingTimeMetricBatchMessage and TestProcessingTimeMetricSkipsIDsWithoutReceiveTime in pulsar/consumer_partition_test.go. They don't need a broker. The new cases fail without the fix and pass with it, except the plain AckIDList and AckIDCumulative ones, which guard paths that already worked.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API: no
  • The schema: no
  • The default values of configurations: no
  • The wire protocol: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

The pulsar_client_consumer_processing_time_seconds histogram records
values of about 8.5e9 seconds. On an individual ack, ackIDCommon
replaces trackingID with a new ID that has no receive time and then
observes the metric from that ID, so it measures from the zero
time.Time. Cumulative acks of chunked messages hit the same problem,
because toTrackingMessageID does not keep the receive time of a chunk
ID. Individual acks of chunked messages recorded one such value per
chunk, because each chunk is acked by its plain message ID. Individual
and cumulative acks also did this for IDs that the consumer never
received, such as ones built by the application.

Add observeProcessingTime, which reads the receive time from the acked
tracking or chunk ID and skips IDs that have none. Use it in the three
places that observed the metric, and observe a chunked message once in
the individual ack and AckIDList paths, so chunked messages are recorded
once per message on every ack path.

Signed-off-by: Yashvardhan Thanvi <[email protected]>
@Thanatos9404
Thanatos9404 force-pushed the fix/consumer-processing-time-metric branch from 3c37764 to c18e596 Compare October 21, 2026 05:51
@Thanatos9404

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I rebased onto master so the integration tests pick up #1545: the three failures in the last run (TestTxn_TCClient, TestSetTopicAutoCreation, TestPartitionState) are the ones that change fixed. The commit itself is unchanged, and the new run is waiting for workflow approval.

@nodece
nodece merged commit a41b8a6 into apache:master Oct 24, 2026
10 of 12 checks passed
@nodece nodece added this to the 0.22.0 milestone Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pulsar_client_consumer_processing_time_seconds metric records incorrect values

2 participants