Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][broker] Reduce number of OpenTelemetry consumer attributes #22837

Merged

Conversation

dragosvictor
Copy link
Contributor

@dragosvictor dragosvictor commented Jun 4, 2024

Motivation

PR #22693 introduced OpenTelemetry consumer stats. Two issues surfaced as part of a follow-up review:

  1. The attribute sets are immutable and should be cached, such that they are not allocated on each metric collection run.
  2. Too many attributes are being exposed, potentially slowing down the metric pipeline as a result. Many of these attributes are currently being emitted as 'string' metrics in Prometheus.

Modifications

  1. Cache the attribute sets in the Consumer class, using lazy initialization to conserve memory if OTel is disabled.
  2. Remove consumer attributes pulsar.consumer.connected_since, pulsar.consumer.metadata, pulsar.client.address, and pulsar.client.version.
  3. Extract attribute pulsar.consumer.blocked from metric "pulsar.broker.consumer.message.unack.count into its own metric pulsar.broker.consumer.blocked.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Updated test OpenTelemetryTopicStatsTest#testMessagingMetrics to account for these changes

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

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics: As described above
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: dragosvictor#30

@dragosvictor dragosvictor marked this pull request as ready for review June 4, 2024 04:15
@github-actions github-actions bot added the doc-required Your PR changes impact docs and you will update later. label Jun 4, 2024
@dragosvictor
Copy link
Contributor Author

@asafm Please take a look if this addresses your concerns. Thank you!

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 83.33333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 73.22%. Comparing base (bbc6224) to head (52abcf4).
Report is 340 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #22837      +/-   ##
============================================
- Coverage     73.57%   73.22%   -0.35%     
- Complexity    32624    32931     +307     
============================================
  Files          1877     1888      +11     
  Lines        139502   141756    +2254     
  Branches      15299    15558     +259     
============================================
+ Hits         102638   103802    +1164     
- Misses        28908    29936    +1028     
- Partials       7956     8018      +62     
Flag Coverage Δ
inttests 27.37% <80.00%> (+2.79%) ⬆️
systests 24.74% <26.66%> (+0.42%) ⬆️
unittests 72.25% <83.33%> (-0.60%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
.../pulsar/opentelemetry/OpenTelemetryAttributes.java 100.00% <ø> (ø)
...ulsar/broker/stats/OpenTelemetryConsumerStats.java 98.36% <87.50%> (ø)
...ava/org/apache/pulsar/broker/service/Consumer.java 86.81% <81.81%> (+0.15%) ⬆️

... and 378 files with indirect coverage changes

@lhotari lhotari merged commit 8276f21 into apache:master Jun 4, 2024
55 of 58 checks passed
@asafm
Copy link
Contributor

asafm commented Jun 6, 2024

Perfect @dragosvictor !

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

Successfully merging this pull request may close these issues.

5 participants