Skip to content

WIP: Baggage Span Tags #7020

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

rachelyangdog
Copy link

Summary of changes

Reason for change

Implementation details

Test coverage

Other details

@rachelyangdog rachelyangdog requested a review from a team as a code owner May 27, 2025 20:21
@rachelyangdog rachelyangdog marked this pull request as draft May 27, 2025 20:21
@github-actions github-actions bot added the area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations) label May 27, 2025
}

// add only specified baggage items as tags
var allowedKeys = baggageTagKeys.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try not to do any heap allocations (don't do Split) --> go around this

Copy link
Member

@lucaspimentel lucaspimentel Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change settings.BaggageTagKeys to a string[] and do the split when we read the config (see my other comment in TracerSettings.cs), then we don't need to split here anymore.

You can remove this line and change the foreach below to something like:

foreach (var key in baggageTagKeys)

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented May 27, 2025

Datadog Report

Branch report: rachel.yang/baggage-span-tags
Commit report: 9216bc7
Test service: dd-trace-dotnet

✅ 0 Failed, 53 Passed, 0 Skipped, 32m 26.97s Total Time

@@ -125,6 +140,7 @@ public Scope StartAspNetCorePipelineScope(Tracer tracer, Security security, Http
var scope = tracer.StartActiveInternal(_requestInOperationName, extractedContext.SpanContext, tags: tags, links: extractedContext.Links);
scope.Span.DecorateWebServerSpan(resourceName, httpMethod, host, url, userAgent, tags);
AddHeaderTagsToSpan(scope.Span, request, tracer);
AddBaggageTagsToSpan(scope.Span, extractedContext.Baggage, tracer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to do this for other web server spans as well.

Comment on lines +593 to +595
BaggageTagKeys = config
.WithKeys(ConfigurationKeys.BaggageTagKeys)
.AsString(defaultValue: "user.id,session.id,account.id");
Copy link
Member

@lucaspimentel lucaspimentel Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try making BaggageTagKeys a string[] and splitting here so we only do it once and not when we try to apply this setting in each incoming http request. See disabledIntegrationNames around line 331 above as an example. Probably just need to add Split(), like:

Suggested change
BaggageTagKeys = config
.WithKeys(ConfigurationKeys.BaggageTagKeys)
.AsString(defaultValue: "user.id,session.id,account.id");
BaggageTagKeys = config
.WithKeys(ConfigurationKeys.BaggageTagKeys)
.AsString(defaultValue: "user.id,session.id,account.id")
.Split([','], StringSplitOptions.RemoveEmptyEntries);

You'll have to change the property in line 1067 below, too:

- internal string BaggageTagKeys { get; }
+ internal string[] BaggageTagKeys { get; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tracer The core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants