-
Notifications
You must be signed in to change notification settings - Fork 833
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 documentation on how to remove the span and disable implicit child spans for a particular code path #1717
Comments
Your code snippet just clears the current span, I don't know if that counts as "disable tracing". For disabling tracing, a spec issue is open at open-telemetry/opentelemetry-specification#530. EDIT: I think here you just want to clear the active span, so please be careful with terminology 😃 |
@Oberon00 I'm trying to differentiate between only clearing the active span, meaning a new span could be made, or making sure no new spans are made within that scope of code. Unless someone explicitly brings in a valid span with something like Edit: Parent would also need to be explicit to re-enable tracing |
Tracing is enabled, everything works as expected, there is just no current span. For example, if you set an attribute, you would usually not do it on the return value of getCurrentSpan, but on some span object you already have, which would still work. So I am against calling this "disable tracing". Also, it would easily be confused with what open-telemetry/opentelemetry-specification#530 wants to specify. |
If your code snippet disables tracing, then tracing is always initially disabled in opentelemetry-java. |
Well - changed the title to be more explicit, but IMO less clear. The difference between disable and stop tracing in my mind I think is Disabled: No spans are generated, nothing is propagated At least I think that's what open-telemetry/opentelemetry-specification#530 says. As you say, the extractors have the power to set the current span, but that's about it, and happens before user code so if a user sets the |
I think there was no intention to introduce a difference between disabling and stopping tracing.
Why only extractors? If the user
Note that while the invalid span has sampled=false, this is ignored due to it being invalid. |
You mean using |
No, also using the implicit current span as parent. EDIT: See also #1690 |
Ah oops - thanks yeah forgot the non-default tracer does that. It's related to that spec PR indeed. |
Yeah, I'd assume that were talking about removing the span from scope. That means that if I call |
currentSpan will never return null, but an invalid span if there is no current span. This is so that you never have to check if for null and calling anything on it is a no-op instead of crashing. |
@anuraaga do you think this is still needed, or is this blocked on spec changes? |
I think this is still needed and needing someone to drive the spec change |
I am trying to figure out if this a solution to a problem I have. What I would like to do is to be able to determine programmatically that a given span (and all its children) are uninteresting and should not be traced. Indeed maybe I want to discard the entire trace at this point and not send it to the collector. In other words, I think I want some way to say "isSampled=false" programmatically. Is there a way to do that today? The original post seems to imply there's a way to at least prune out some children by making the current span invalid but that seems more like a workaround? |
So, I am wondering, is there any news on this? I have manually instrumented my Kotlin Ktor API application, and use a Java Agent to collect all OpenTelemetry data. So how do I disable all child spans from being recorded? I am contemplating adding a root span attribute like |
Hi @peterdk - we're unfortunately still waiting for a language agnostic answer in the spec (open-telemetry/opentelemetry-specification#530). But in the mean time, check out #6546. Its a java specific solution, and requires coordination with instrumentation which has to check if the supress context key is set, but I believe instrumentations from cc @open-telemetry/java-instrumentation-maintainers to fact check me |
Currently, the best way to how to remove the span and disable implicit child spans for a particular code path is probably this
This should be documented, possibly with a helper somewhere, something like
Scope withTracingDisabled()
./cc @marcingrzejszczak
The text was updated successfully, but these errors were encountered: