Skip to content

Commit

Permalink
Add required SpanLink attributes for the new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharycmontoya committed Jan 9, 2025
1 parent 145059c commit 71321a5
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ internal PropagationContext Extract<TCarrier, TCarrierGetter>(TCarrier carrier,
SpanContext? cumulativeSpanContext = null;
Baggage? cumulativeBaggage = null;
List<SpanLink> spanLinks = new();
string? initialExtractorDisplayName = null;

foreach (var extractor in _extractors)
{
Expand Down Expand Up @@ -215,6 +216,7 @@ cumulativeSpanContext is not null &&
if (cumulativeSpanContext == null)
{
cumulativeSpanContext = currentExtractedContext.SpanContext;
initialExtractorDisplayName = extractor.DisplayName;
}
else if (currentExtractedContext.SpanContext is { } extractedSpanContext)
{
Expand All @@ -231,7 +233,7 @@ cumulativeSpanContext is not null &&

return _extractBehavior switch
{
ExtractBehavior.Restart when cumulativeSpanContext is not null => new PropagationContext(default, cumulativeBaggage, [new SpanLink(cumulativeSpanContext)]),
ExtractBehavior.Restart when cumulativeSpanContext is not null => new PropagationContext(default, cumulativeBaggage, [new SpanLink(cumulativeSpanContext, attributes: [new("reason", "propagation_behavior_extract=restart"), new("context_headers", initialExtractorDisplayName!)])]),
ExtractBehavior.Restart => new PropagationContext(default, cumulativeBaggage, []),
_ => new PropagationContext(cumulativeSpanContext, cumulativeBaggage, spanLinks),

Expand Down

0 comments on commit 71321a5

Please sign in to comment.