-
Notifications
You must be signed in to change notification settings - Fork 889
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
Move context utils outside of the Tracer #527
Conversation
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
specification/api-tracing.md
Outdated
The API MUST provide methods to (depending on the language, global functions | ||
or util class e.g. `TracingContextUtils`): |
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.
The API MUST provide methods to (depending on the language, global functions | |
or util class e.g. `TracingContextUtils`): | |
The API MUST provide methods (or, depending on the language, global functions | |
or util class e.g. `TracingContextUtils`) to: |
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.
also s/TracingContextUtils/TracingContext/
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 think we need something as suffix or prefix if we want to be consistent for CorrelationContext which has Context
at the end, because will be ugly to name that CorrelationContextContext
:(. Any ideas?
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.
If context interaction is done via static util class, then TracingContext.activeSpan()
looks a lot better than TracingContextUtils.activeSpan()
.
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 do agree with you but I am trying to think how would I name this class for "CorrelationContext" package. If I find a good name for that and ensure consistency I am all to remove Utils
.
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.
CorrelationContext can remain CorrelationContext. It can represent both the object that stores correlations and the namespace for static functions.
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.
@yurishkuro I'd be up for not using TraceContext
and keeping the activation bits in CorrelationContext
- we will end up with too many classes having the Context
suffix (some of them doing different things, i.e. TraceContext
doing activation handling only, CorrelationContext
doing both activation handling PLUS as a container of key-values).
There was already some confusion in the past because of the fact we had both CorrelationContext
and Context
, so this could get worse ;)
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-Authored-By: Yuri Shkuro <yurishkuro@users.noreply.github.com>
The OpenTelemetry library achieves in-process context propagation of `Span`s by | ||
way of the [Context](./context.md). | ||
|
||
An `active Span` referes to a Span that is set to an |
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.
That means, for other languages (e.g. Go) all Spans are inactive?
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.
that means there is no concept of active span
. The current span is defined as the Span in the context passed to the function so no need to getCurrentSpan just getSpanFromContext.
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 would suggest:
- having a clear definition of "current" in the context.md, which can be defined both for implicit prop and for explicit prop (closest context in the lexical scope)
- converge on a single term for spans, either "active" or "current", not both, and define it as "span stored in the current context"
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.
@yurishkuro I agree on keeping either current or active, not both terms. However, I'm wondering if this should be done in a follow up PR.
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.
@carlosalberto I agree but this PR adds wording using both terms, at least within the PR it should be consistent.
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.
This PR does not add any new reference to either active or current, both were in the previous text.
@bogdandrutu Overall LGTM. @yurishkuro raises a few interesting points (on which all I agree), so I'd be up for merging this one after the issues have been resolved (a few of them can be done in a follow up too, as already mentioned). |
* Get/Set a Span from/to a Context | ||
* Make a given Span as active | ||
|
||
The API MUST internally leverage the Context in order to get and set the current |
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.
This sounds like logic is going into the API? Before the API was almost entirely interfaces.
Unless I'm misunderstanding this it seems instead of the Tracer simply calling to the sdk with a context and some options to start a span there is log in the API for juggling the span in the context, resulting in multiple calls from the API to the SDK?
How does this work out for the streaming SDK for example?
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.
It was my understanding that the API should never call the SDK and cannot depend on it. Otherwise it would be impossible to have third party SDKs
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.
The API is functions/methods that are implemented by the SDK, calling API functions results in whatever SDK is being used (if any) being called. Users do not call the SDK directly.
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.
@tsloughter As far as I'm aware, Context is not a part of the SDK but a third top-level item that the API and SDK depend on.
There used to be specification language about the Can we remove that now In my work on Resource Scope, open-telemetry/oteps#78, that method caused a headache. If something similar must be done, I would argue that Spans should be able to provide you with their parent's Context, not their Tracer. |
@tsloughter I am assuming that the Span has a reference to the Tracer that created it, but that it does not expose this to the user. I believe that if a user wants to get at the Tracer that created a Span, the user should retain a reference to the Context that was used to start the Span. |
The OpenTelemetry library achieves in-process context propagation of `Span`s by | ||
way of the [Context](./context.md). | ||
|
||
An `active Span` referes to a Span that is set to an |
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.
"a span that is set to an attached context" sounds unclear to me
The OpenTelemetry library achieves in-process context propagation of `Span`s by | ||
way of the [Context](./context.md). | ||
|
||
An `active Span` referes to a Span that is set to an |
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.
@carlosalberto I agree but this PR adds wording using both terms, at least within the PR it should be consistent.
Co-Authored-By: Armin Ruech <armin.ruech@gmail.com>
Co-Authored-By: Armin Ruech <armin.ruech@gmail.com>
Co-Authored-By: Armin Ruech <armin.ruech@gmail.com>
Co-Authored-By: Armin Ruech <armin.ruech@gmail.com>
@jmacd @tsloughter This PR does not changes anything related to Span having or not having a method to return the Tracer that created it. |
From the spec meeting I thought I'd show how we do propagation in the tracer in Erlang. -spec w3c_propagators() -> {ot_propagation:http_extractor(), ot_propagation:http_injector()}.
w3c_propagators() ->
ToText = fun ot_propagation_http_w3c:inject/2,
FromText = fun ot_propagation_http_w3c:extract/2,
Injector = ot_ctx:http_injector(?TRACER_KEY, ?TRACER_CTX, ToText),
Extractor = ot_ctx:http_extractor(?TRACER_KEY, ?EXTERNAL_SPAN_CTX, FromText),
{Extractor, Injector}. Applications can then setup a propagation in the SDK for the tracer of the SDK: {CorrelationExtractor, CorrelationInjector} = ot_correlations:get_http_propagators(),
{TracerExtractor, TracerInjector} = ot_tracer_default:w3c_propagators(),
opentelemetry:set_http_extractor([TracerExtractor, CorrelationExtractor]),
opentelemetry:set_http_injector([TracerInjector, CorrelationInjector]) But now I see maybe your issue is that I'm using the SDK tracer directly, |
I think this is partially obsolete after #619. |
Rational:
getCurrentSpan
an interface.Fixes: #455