-
Notifications
You must be signed in to change notification settings - Fork 31
Add OpenTelemetry metrics instrumentation #461
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
Conversation
Implements comprehensive OTEL metrics for RabbitMQ Stream operations: Metrics tracked: - rabbitmq.stream.connections (up/down counter) - rabbitmq.stream.published (counter) - rabbitmq.stream.confirmed (counter) - rabbitmq.stream.errored (counter) - rabbitmq.stream.chunks (counter) - rabbitmq.stream.chunk_size (histogram) - rabbitmq.stream.consumed (counter) - rabbitmq.stream.outstanding_publish_confirmations (up/down counter) Implementation: - Add MeterProvider configuration to EnvironmentOptions - Instrument connection lifecycle, producer publish/confirm/error events, and consumer delivery events - Include OTEL semantic conventions for attributes (messaging.system, server.address, server.port, messaging.destination.name, etc.) - Default to noop provider when not configured Testing: - Add comprehensive unit tests with mock meter provider (21 tests) - Add integration tests covering producer, consumer, connection, and error scenarios - All tests avoid OTEL SDK dependency by using custom mocks Example: - Add examples/metrics demonstrating usage with stdout exporter This enables observability of RabbitMQ Stream operations through standard OpenTelemetry tooling and exporters.
The default value of the metric provider is the global metric provider. This is better because some applications simply set the metric provider globally and do not pass it down to libraries. This approach also solves the problem of users initialising EnvironmentOptions without the constructor; earlier, bypassing the constuctor resulted in subsequent panics when the metrics were initialised.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #461 +/- ##
==========================================
+ Coverage 83.36% 83.45% +0.09%
==========================================
Files 28 29 +1
Lines 4238 4376 +138
==========================================
+ Hits 3533 3652 +119
- Misses 480 490 +10
- Partials 225 234 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Please add some documentation to the README.md then we can merge! Thank you! |
460dc93 to
ca85c9a
Compare
Sometimes in CI this test fails because the offset is off by 1. It passes on the next run
ca85c9a to
4fc83ed
Compare
This PR implements OTEL metrics for RabbitMQ Stream operations:
Metrics tracked:
Implementation:
Testing:
Example:
Running the example
To run the example, I recommend creating a Go workspace using
go workas follows:This prevents the Go module from downloading the client from github, and instead use the local client code.
Closes: #26