Skip to content

What should the default DistributedContextPropagator be #56794

Closed as not planned
@MihaZupan

Description

@MihaZupan

#50658 and #55556 added APIs for controlling distributed context propagation.
Part of those APIs is a CreateDefaultPropagator method that is used to seed the global static Current property.

HttpClient and ASP.NET Core both consume these APIs and as such inherit the default behavior.

CreateDefaultPropagator currently returns a LegacyPropagator, which is preserving pre-.NET 6 behavior of injecting context by default.

Having injection ON by default means some user scenarios work out of the box:

  • ASP.NET Core services will preserve the trace across process boundaries even if they haven't been explicitly instrumented for distributed tracing
  • For services that collect logs, actions performed across different services can still be attributed to a shared incoming request
  • Even when some of the services are not instrumented, others still benefit from the trace as it continues to flow

On the other hand it brings some downsides:

  • Some services are very strict about the headers they are expecting and may refuse requests that contain trace-related headers. This may be relatively difficult for users to diagnose as the behavior of HttpClient depends on whether it was used from within the ASP.NET Core pipeline or not
  • We are spending a few cycles every request to decide on whether to do anything, or potentially sending extra headers that may just get ignored
  • There are theoretical privacy concerns of correlating requests based on the trace id, outlined in the W3C Trace Context specification
  • More discussion around the behavior: HttpClient automatically adds Request-Id HTTP header #35337

For 7.0, we should decide whether injecting context is the right default for the platform.

cc: @tarekgh @noahfalk @shirhatti @davidfowl @dotnet/ncl

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions