Skip to content

OpenTelemetry: provide a way to use (part of) the baggage as attributes #45430

Open
@turing85

Description

Description

When using OpenTelemetry, it can be extremely helpful to use the baggage in order to propagate information. The OpenTelemetry standard supports this idea explicitly (opentelemetry.io):

Baggage is not the same as attributes

An important thing to note about baggage is that it is a separate key-value store and is unassociated with attributes on spans, metrics, or logs without explicitly adding them.

To add baggage entries to attributes, you need to explicitly read the data from baggage and add it as attributes to your spans, metrics, or logs.

Because a common use cases for Baggage is to add data to Span Attributes across a whole trace, several languages have Baggage Span Processors that add data from baggage as attributes on span creation.

Story:

As a developer
When I want to have information across multiple signals of a span
Then I want a way to store them in the baggage, such that they are automatically added to the signal.

Implementation ideas

The simplest form would be to just add the whole baggage as attributes/metadata/.... e.g. with a common, configurable prefix (e.g. defaulting to baggage such that an baggage item foo.bar becomes attribute baggage.foo.far or metadata entry baggage.foo.bar).

A more sophisticated solution would allow to define a list of baggage items (possibly with regex-pattern) that - if present - are added as attributes/metadata/...

An additional improvement would then be to define additional overrides in form of a Map<String, String> such that the baggage items are renamed. An entry of "foo.bar" = "baz.bag" would then rename the item from baggage.foo.bar to baz.bang (notice the missing baggage prefix).

Activity

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

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