Java Code Examples for io.opentracing.Scope#span()

The following examples show how to use io.opentracing.Scope#span() . 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: OpenTracingDecorator.java    From smallrye-graphql with Apache License 2.0 6 votes vote down vote up
@Override
protected void before(final ExecutionContext executionContext) {
    final DataFetchingEnvironment env = executionContext.dataFetchingEnvironment();
    Tracer tracer = openTracingService.getTracer();

    Span parentSpan = getParentSpan(tracer, env);

    Scope scope = tracer.buildSpan(SpanNaming.getOperationName(env))
            .asChildOf(parentSpan)
            .withTag("graphql.executionId", env.getExecutionId().toString())
            .withTag("graphql.operationName", env.getOperationDefinition().getName())
            .withTag("graphql.parent", NameHelper.getName(env.getParentType()))
            .withTag("graphql.field", env.getField().getName())
            .withTag("graphql.path", env.getExecutionStepInfo().getPath().toString())
            .startActive(false);

    final Span span = scope.span();
    executionContext.newGraphQLContext().put(PARENT_SPAN_KEY, span);

    spans.put(executionContext, span);
}
 
Example 2
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 3
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 4
Source File: OpenTracingFilter.java    From problematic-microservices with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
		throws IOException {
	if (isTraced(requestContext) && !keepOpen(requestContext.getProperty(PROPERTY_KEEP_OPEN))) {
		Scope scope = getActiveScope(httpRequest);
		Span span = scope.span(); 
		scope.close();
		span.finish();
	}
}
 
Example 5
Source File: TracerWrapper.java    From java-jfr-tracer with Apache License 2.0 4 votes vote down vote up
@Override
@Deprecated
public Span activeSpan() {
	Scope active = scopeManager.active();
	return isNull(active) ? null : active.span();
}
 
Example 6
Source File: ScopeManagerWrapper.java    From java-jfr-tracer with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public Span activeSpan() {
	Scope scope = active();
	return scope == null ? null : scope.span();
}
 
Example 7
Source File: ThresholdLogTracer.java    From couchbase-jvm-core with Apache License 2.0 4 votes vote down vote up
@Override
public Span activeSpan() {
    Scope scope = scopeManager.active();
    return scope == null ? null : scope.span();
}