Java Code Examples for io.opentracing.ScopeManager#active()

The following examples show how to use io.opentracing.ScopeManager#active() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TracingContextProvider.java    From thorntail with Apache License 2.0 6 votes vote down vote up
@Override
public MiniConProp.ContextSnapshot capture() {
    Tracer tracer = GlobalTracer.get();
    ScopeManager scopeManager = tracer.scopeManager();
    Scope activeScope = scopeManager.active();

    if (activeScope != null) {
        Span span = activeScope.span();
        return () -> {
            Scope propagated = scopeManager.activate(span, false);
            return propagated::close;
        };
    }

    return MiniConProp.ContextSnapshot.NOOP;
}
 
Example 2
Source File: TracingContextProvider.java    From smallrye-fault-tolerance with Apache License 2.0 5 votes vote down vote up
@Override
public ThreadContextSnapshot currentContext(Map<String, String> props) {
    Tracer tracer = GlobalTracer.get();
    ScopeManager scopeManager = tracer.scopeManager();
    Scope activeScope = scopeManager.active();

    if (activeScope != null) {
        Span span = activeScope.span();
        return () -> {
            Scope propagated = scopeManager.activate(span, false);
            return propagated::close;
        };
    }
    return () -> DO_NOTHING;
}
 
Example 3
Source File: TracingContextProvider.java    From smallrye-fault-tolerance with Apache License 2.0 5 votes vote down vote up
@Override
public ThreadContextSnapshot clearedContext(Map<String, String> props) {
    return () -> {
        Tracer tracer = GlobalTracer.get();
        ScopeManager scopeManager = tracer.scopeManager();
        Scope activeScope = scopeManager.active();
        if (activeScope != null) {
            activeScope.close();
        }
        return () -> {
            // TODO: we should bring back the span here
        };
    };
}