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

TraceContextPropagator uses ActivityContext in input PropagationContext as override instead of fallback #2807

Open
Oberon00 opened this issue Jan 24, 2022 · 1 comment

Comments

@Oberon00
Copy link
Member

Oberon00 commented Jan 24, 2022

Affected code:

public override PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter)
{
if (context.ActivityContext.IsValid())
{
// If a valid context has already been extracted, perform a noop.
return context;
}

This will not extract a Context from the carrier if there already is one in the input context.

This is against the base class documentation which says:

/// <summary>
/// Extracts the context from a carrier.
/// </summary>
/// <typeparam name="T">Type of object to extract context from. Typically HttpRequest or similar.</typeparam>
/// <param name="context">The default context to be used if Extract fails.</param>
/// <param name="carrier">Object to extract context from. Instance of this object will be passed to the getter.</param>
/// <param name="getter">Function that will return string value of a key with the specified name.</param>
/// <returns>Context from it's text representation.</returns>
public abstract PropagationContext Extract<T>(PropagationContext context, T carrier, Func<T, string, IEnumerable<string>> getter);

The default context to be used if Extract fails.

The base class docs conform to the OTel spec (or at least my understanding of it and the Java implementation), the TraceContextPropagator implementation does not. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/context/api-propagators.md#extract

@stevejgordon
Copy link
Contributor

@Oberon00 - This appears to be by design (added in #1048) since ASP.NET and ASP.NET Core automatically extract the W3C trace context when handling incoming requests, so there's no need to parse the headers a second time, adding a small amount of overhead. It, therefore, handles cases when an ActivityContext hasn't already been parsed (i.e. when ASP.NET (Core) is not involved). This seems reasonable, and I don't think the spec prohibits this. @martinjt, if @CodeBlanch agrees, I think we can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants