Skip to content
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

TracingServerInterceptor not closing activated Scopes ? #57

Open
jelgh opened this issue Jun 28, 2021 · 2 comments
Open

TracingServerInterceptor not closing activated Scopes ? #57

jelgh opened this issue Jun 28, 2021 · 2 comments

Comments

@jelgh
Copy link

jelgh commented Jun 28, 2021

Hey,

We're having java services OOMing and traced the leakage to be related to a non-closed Scope returned from tracer.scopeManager().activate(span).

We fixed those issues and now see OOMs from another service where we don't have the above bug in our code. However, we use the TracingServerInterceptor from this library, and I noticed now that this class does does close the activated Scopes.

From the javadoc of io.opentracing.Tracer you find:

    /**
     * Make a {@link Span} instance active for the current context (usually a thread).
     * This is a shorthand for {@code Tracer.scopeManager().activate(span)}.
     *
     * @return a {@link Scope} instance to control the end of the active period for the {@link Span}. It is a
     * programming error to neglect to call {@link Scope#close()} on the returned instance,
     * and it may lead to memory leaks as the {@link Scope} may remain in the thread-local stack.
     */
    Scope activateSpan(Span span);

Am i missing anything or is there a bug in the code here? Happy to be proven wrong! 😄

@jelgh
Copy link
Author

jelgh commented Jun 28, 2021

This also exists in the client one TracingClientInterceptor btw

@zzxgzgz
Copy link

zzxgzgz commented Nov 30, 2021

Hi,

Is there any update on this one? I think I am encountering the same problem here.

I'm using a TracingServerInterceptor to trace my gRPC server, and it seems like that the server spans are not closing, which is producing a trace graph like this:
image

The RequestGoalStates are separate, but the later spans are generated as if they are the children of the previous span.

Am I using the interceptor incorrectly? Any help will be appreciated.

Thank you,
Rio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants