-
Notifications
You must be signed in to change notification settings - Fork 327
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 W3C Trace Context propagation #949
Conversation
Great job as far as I can tell, but you're gonna have to give me some time to study the specification. |
3a790a6
to
5aa1f28
Compare
Any plans on moving this forward? |
I want to get this thing merged this week, it seems pretty solid but I wanted to double check before merging. I had a chat with @jatcwang last week precisely about moving OTel-related support forward and I'm really grateful you are pushing for it @pnerg 🙏. (jumped out of the work bubble just to answer this message, will be back at it later today) |
Sounds super if we could get it into the baseline this week. The true test however will be to run a kamon instrumented app alongside with non-kamon apps, propagating the same w3c context AND reporting to the same OTLP endpoint hoping the total trace would be stitched properly |
I've been reading the spec https://www.w3.org/TR/trace-context/ P.S. rebasing onto master should fix the failing tests |
To be honest I've not really understood the use of the I've noticed that the OTLP spec contains a field trace_state which according to the docs relates to the w3c tracestate header. But the spec just defines it as a string so I assume one just crams the entire header as-is. The most important fields imo are the identifiers (trace, span, parent) as is using them one can stitch the trace. |
If I'm reading the spec correctly, we're not breaking anything by not touching I've raised an issue for handling How does that sound @pnerg ? |
excellent, I'll take it into use along with the OTel exporter and we'll see where it goes from there. |
Yeah, that's done on purpose. I think this behavior should be compliant with the specification as we don't really need to store any Kamon specific value in
If we would like to pass the Context, then probably it would be better to use |
I just took a second look at the spec and this PR, and I think it will work just fine 🎉 There is only one tiny thing that we should consider: Kamon uses 8-byte identifiers by default, but W3C uses 16-byte identifiers by default. I saw that this PR will handle it gracefully:
But it will be a bit odd that all traces starting on a Kamon application will have an ID like |
parentId = Identifier("2222", Array[Byte](2, 2, 2, 2)), | ||
trace = Trace( | ||
id = Identifier("1234", Array[Byte](1, 2, 3, 4)), | ||
samplingDecision = SamplingDecision.Sample |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a test for the Unknown
sampling decision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't mind if it's added, but it can be merged without it
@ivantopo when we implement support for OTel trace exporter the trace_id HAS to be 16 bytes.
Failing to comply will result in failure when exporting the trace. At least the reference collector I've tested with returns an error code. I'm more of a brutal failure person than the fix gracefully...:)
I've seen too many cases where logs are ignored and/or possibly just drown in an avalanche of other logs. |
I'm trying to balance the two sides we have seen over the years:
I find myself in the middle of these two groups 😅 In this case, this is what I think we should do:
I'm treating these two cases differently because using w3c tracecontext doesn't necessarily mean using the OTLP reporter, and the application will work fine in those cases anyways. I think we should be lining up a bigger release soon and change the default propagation to w3c tracecontext, along with the default identifier scheme. @duxet are you ok with adding the warning? |
I'm fine with any decision you make, I'll adapt the OTel exporter to behave in a similar fashion. As for releasing this feature, I'd be happy if we could come up with a minor release including the w3c context propagation. |
Sure, I've updated the PR. |
Well, it's not a hard requirement but still a recommendation to use the padding in such case:
|
@duxet , I've already surrendered on the id padding...:) |
New propagation implementation, based on W3C Trace Context specification. This PR solves #802.