Skip to content

Attribute injection in the Collector #6404

@jade-guiton-dd

Description

@jade-guiton-dd

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:

  • resource attributes are set once when creating a Provider, and cannot be changed without recreating the telemetry exporting pipeline, whereas we need different values for different components;
  • instrumentation scope attributes have the wrong semantics (they identify parts of the code, not runtime component instances), and are poorly supported (if at all) by observability backends;
  • span/metric/log attributes are normally set in the final call, inside component code which we don't control.

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 threading Contexts and never using context.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:

  • the ability to define default span/metric/log attributes on Tracers/Meters/Loggers
  • the ability to specialize a Provider with additional resource attributes, without recreating the exporting pipeline
  • the ability to define "metric processors", akin to span/log processors
    (note that there is an ongoing specification effort related to this)
    • perhaps additionally, the ability to define extra Baggage associated with a Meter/Tracer/Logger, to avoid issues with threading Contexts through components

If 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions