-
Notifications
You must be signed in to change notification settings - Fork 49
Add Metrics to stream client #443
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
Merged
Merged
Conversation
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
Gsantomaggio
requested changes
Dec 19, 2025
Member
Gsantomaggio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is important in Darwin (MacOS) because `/bin/bash` is the system Bash, which is version 3.x. This version of bash does not recognise the test operator `-v`, therefore the script breaks in line `if [[ -v foo]]` With this change, `env` picks up the Bash version installed from Homebrew (if available), which is Bash 5.x; this version has support for `-v` operator.
This commit also has a test to demonstrate that multiple calls on `Close()` do not decrease the counters to a negative value. There was potential for race conditions, therefore, a basic locking mechanism had to be introduced in the metrics class to prevent race conditions and concurrent access.
Signed-off-by: Gabriele Santomaggio <[email protected]>
Gsantomaggio
approved these changes
Dec 22, 2025
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.

Following the same convention as the stream java client, our metrics are prefixed with
rabbitmq.stream.. The Java client defines metrics for micrometer collector here:https://github.com/rabbitmq/rabbitmq-stream-java-client/blob/66d7aeeef3b4a9edaf2ebc14aa31271f1dfb8f34/src/main/java/com/rabbitmq/stream/metrics/MicrometerMetricsCollector.java#L54-L65
This PR adds the same metrics to this client. Our metrics don't have the same cardinality keys (key-values associates to metrics. I would like some feedback on the current approach, specifically in the usage of a static class.
How to test the metrics
There are two options to observe the metrics. Via
dotnet-counterscli tool, or via the metrics example program.1. Via
dotnet-countersIn one terminal, start a program e.g.
Examples/Performances/Program.csin one terminal:In another terminal, run
dotnet-counters:# dotnet tool update -g dotnet-counters dotnet-counters monitor -n Performances --counters RabbitMQ.Stream.Client2. Via the Metrics example
This example shows how to configure an exporter for our metrics. This example uses Open Telemetry console exporter.