Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

try-with-resources (which doesn't work) is still the main documented way to use OpenTracing in java #376

Open
dhalperi opened this issue May 1, 2020 · 0 comments

Comments

@dhalperi
Copy link

dhalperi commented May 1, 2020

cc: @felixbarny @carlosalberto (after #301, related #361)

"finishSpanOnClose" in "try-with-resources" is still the main documented way of using spans. E.g., see: https://opentracing.io/guides/java/scopes/#scope-objects which recommends

Tracer.SpanBuilder.startActiveSpan(boolean finishOnClose) will create a new Span and will automatically set is as the active one for the current context.

import io.opentracing.Scope;

// Strongly encouraged to use them under try statements,
// to prevent ending up with the incorrect active Span
// in case of error.
try (Scope scope = tracer.buildSpan("foo").startActive(true)) {
    scope.span().setTag(...);
    scope.span().log(...);
}

  // The 'foo' Span is finished at this point.

And there are several dead javadoc links throughout the codebase to startActive(boolean), which has been removed. https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/Tracer.java#L166

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

No branches or pull requests

1 participant