Change the pulsar_client_sending_buffers_count metric to client level#1408
Merged
RobertIndie merged 4 commits intoAug 21, 2025
Merged
Conversation
RobertIndie
reviewed
Aug 19, 2025
Member
|
Can you explain the motivation for this change? |
0f7c9bc to
ba298d3
Compare
Contributor
Author
|
@crossoverJie I have updated the PR description, PTAL again |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR moves the pulsar_client_sending_buffers_count metric from a global level to client level, enabling it to be tagged with custom metrics labels. This change allows better tracking of buffer allocation issues across multiple client instances in applications.
Key changes include:
- Refactored metric creation to use client-specific labels instead of global constants
- Updated buffer allocation tracking to use client-level metrics
- Modified batch builders and producers to accept metrics as a parameter
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pulsar/internal/metrics.go | Moved SendingBuffersCount from global variable to client-level metric with custom labels support |
| pulsar/internal/buffer.go | Added release callback mechanism to track buffer lifecycle and removed global metric tracking |
| pulsar/internal/batch_builder.go | Updated to accept metrics parameter and track buffer allocation at client level |
| pulsar/internal/key_based_batch_builder.go | Updated function signatures to pass metrics parameter through batch container creation |
| pulsar/internal/key_based_batch_builder_test.go | Added metrics parameter to test setup |
| pulsar/producer_partition.go | Updated to pass client metrics to batch builder and track buffer allocation in single send |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
RobertIndie
approved these changes
Aug 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#1394 introduces the
pulsar_client_sending_buffers_countmetric to track how many buffers are allocated for send purpose and not put back to the pool. However, unlike other metrics, this metric is not client level, so it cannot be attached withCustomMetricsLabelsin client options.When a send buffer was not put back to the pool, it means the
Releasemethod is not called due to some reason. Changing this metric to client level could help locate which client has triggered this bug in an application that has many client instances from different businesses.Here is an example metric when I configured
CustomMetricsLabels: map[string]string{"key": "value"}after this change