otelgrpc: add MetricAttributesFn option to allow adding dynamic attributes on metrics
This PR addresses the need of adding dynamic attributes on the auto-instrumented metrics from otelgrpc. It potentially addresses https://github.com/open-telemetry/opentelemetry-go-contrib/issues/6026 without giving access to the payload since it is not available during every phase which adds complexity when trying to add the labels to all available metrics. It might also generate more confusion to the end user by exposing internal implementation details.
Initial draft that implemented the Labeler pattern from otelhttp (it also explains why it was closed): https://github.com/open-telemetry/opentelemetry-go-contrib/pull/8135
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: vlad-coman-hs / name: Vlad Coman (baaae0f1671ec6ae44b86fff1ac7789778d8ba37)
- :white_check_mark: login: vlad-coman-hs / name: vlad-coman-hs (6e56dbbea7733678fd158146a05c41090d37dc01)
Can you add documentation or an example_test.go to demonstrate how someone could use this to add attributes to metrics?
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 82.3%. Comparing base (fc62fd6) to head (551b60b).
Additional details and impacted files
@@ Coverage Diff @@
## main #8191 +/- ##
=====================================
Coverage 82.3% 82.3%
=====================================
Files 193 193
Lines 13780 13791 +11
=====================================
+ Hits 11345 11360 +15
+ Misses 2030 2028 -2
+ Partials 405 403 -2
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...entation/google.golang.org/grpc/otelgrpc/config.go | 87.3% <100.0%> (+1.0%) |
:arrow_up: |
| ...n/google.golang.org/grpc/otelgrpc/stats_handler.go | 98.5% <100.0%> (+<0.1%) |
:arrow_up: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Hello @dashpole, Just wanted to check in on this PR. Please let me know if there's anything I should adjust or clarify. Thank you for your time!
There was a release, so you need to move the changelog entry up to the unreleased section. You may need to add the appropriate header if the section doesn't already exist.