-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Attribute injection in the Collector #6404
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
Comments
@jade-guiton-dd Thank you, this is great. I would like to propose to elevate this to the specification level, as I do not believe the stated problems are specific to the OTel Collector. You've listed three solutions and all of them have been discussed in the past and yet we are stalled. Here are some brief positions of mine:
I think this is an unfortunate situation, and I would focus our efforts on resolving this. IMO InstrumentationScope is the correct place for these attributes to go; while the I think this is the best approach compared with the others you mentioned. Our goal should be to avoid repetition of attributes for each span/metric/log because it is an important optimization.
OpenTelemetry has (for years) talked about a specific solution in metric instrumentation called the "Bound" instrument, which is a bound instrument for metric-ing with pre-specified attributes. Many metrics and logging APIs outside OTel allow you to register attributes that are automatically inserted to every log or metric (e.g. zap's Logger.With(), Prometheus' MetricVec.CurryWith()), and still there's no way to do that in OpenTelemetry. While I think OTel should move in this direction, I would still prefer to see component-level attributes as stated in open-telemetry/opentelemetry-collector#12217 use instrumentation-scope attributes to avoid repetition.
See the discussion in open-telemetry/oteps#207. Again, this is something I think OpenTelemetry should work out. You linked to the work on MetricsProcessor, which goes part of the way to a solution: OTEP 207 takes it further by proposing that OTel provide a standard way to enter context that would automatically be extracted by the SDKs. I would like to see such functionality in the Collector, but I would not use it for component-level attributes. The place I would use this in a Collector, for example, is to attach information propagated in-band that is not component-specific, like information about the end-user who submitted the request or the identity of the downstream destination calculated by an upstream load balancer. (Also yes, Go developers should always be careful about correct use of context.) |
It's unclear to me how we fix this. Do you have a concrete proposal on how to go about it? |
@mx-psi This will require a group discussion at the specification level to make progress. My proposal is to push forward with the Scope Attributes concept. Here's the original OTEP: and the associated issue: open-telemetry/opentelemetry-specification#2450 My understanding is that there are conflicting opinions about how attributes should be interpreted on Scopes and when it is safe for SDKs to permit multiple scopes. The topic is stalled, and I can't fully answer why in brief. If you submit OTLP data with "identifying" scope attributes, they need to be elevated to metric-level attributes by Prometheus, for example. If Prometheus exporter doesn't know about Scope attributes, the feature is a loss; if the Prometheus exporter includes non-identifying attributes, the feature is a breaking change. Still, I think Scope Attributes are the answer the problem. When the Collector's
I base this proposal on the assertion that right here, OpenTelemetry has discovered within itself a shortcoming where instrumentation is hard to get right (and efficient). Let's figure out the best approach to instrumentation here, and the standardize it across OpenTelemetry SDKs. |
@jmacd Do you think I should create a new issue on the specification repo to discuss whether scope attributes are the right way to go on this? |
This is on the discussion agenda for 3/11/2025 in the Specification SIG. |
My takeaways from the Spec SIG meeting: (@jmacd feel free to add anything relevant I missed)
|
@jmacd @jade-guiton-dd would it be worth updating the spec to make it more explicitly allowed, rather than being left to interpretation? I have only ever seen examples that refer to static scopes, e.g. "module, package, or class" at https://opentelemetry.io/docs/specs/otel/glossary/#instrumentation-scope and https://opentelemetry.io/docs/concepts/instrumentation-scope/ |
@axw Definitely, yes. Your first link is the glossary entry I mentioned above, which is technically under "specs" and is unnecessarily restrictive at the moment. The second link should be non-normative, but I agree that adding an explicit example of a runtime scope would be beneficial. |
Thank you @jade-guiton-dd. I agree with your summary, and I'm glad that scope attributes is the outcome. I agree that OpenTelemetry should look at its documentation about this topic, too. I would suggest renaming this issue, maybe to "Endorse use of Scoped Attributes in instrumentation" and transferring the issue to the specification repository. |
This issue has a lot of info that I don't think will be very relevant for rewording the spec; I'll create a new issue on the spec repo and close this one. |
Spec issue created here: open-telemetry/opentelemetry-specification#4450 |
Uh oh!
There was an error while loading. Please reload this page.
Problem
The Collector SIG is working on various improvements to the Collector's internal telemetry, among which is an RFC specifying attributes used to identify which Collector component emitted a given item of telemetry (eg. "the transform/foo processor in pipeline metrics/bar").
We are looking for ways to attach these "component attributes" to internal Collector telemetry automatically, without needing component developers to manually add them. (See the discussion in this issue.)
Current solutions
This has proven to be complicated with the current OTel API and data model:
Our current best solution (in this PR) uses span/metric/log attributes, and involves wrapping the TracerProvider and MeterProvider we pass to the component, as well as the Tracer, Meter, and all instruments created from them, to thread the attributes through the component and inject them in the final call. This works, but is brittle and inelegant.
Another proposed idea is to thread the attributes through the
Context
passed to components, and inject the attributes using SDK processors. However, this would require some cooperation on the component side (carefully threadingContext
s and never usingcontext.Background
), and because metric processors do not exist, would still require an unwieldy wrapper-based workaround.Question
Does the Go SIG know of any current or planned SDK-level or API-level features we could leverage to make this easier to accomplish?
Here are some ideas we thought of which would fit our use case:
(note that there is an ongoing specification effort related to this)
Context
s through componentsIf you have ideas for alternative solutions to this using purely the OTel API, we are of course also interested.
Additional context
Possibly related use cases:
The text was updated successfully, but these errors were encountered: