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

Add an options to flow the incoming distributed tracing headers #1344

Open
Kahbazi opened this issue Nov 1, 2021 · 9 comments
Open

Add an options to flow the incoming distributed tracing headers #1344

Kahbazi opened this issue Nov 1, 2021 · 9 comments
Labels
single_exe Issues that apply when a shipping YARP as a single exe Type: Idea This issue is a high-level idea for discussion.
Milestone

Comments

@Kahbazi
Copy link
Collaborator

Kahbazi commented Nov 1, 2021

Currently YARP would remove the distributed tracing headers from an incoming requests, and the new updated headers is being added to it by SocketsHttpHandler. These new headers counts YARP as a SPAN, and if we look at the distributed tracing in a tool like Zipkin, the hierarchy would be [client -> YARP -> Destination]. Although This would happen only when all three applications are logging to a distributed tracing system.

There might be some scenarios when YARP is not configured to be in part of distributed tracing system or users don't want to count YARP as a SPAN in distributed tracing system. In this case I think the hierarchy between client and destination would be lost because of the missing link (YARP). In this case an option for clusters to just flow the incoming distributed tracing headers is helpful.

@Kahbazi Kahbazi added the Type: Idea This issue is a high-level idea for discussion. label Nov 1, 2021
@MihaZupan
Copy link
Member

MihaZupan commented Nov 1, 2021

This is exactly what the PassThroughPropagator was designed for.

DistributedContextPropagator.Current = DistributedContextPropagator.CreatePassThroughPropagator();

// Or
services
    .AddReverseProxy()
    .ConfigureHttpClient((context, handler) =>
    {
        handler.ActivityHeadersPropagator = DistributedContextPropagator.CreatePassThroughPropagator();
    });

image

May be worth a mention in #1342

@Kahbazi
Copy link
Collaborator Author

Kahbazi commented Nov 1, 2021

Cool, I didn't know about this option.
Now should this be an option in HttpClientConfig? It might be useful when having YARP as an exe or docker, so this could be set via config instead of code.

@Kahbazi
Copy link
Collaborator Author

Kahbazi commented Nov 2, 2021

This is what could be added. I will send a PR if you agree with the design.

public enum DistributedContextPropagator
{
    Default = 0, // CreateDefaultPropagator()
    PassThrough = 1, // CreatePassThroughPropagator()
    NoOutput = 2, // CreateNoOutputPropagator()
    Disable = 3 // null , (I'm not sure if there's any behavior different between setting null and CreateNoOutputPropagator)
}

public class HttpClientConfig
{
+    public DistributedContextPropagator? DistributedContextPropagator  { get; init; }
}

@Tratcher
Copy link
Member

Tratcher commented Nov 2, 2021

This would only be for 6.0+, right?

@Kahbazi
Copy link
Collaborator Author

Kahbazi commented Nov 2, 2021

This would only be for 6.0+, right?

Yes, I believe so.

@MihaZupan
Copy link
Member

It would be 6.0+ only, but nothing stops the user from implementing what they need on top of something like the sample DiagnosticsHandlerFactory

I'm not sure if there's any behavior different between setting null and CreateNoOutputPropagator

NoOutputPropagator means HttpClient will still raise diagnostic events, but won't add headers.
null means no events and no headers - the handler won't be included at all.

In the context of Yarp, I think the following options would make sense:

  1. remove headers
  2. keep the original headers (passthrough, 5.0 default)
  3. maintain the trace and create a new span (6.0 default)

Only the first two should ever be useful to set from the config - for the third you would want code instrumentation.

@karelz karelz added this to the Backlog milestone Nov 2, 2021
@karelz
Copy link
Member

karelz commented Nov 2, 2021

Triage: We think default will work for most people. If we have more upvotes, we can add a config.
Leaving it open for a while to collect more feedback.

@samsp-msft samsp-msft added samsp_list Personal tag used when reviewing issues for further discussion single_exe Issues that apply when a shipping YARP as a single exe labels Dec 8, 2021
@samsp-msft
Copy link
Contributor

I'm a bit confused as to what needs to be done here: it sounds like adding the passthrough propagator solves the issue. If so, we should add to the samples/docs.

@karelz
Copy link
Member

karelz commented Dec 16, 2021

Triage: We have it doc'ed a bit, so no need to do more until we have more upvotes.

@karelz karelz removed the samsp_list Personal tag used when reviewing issues for further discussion label Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
single_exe Issues that apply when a shipping YARP as a single exe Type: Idea This issue is a high-level idea for discussion.
Projects
None yet
Development

No branches or pull requests

5 participants