Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
3 changes: 2 additions & 1 deletion src/OpenTelemetry.Api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Notes](../../RELEASENOTES.md).

* Fixed `TraceContextPropagator` to normalize empty `tracestate` header values
to `null` when extracting trace context.
([#7407](https://github.com/open-telemetry/opentelemetry-dotnet/pull/7407))
([#7407](https://github.com/open-telemetry/opentelemetry-dotnet/pull/7407),
[#7433](https://github.com/open-telemetry/opentelemetry-dotnet/pull/7433))

* **Experimental (pre-release builds only):** Updated `EnvironmentVariableCarrier.Get`
to read only the normalized environment variable name, following the updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private static bool TryExtractSingleTracestate(string tracestate, out string tra
{
tracestateResult = string.Empty;

if (tracestate.Length == 0)
if (tracestate is not { Length: > 0 })
Comment thread
martincostello marked this conversation as resolved.
Outdated
{
return true;
}
Comment thread
martincostello marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,27 @@ public void TryExtractTracestate_NullCollectionReturnsEmpty()
Assert.Empty(actual);
}

[Fact]
public void ExtractHandlesNullValue()
Comment thread
martincostello marked this conversation as resolved.
Outdated
{
var headers = new Dictionary<string, string>
{
{ TraceParent, $"00-{TraceId}-{SpanId}-01" },
};

var propagator = new TraceContextPropagator();
var context = propagator.Extract(default, headers, (_, name) => headers.TryGetValue(name, out var value) ? [value] : [null!]);
Comment thread
martincostello marked this conversation as resolved.

Assert.Equal(ActivityTraceId.CreateFromString(TraceId.AsSpan()), context.ActivityContext.TraceId);
Assert.Equal(ActivitySpanId.CreateFromString(SpanId.AsSpan()), context.ActivityContext.SpanId);

Assert.True(context.ActivityContext.IsRemote);
Assert.True(context.ActivityContext.IsValid());
Assert.NotEqual(0, (int)(context.ActivityContext.TraceFlags & ActivityTraceFlags.Recorded));

Assert.Null(context.ActivityContext.TraceState);
}

[Fact]
public void Inject_NoTracestate()
{
Expand Down