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

Use existing opentracing context #2016

Closed

Conversation

jmalvarezf
Copy link
Contributor

Hi,

As we wanted to have the ability for linkerd to propagate the opentracing context that was originated outside linkerd, and it wasn't clearly in your roadmap, we went ahead and modified linkerd to do this.
I'm a scala newbie, so the code may be less than optimal. Any change you feel would fit better, feel more than free to tell me. The change consists basically in adding an if when getting tracing context to get opentracing headers, and to propagate the context in the same headers in the next step.
This is very important for us to be able to have the full trace for a request, as it is originated outside the platform that is running linkerd as service mesh.

We have tested this in our deployment and it's working as expected.

This should fix #1447 with standard opentracing headers

Thanks!

Jose Maria Alvarez added 2 commits June 26, 2018 09:11
We wanted linkerd to continue a tracing context created outside (in our load balancers basically) instead of creating a new context and using their own headers when propagating it.

To solve it, we have added a condition in the method that parses headers to look for a span header, and if present, parse that information and use it to create the tracing context. Also, we have added the headers to propagate outside linkerd, to make life easier for applications that want to use opentracing libraries.

We have validated this in our environment, using linkerd as service mesh as part of a DC/OS installation. We have seen the same traceId in zipkin with this change for both LB and linkerd.

Fixes #[1447]
@adleong
Copy link
Member

adleong commented Jun 26, 2018

Thanks for this, @jmalvarezf! I agree with you that Linkerd is long overdue to play more nicely with other tracing systems like OpenTracing. Unfortunately, there are a few complications.

So far, Linkerd has always used its own l5d-ctx-trace header for trace propagation and just blindly forwarded other headers such as the x-b3 ones. This means that Linkerd tracing can peacefully co-exist in a system that also does x-b3 style tracing. The two systems will basically be invisible to each other.

With your change, Linkerd will read the x-b3 headers and prefer them to the l5d-ctx-trace header. It will also write out both styles of headers. The problem with this is that it's a backwards incompatible change. In cases where both headers are present, this changes Linkerd's behavior to use the x-b3 header instead of the l5d-ctx-trace one.

Even switching the precedence so that Linkerd prefers the l5d-ctx-trace header over the x-b3 headers doesn't solve the problem fully. In cases where the request is sent through a tracing aware service that increments the x-b3 span header, that span would get lost at the next Linkerd because Linkerd would ignore it in favor of the l5d-ctx-trace header.

The complexity compounds even further if you want to support other tracing propogation headers such as jaeger's uber-trace-id or lightstep's ot-tracer- headers.

The TLDR is that I think this needs to be something configurable so that users can decide which tracing systems they want Linkerd to participate in and which they want Linkerd to ignore. Would you be willing to hold off on this PR while I put together a Linkerd trace propagation plugin interface? This would then allow you to resubmit your change as a trace propagation plugin.

I hope this context is useful, please let me know what you think!

@jmalvarezf
Copy link
Contributor Author

Hi @adleong,

Yes, I think it makes total sense!
I will rewrite this when you have the interface ready. Do you want me to close this? Or you prefer to leave it open?

Thank you!

@adleong
Copy link
Member

adleong commented Jun 27, 2018

@jmalvarezf I'll leave it up to you. Either way we can close this one once the replacement is ready.

@adleong
Copy link
Member

adleong commented Jun 29, 2018

Please see #2025 and let me know what you think.

@jmalvarezf
Copy link
Contributor Author

I'll try to adapt this to the interface you propose during the following month when I have enough time and I'll let you know. Thank you!

@adleong
Copy link
Member

adleong commented Jul 11, 2018

@jmalvarezf the new interface has merged. Please let me know if you need any help with this new interface!

}

object Trace {
val Key = Prefix + "trace"
val OpentracingSpanHeader = "x-b3-spanid";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has nothing to do with opentracing by the way. OpenTracing includes no library support for B3 unless something changed recently. census does however. B3 is defined here https://github.com/openzipkin/b3-propagation

@jmalvarezf
Copy link
Contributor Author

You are right. This is not opentracing but zipkin. Ill close this and start working on the interface already merged.

Thanks

@jmalvarezf jmalvarezf closed this Jul 12, 2018
@codefromthecrypt
Copy link

codefromthecrypt commented Jul 12, 2018 via email

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

Successfully merging this pull request may close these issues.

Add a "l5d-trace" user header which can be used to manipulate the "l5d-ctx-trace" header
3 participants