Skip to content
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

Baggage part 1/3: change propagator signatures #6157

Merged
merged 40 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b99e050
add new types
lucaspimentel Sep 30, 2024
d096da0
add PropagatorType property to IContextInjector and IContextExtractor
lucaspimentel Oct 16, 2024
f9a2a13
change IContextInjector and IContextExtractor to use PropagationContext
lucaspimentel Oct 3, 2024
abca132
refactor SpanContextPropagator to use PropagationContext
lucaspimentel Oct 16, 2024
4f762f3
refactor all propagators to use PropagationContext
lucaspimentel Oct 16, 2024
301e73a
fix propagator usages
lucaspimentel Oct 10, 2024
2ba4385
fix propagator usages in tests
lucaspimentel Oct 16, 2024
ade0a1c
assert that baggage is null in the trace context extraction tests
lucaspimentel Oct 21, 2024
3f8cf8f
initialize the AsyncLocal<Baggage>
lucaspimentel Oct 25, 2024
bf6a8e2
simplify merging Baggage in SpanContextPropagator.Extract()
lucaspimentel Oct 25, 2024
3236458
rename method
lucaspimentel Oct 25, 2024
55a7759
assert that baggage is null
lucaspimentel Oct 25, 2024
41ae893
rename Baggage methods
lucaspimentel Oct 25, 2024
0d181db
fix Baggage.Merge() and add test case
lucaspimentel Oct 25, 2024
a029eec
don't inject/extract baggage from the existing SpanContextInjector/Sp…
lucaspimentel Oct 28, 2024
850d5ae
move methods to keep all Extract() overloads together
lucaspimentel Oct 28, 2024
bb6d299
update xml-doc comments
lucaspimentel Oct 29, 2024
8b02062
avoid boxing
lucaspimentel Oct 29, 2024
1d66b31
fix locking in Baggage.AddOrReplace() and add Baggage.MergeInto()
lucaspimentel Oct 29, 2024
1292e9f
add extension method PropagationContext.MergeBaggageInto()
lucaspimentel Oct 29, 2024
92278eb
use extension method PropagationContext.MergeBaggageInto()
lucaspimentel Oct 29, 2024
ca5dcc0
use Baggage.MergeInto()
lucaspimentel Oct 29, 2024
d624cf0
make Baggage.Add public to enable collection initialization syntax
lucaspimentel Oct 29, 2024
fa9ee54
remove unused Baggage.Merge(), update unit tests
lucaspimentel Oct 29, 2024
96fcc77
don't merge extracted baggage in HttpWebRequest_EndGetResponse_Integr…
lucaspimentel Oct 29, 2024
101375d
inline the only call to Baggage.GetEmptyEnumerator()
lucaspimentel Oct 29, 2024
943843d
make GetEnumerator() and the static Baggage.AddOrReplace() private
lucaspimentel Oct 29, 2024
123040e
remove unused Baggage.GetAllItems()
lucaspimentel Oct 29, 2024
59bbba7
let SpanContextPropagator.Extract return null Baggage again
lucaspimentel Oct 29, 2024
4c5a9ea
make Baggage sealed and add a nullable annotation
lucaspimentel Oct 30, 2024
bfa715e
move Remove() methods together
lucaspimentel Oct 30, 2024
d4d3efb
implements Contains() and move Contains() methods together
lucaspimentel Oct 30, 2024
86e4ca3
imeplement CopyTo()
lucaspimentel Oct 30, 2024
a2b373a
merge extracted baggage in RabbitMQIntegration
lucaspimentel Oct 30, 2024
bd39647
misc clean up
lucaspimentel Oct 30, 2024
f205700
fix comment
lucaspimentel Oct 30, 2024
d52c016
use Baggage collection initializer syntax in tests
lucaspimentel Oct 30, 2024
a720a99
fix race condition when reading _items.Count, rename locals for consi…
lucaspimentel Oct 31, 2024
a1ddad9
resolve another possible deadlock
lucaspimentel Oct 31, 2024
6c5a422
rename static AddOrReplace to avoid confusion
lucaspimentel Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,15 @@ private void ProcessFolder(string folder, SearchOption searchOption)
_logger?.Warning($"Processed {numAssemblies} assemblies in folder: {folder}");

// The following is just a best effort approach to indicate in the test session that
// we sucessfully instrumented all assemblies to collect code coverage.
// we successfully instrumented all assemblies to collect code coverage.
// Is not part of the spec but useful for support tickets.
// We try to extract session variables (from out of process sessions)
// and try to send a message to the IPC server for setting the test.code_coverage.injected tag.
if (SpanContextPropagator.Instance.Extract(
EnvironmentHelpers.GetEnvironmentVariables(),
new DictionaryGetterAndSetter(DictionaryGetterAndSetter.EnvironmentVariableKeyProcessor)) is { } sessionContext)
var extractedContext = SpanContextPropagator.Instance.Extract(
EnvironmentHelpers.GetEnvironmentVariables(),
new DictionaryGetterAndSetter(DictionaryGetterAndSetter.EnvironmentVariableKeyProcessor));

if (extractedContext.SpanContext is { } sessionContext)
{
try
{
Expand All @@ -323,7 +325,7 @@ private void ProcessFolder(string folder, SearchOption searchOption)
}
else
{
_logger?.Debug($"CoverageCollector.Test session context cannot be found, skipping IPC client and sending injection tags");
_logger?.Debug("CoverageCollector.Test session context cannot be found, skipping IPC client and sending injection tags");
}
}

Expand Down
10 changes: 6 additions & 4 deletions tracer/src/Datadog.Trace/AspNet/TracingHttpModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ private void OnBeginRequest(object sender, EventArgs eventArgs)
HttpRequest httpRequest = httpContext.Request;
var requestHeaders = RequestDataHelper.GetHeaders(httpRequest) ?? new System.Collections.Specialized.NameValueCollection();
NameValueHeadersCollection? headers = null;
SpanContext propagatedContext = null;
PropagationContext extractedContext = default;

if (tracer.InternalActiveScope == null)
{
try
{
// extract propagated http headers
headers = requestHeaders.Wrap();
propagatedContext = SpanContextPropagator.Instance.Extract(headers.Value);
extractedContext = SpanContextPropagator.Instance.Extract(headers.Value).MergeBaggageInto(Baggage.Current);
}
catch (Exception ex)
{
Expand All @@ -152,7 +153,7 @@ private void OnBeginRequest(object sender, EventArgs eventArgs)
string httpMethod = httpRequest.HttpMethod.ToUpperInvariant();
string url = httpContext.Request.GetUrlForSpan(tracer.TracerManager.QueryStringManager);
var tags = new WebTags();
scope = tracer.StartActiveInternal(_requestOperationName, propagatedContext, tags: tags);
scope = tracer.StartActiveInternal(_requestOperationName, extractedContext.SpanContext, tags: tags);
// Leave resourceName blank for now - we'll update it in OnEndRequest
scope.Span.DecorateWebServerSpan(resourceName: null, httpMethod, host, url, userAgent, tags);
if (headers is not null)
Expand All @@ -172,7 +173,8 @@ private void OnBeginRequest(object sender, EventArgs eventArgs)
// (e.g. WCF being hosted in IIS)
if (HttpRuntime.UsingIntegratedPipeline)
{
SpanContextPropagator.Instance.Inject(scope.Span.Context, requestHeaders.Wrap());
var injectedContext = new PropagationContext(scope.Span.Context, Baggage.Current);
SpanContextPropagator.Instance.Inject(injectedContext, requestHeaders.Wrap());
}

httpContext.Items[_httpContextScopeKey] = scope;
Expand Down
Loading
Loading