Skip to content

Tracing: How to add dynamic attributes to all spans? #2970

Description

@jbluntz

Question

I'd like to be able to add an attribute that may change throughout the lifetime of the app to all spans logged by the SDK. I'm using OpenTelemetry so I can add tags that are static and known at initialization time via OtelTracerProvider.Builder.addTag, but this doesn't work for attributes that either aren't static or aren't known at initialization time.

I looked into SpanEventMapper but very little of the SpanEvent object is mutable (only resource and name) and the SDK drops Spans if the mapper returns a new object instead of the one that was passed in.

Is there another approach to solving this problem? If not, would you consider making SpanEvent.Meta.additionalProperties a MutableMap or exposing a setter to add properties?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions