-
Notifications
You must be signed in to change notification settings - Fork 888
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
Add Context
parameter to Enabled for metrics instruments
#4256
Comments
Why? |
Description updated. Thanks |
There's no corresponding SDK behavior that would allow the enabled API to change its response based on context. |
A custom API implementation (e.g. SDK wrapper) could change its response based on context. I find that adding is important for Go that require passing Context explicitly. Adding it later to the API would be a burden. CC @open-telemetry/go-maintainers, @open-telemetry/collector-maintainers |
@open-telemetry/technical-committee since there is precedence for this already, we think that we can move forward with this, any objections? (cc @pellared @jpkrohling @danielgblanco) |
Agree with @pellared that adding this is important for Go |
IMO there is no need to modify the specification here. To me, this is a Go-specific question. Golang uses explicit context, and all API calls should have context independent of whether OTel specifications explicitly mention context. There is no need to modify the OTel specification to add a Context parameter in Golang. Most OTel APIs rely on implicit context, like being able to get a thread-local context object. Golang does not have thread-local state, so we always expect a Context argument. It shouldn't require a lot of imagination to see how context is useful for customized SDK purposes. A custom metric SDK could record metric events to the active span when the context is sampled, for example. |
This is why in almost all places |
@pellared I can't find what you're referring to. In the metrics
this implies that Enabled() should accept a context. In the trace Moreover, if you look at the one operation that absolutely requires a context, tracer.Start(), we see it is permitted to be implicit:
This seems to set a precedent that context can be implicit. The definition of Context itself also repeats this:
I still believe it is not necessary to modify the specification in this case. |
@jmacd, I added all these in the description of #4262
Is there any reason that adding the OTel concept of context would be bad in this scenario? Especially given that in most languages it is always implicitly available.
I prefer the specification to be less ambiguous. I would rather change the specification and call out that adding a |
+1 for making our specification explicit in its meaning. |
+1 as well, for explicitness, but also consistency. When tracing mentions the context, we should also mention it for similar appropriate cases with other signals. |
We should add
Context
as a parameter similarly to https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/bridge-api.md#enabled.Context is needed for allowing "context related" behavior. For instance, it enables to user to disable the instrument for some key/value in the context has been set. It can also used to see if the call is within a span. Related PR: #4203
Created here.
The text was updated successfully, but these errors were encountered: