Skip to content

Way to add baggage as tags via environment variable OR system properties #4975

Closed

Description

@umarkhan17

Is there a way to map baggage as tags via environment variable OR system properties? I know that it can be done via span.getBaggageItem and span.setBaggageItem, but is there a service level or global property which can be set like DD_TRACE_BAGGAGE_TAGS, which will accept baggage-key:span-key where it will check if a span has the baggageItem called baggage-key and create a span tag with that baggage item.

Why i would want this is, because we have a key called as taskId which gets generated early on for a task run, and i want all the spans searchable by that taskId, meaning i want taskId available throughout the trace. I know that i can add baggageItem, but baggageItems are not sent to datadog. Also, doing getBaggageItem everywhere in the code is cumbersome process.

Activity

  1. umarkhan17 commented on Mar 28, 2023

    @umarkhan17
    Author

    Just like how we can map headers to tags with this DD_TRACE_HEADER_TAGS, i want to map baggage to tags.

  2. rachelyangdog commented on Feb 5, 2026

    @rachelyangdog
    Contributor

    Hello! Thanks for raising this issue, and sorry for the delayed response.

    We introduced a new configuration, DD_TRACE_BAGGAGE_TAG_KEYS, which allows you to declare baggage keys that should automatically be copied onto spans as tags. When a span contains a baggage item matching one of the configured keys, its value is added to a span as a tag in the form baggage.: .

    This functionality was implemented in the Java tracer in this PR
    if you’d like to take a closer look.

    I hope this helps with your use case. Thank you again!

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

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