Skip to content

TracingServerInterceptor not closing activated Scopes ? #57

@jelgh

Description

@jelgh

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! 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions