-
Notifications
You must be signed in to change notification settings - Fork 576
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
Allow setting custom metric attributes in otelhttp transport #5876
Allow setting custom metric attributes in otelhttp transport #5876
Conversation
977c738
to
4570245
Compare
You shouldn't need this option. The same can be achieved with a view. |
Ohh nice, so i guess this is not useful! Will check out how this works |
@dmathieu i've checked out the documentation of the view, but I don't see an option to add attributes with that you can only filter them? |
Urgh yes sorry, my bad. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5876 +/- ##
=====================================
Coverage 65.5% 65.5%
=====================================
Files 203 203
Lines 12926 12936 +10
=====================================
+ Hits 8474 8486 +12
+ Misses 4198 4197 -1
+ Partials 254 253 -1
|
4570245
to
69f66d2
Compare
Created an issue: #5877, not sure if this is the best way to add this functionality (maybe there can be an option to add attributes in a the view? but it seems more invasive) |
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.
Typically, with this kind of attributes in otelhttp and other instrumentations, the follow request we have seen is to be able to set data dynamically, depending on the request data.
I wonder if it would be worth going directly with a callback that accepts the request as a parameter?
02ba617
to
21fbc0f
Compare
yea, pretty sure I can do that 😄 will send changes in a bit |
0551a23
to
4e2fa69
Compare
d730e7a
to
0f4aa08
Compare
@dmathieu what is the process for merging? do you want me to squash commits? is there anything else that i should do? |
A second approval from a member of @open-telemetry/go-approvers is required before we can merge. |
I think this has been discussed, but I don't remember the outcome. Can you update the description to include it? Why can't the Labeler be used to accomplish this? |
It's mentioned in #5877. |
Thanks. Does it need to be a function, then, if the goal is to add constant labels not based on the request? This seems to just duplicate the Labeler's functionality right now. |
I asked for it to be a function here, as every other option we've set like this before was always followed with a request to be able to dynamically add data rather than statically. |
dc2b367
to
77af1b0
Compare
@hanyuancheung @dmathieu i've squashed all the commits and rebased with main. Let me know if you need me to do something else. |
…ncluded in request metric
77af1b0
to
90b1f5d
Compare
Co-authored-by: Damien Mathieu <[email protected]>
Co-authored-by: Damien Mathieu <[email protected]>
This release is the last to support [Go 1.21]. The next release will require at least [Go 1.22]. ### Added - Add the `WithSpanAttributes` and `WithMetricAttributes` methods to set custom attributes to the stats handler in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc`. (#5133) - The `go.opentelemetry.io/contrib/bridges/otelzap` module. This module provides an OpenTelemetry logging bridge for `go.uber.org/zap`. (#5191) - Support for the `OTEL_HTTP_CLIENT_COMPATIBILITY_MODE=http/dup` environment variable in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` to emit attributes for both the v1.20.0 and v1.26.0 semantic conventions. (#5401) - The `go.opentelemetry.io/contrib/bridges/otelzerolog` module. This module provides an OpenTelemetry logging bridge for `github.com/rs/zerolog`. (#5405) - Add `WithGinFilter` filter parameter in `go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin` to allow filtering requests with `*gin.Context`. (#5743) - Support for stdoutlog exporter in `go.opentelemetry.io/contrib/config`. (#5850) - Add macOS ARM64 platform to the compatibility testing suite. (#5868) - Add new runtime metrics to `go.opentelemetry.io/contrib/instrumentation/runtime`, which are still disabled by default. (#5870) - Add the `WithMetricsAttributesFn` option to allow setting dynamic, per-request metric attributes in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#5876) - The `go.opentelemetry.io/contrib/config` package supports configuring `with_resource_constant_labels` for the prometheus exporter. (#5890) - Support [Go 1.23]. (#6017) ### Removed - The deprecated `go.opentelemetry.io/contrib/processors/baggagecopy` package is removed. (#5853) ### Fixed - Race condition when reading the HTTP body and writing the response in `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp`. (#5916) [Go 1.23]: https://go.dev/doc/go1.23 [Go 1.22]: https://go.dev/doc/go1.22 [Go 1.21]: https://go.dev/doc/go1.21
Similar to open-telemetry#5876 but for gRPC.
There is no option to include a set of attribute on metrics for every request