-
Notifications
You must be signed in to change notification settings - Fork 50
Add support for https://github.com/w3c/distributed-tracing #70
Comments
OpenCensus Go already has support for this format. Feel free to use it as reference. https://github.com/census-instrumentation/opencensus-go/tree/master/plugin/ochttp/propagation/tracecontext |
@rakyll we probably need to propagate the Trace-State as well. For the moment no need to look into it but we need to propagate that. |
@bogdandrutu @adriancole @rakyll, we've been looking into the changes needed to support the W3C protocol and wanted to share our thoughts with you. Would be great to hear your thoughts on it and discuss overall plan and the details. traceparentNow the header that carries span context is called Supporting traceparent seems to be straightforward in any language as it is the same as X-Cloud-Trace-Context. The main point here: we should agree on intention that W3C becomes default propagation component. E.g. in python flask collector X-Cloud-Trace-Context is hardcoded. tracestateTracestate carries tracing-system specific context in a list of key value pairs. tracestate allows different vendors propagate additional information and interoperate with their legacy Id formats (and migrate from legacy format to the traceparent). One of the possible scenarios for tracestate is:
So the key requirement here is: 'unknown' pairs should be propagated blindly (in and out of process), 'known' pairs could be modified by pluggable vendor-specific component for each span. From the OpenCensus side, supporting tracestate would mean
General implementation considerationsTracestateTracestate should be represented by the class that allows to add, get, update and delete pairs. It should handle overflows of key, value and overall length. It is likely that tracestate is empty or contains just a few pairs. It's also likely that only the first pair will ever be updated (all apps in the cluster are instrumented by the same vendor and request leaves cluster boundary rarely). CallbackCallback should be fired when new span is created/started. OpenCensus should pass child tracestate to the vendor plugins and must synchronously wait for all plugins to complete updating a child state. OpenCensus should implement default behavior: copy parent tracestate to child tracestate (open question: can we do it efficiently, without copy?). If there are no plugins registered, callback may be skipped (as well as copying the state). Instead of pub-sub callback, we could use inheritance: have an interface that vendor can implement and register. It will be invoked to update the context. If there is no registered implementation - tracestate is propagated without modification. However, this will prevent certain scenarios like multiple vendor plugins. Open questions:
|
Thanks for @reyang to bring me to here. I am familiar with what W3C trace context do. I think @reyang 's proposal in #131 (comment) is very useful. |
small notes: sometimes a span is resumed (not just new or started) so for example brave decorate is hook whenever a span context is to be used or used again https://github.com/openzipkin/brave/blob/master/brave/src/main/java/brave/propagation/Propagation.java also and similarly true that we should focus on trace state though there may be other consumers of hooks like this (ex arbitrary or not yet defined field propagation). even if we do subclass approach for things here it might not be viable for multi party. this is why brave propagation hook is composition (of extra things) not inheritance even if a sub hook (like tracestate) could have inheritance. anyway just offering 2p as did something similar last year and it works for different trace contexts.. might be helpful background even if only java. |
Great feedback @lmolkova. Not 100% I understand the discussion about sub-class approach vs composition. Can @lmolkova or @adriancole write an example. Here are things that we should do to support tracestate (based on my current understanding):
|
I think maybe just hook on creating maybe not enough. At the stage of creating, only can get a span name, right? Some propagation context is in annotation or attribute. So, may need hook on that too. |
@bogdandrutu welcome back!
This is the discussion around hook implementation: how does OpenCensus notify vendor about new span and how does vendor subscribe. It could be done through sub-class approach where vendor implements something like ITraceStatePropagation interface and in runtime OC finds the implementation. However this approach does not provide enough flexibility to support multiple vendors/extensions, so some kind of observer pattern looks more suitable. |
Right, when the hook is called it should pass parent tracestate. Perhaps if we're going to support Correlation-Context at some point, it should also pass Tags. Also, the tracestate is not particularly about propagation across the wire: it is also about in-proc auto-propagation. So adding arbitrary context through the annotations/attributes seems to be quite useful, but tracestate should be propagated automatically, where possible. |
Yes. I also want to say tracestate in W3C and auto-propagation are not totally the same thing. We have some similar usage. So, I hope the OC-team could think about providing auto-propagation context with the extendable mechanism, then consider tracestate in W3C is an extendable implementation. |
Already fixed. |
Once https://github.com/w3c/distributed-tracing is marked as alpha the OpenCensus library should start supporting this generic format.
This is for the moment a tracking issue for this support until we have the confirmation that the standard is at least in alpha.
The text was updated successfully, but these errors were encountered: