Skip to content

Commit cc1a835

Browse files
authored
Upgrade OpenTracing to v0.32 (#83)
Signed-off-by: Sjoerd Talsma <sjoerd@talsma-ict.nl>
1 parent e21b3c0 commit cc1a835

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

opentracing-span-propagation/src/main/java/nl/talsmasoftware/context/opentracing/ContextScopeManager.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,13 @@ public Scope activate(Span span, boolean finishSpanOnClose) {
7070
return new ThreadLocalSpanContext(getClass(), span, finishSpanOnClose);
7171
}
7272

73+
@Override
74+
public Scope activate(Span span) {
75+
return new ThreadLocalSpanContext(getClass(), span, false);
76+
}
77+
7378
/**
74-
* The currently active {@link Scope} containing the active span {@link Scope#span()}.
79+
* The currently active {@link Scope} containing the {@linkplain #activeSpan() active span}.
7580
*
7681
* @return the active scope, or {@code null} if none could be found.
7782
*/
@@ -80,6 +85,12 @@ public Scope active() {
8085
return ThreadLocalSpanContext.current();
8186
}
8287

88+
@Override
89+
public Span activeSpan() {
90+
Context<Span> current = ThreadLocalSpanContext.current();
91+
return current == null ? null : current.getValue();
92+
}
93+
8394
/**
8495
* Initializes a new context for the given {@linkplain Span}.
8596
*

opentracing-span-propagation/src/main/java/nl/talsmasoftware/context/opentracing/OpentracingContextTimer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*/
3737
public class OpentracingContextTimer implements ContextTimer {
3838
private static final String SYS_ENABLED = "opentracing.trace.contextmanager";
39-
private static final String ENV_ENABLED = SYS_ENABLED.toUpperCase().replace('.', '_');
39+
private static final String ENV_ENABLED = System.getenv(SYS_ENABLED.toUpperCase().replace('.', '_'));
4040
private static final String LOG_FIELD_THREAD = "context.thread";
4141

4242
@Override
@@ -62,7 +62,7 @@ public void update(Class<?> type, String method, long duration, TimeUnit unit) {
6262

6363
private static boolean reportContextSwitchesFor(Class<?> type) {
6464
boolean enableTracing = false;
65-
final String prop = System.getProperty(SYS_ENABLED, System.getenv(ENV_ENABLED));
65+
final String prop = System.getProperty(SYS_ENABLED, ENV_ENABLED);
6666
if ("1".equals(prop) || "true".equalsIgnoreCase(prop) || "enabled".equalsIgnoreCase(prop)) {
6767
// Only report spans for entire snapshots, not individual context managers
6868
// Could be made configurable if somebody ever asks for it..

opentracing-span-propagation/src/main/java/nl/talsmasoftware/context/opentracing/SpanManager.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package nl.talsmasoftware.context.opentracing;
1717

1818
import io.opentracing.Scope;
19-
import io.opentracing.ScopeManager;
2019
import io.opentracing.Span;
2120
import io.opentracing.util.GlobalTracer;
2221
import nl.talsmasoftware.context.Context;
@@ -28,8 +27,7 @@
2827
/**
2928
* Manager for <a href="http://opentracing.io/">OpenTracing</a> {@linkplain Span}.
3029
* <p>
31-
* Management of {@linkplain Span spans} is delegated to the {@linkplain ScopeManager}
32-
* from the {@linkplain GlobalTracer}.
30+
* Management of {@linkplain Span spans} is delegated to the {@linkplain GlobalTracer}.
3331
*
3432
* @author Sjoerd Talsma
3533
*/
@@ -50,7 +48,7 @@ public Context<Span> getActiveContext() {
5048
}
5149

5250
/**
53-
* {@linkplain ScopeManager#activate(Span, boolean) Activates} the given {@linkplain Span span}.
51+
* {@linkplain io.opentracing.ScopeManager#activate(Span) Activates} the given {@linkplain Span span}.
5452
* <p>
5553
* {@linkplain Context#close() Closing} the returned {@link Context} will also close the
5654
* corresponding {@link Scope} as it was also activated by us.<br>
@@ -69,7 +67,7 @@ public Context<Span> getActiveContext() {
6967
*/
7068
@Override
7169
public Context<Span> initializeNewContext(final Span span) {
72-
Scope scope = span == null ? null : GlobalTracer.get().scopeManager().activate(span, false);
70+
Scope scope = span == null ? null : GlobalTracer.get().scopeManager().activate(span);
7371
return new SpanContext(span, scope);
7472
}
7573

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<root.basedir>${project.basedir}</root.basedir>
8686

8787
<metrics.version>4.1.0</metrics.version>
88-
<opentracing-api.version>0.31.0</opentracing-api.version>
88+
<opentracing-api.version>0.32.0</opentracing-api.version>
8989
<spring-security.version>5.1.5.RELEASE</spring-security.version>
9090
<servlet-api.version>4.0.1</servlet-api.version>
9191

0 commit comments

Comments
 (0)