-
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
Allow clearing the span from scope #1025
Comments
Hi, this is not a spec issue (or if it is, it should be handled in #1020). In Java, the way to clear a span is to pass a non-null invalid span. That should work something like |
Why isn't is a spec issue? I want to be able to clear the scope on the API level.
Maybe that's worth documenting in the Javadoc? Also it turns out that one can do:
Maybe instead of |
@marcingrzejszczak As far as I know, not all languages have the concept of a |
Let's see, there are actually two bits required from the spec:
So I'd say the spec has you covered. And as @anuraaga mentioned Scope and withSpan are just convenience helper methods in Java, and not defined at all at spec level. |
Oh, I didn't know that not everyone has a concept of a scope. If that's the case let's continue this discussion here open-telemetry/opentelemetry-java#1717 |
I have an issue like this, but I am not sure should I issue my question here, let me try to describe my problem: I have a Play-based application, which uses ebean as ORM framework. When a request comes into my play controller, the OpenTelemetry java agent creates a root context and span for my application, the traceId and spanId are injected into thread automatically, which is good for me. But when the request is over, the injected traceId and spanId are still left behind in thread and inherited child thread. Then the problem is coming: ebean has some daemon threads aiming to do polling all the time to keep the database connection is alive. daemon threads are injected traceId and keep printing legacy traceid. And the polling spans keep to be sended to remote collector. So simple request may get a long long long trace tree after some time. What is the recommended practice to clear these injected, legacy contexts? |
Hey @magicliang , |
In Spring Cloud Sleuth we have the following situation with scheduled methods. We instrument
ExecutorService
s that schedule tasks to be executed in separate threads. At the point of instrumenting we have no idea what that task really is (e.g. it may end up to be a@Scheduled
annotated method). Currently, with Brave, users have the option to define a property to pick which@Scheduled
annotated methods should be ignored, thus not instrumented. So what we do is we clear the tracing contextWhen I look at the OTel API for
Tracer
I see that I can't clear the scope (null
can't be passed).I would propose clearing that requirement that
NPE
should be thrown whenspan
isnull
. It's a valid case to perform a later decision within the lifecycle of the span about putting it out of the scope.The text was updated successfully, but these errors were encountered: