/** * Returns a new child span if there's a {@link #currentSpan()} or a new trace if there isn't. * * <p>Prefer {@link #startScopedSpan(String)} if you are tracing a synchronous function or code * block. */ public Span nextSpan() { TraceContext parent = currentTraceContext.get(); return parent != null ? newChild(parent) : newTrace(); }
private Span createSpan(String spanName, String path) { Span currentSpan = tracer.currentSpan(); if (currentSpan != null) { return tracer.newChild(currentSpan.context()).name(spanName).tag(CALL_PATH, path).start(); } return tracer.newTrace().name(spanName).tag(CALL_PATH, path).start(); }
/** * Returns a new child span if there's a {@link #currentSpan()} or a new trace if there isn't. * * <p>Prefer {@link #startScopedSpan(String)} if you are tracing a synchronous function or code * block. */ public Span nextSpan() { TraceContext parent = currentTraceContext.get(); return parent != null ? newChild(parent) : newTrace(); }
/** * Returns a span representing the sampled status of the current server span or null if there's no * span attached to the current thread. */ @Nullable public static brave.Span getServerSpan(Tracer tracer, ServerSpanThreadBinder threadBinder) { if (tracer == null) throw new NullPointerException("tracer == null"); if (threadBinder == null) throw new NullPointerException("threadBinder == null"); ServerSpan result = threadBinder.getCurrentServerSpan(); if (result == null || result.equals(ServerSpan.EMPTY)) return null; if (result.getSpan() != null) return toSpan(tracer, result.getSpan()); assert result.getSample() != null && !result.getSample() : "unexpected sample state: " + result; return tracer.withSampler(Sampler.NEVER_SAMPLE).newTrace(); }
@Override Span nextSpan(@Nullable SpanId maybeParent) { brave.Span span = maybeParent != null ? tracer.newChild(toTraceContext(maybeParent)) : tracer.newTrace(); return Brave.toSpan(toSpanId(span.context())); }
Span span = tracer.currentSpan(); if (span == null) { span = tracer.newTrace();
private TraceScope newOrChildSpan(final String description, final Span parent) { if (parent == null) { return new TraceScope(brave, tracer.newTrace().name(description).start()); } return new TraceScope(brave, tracer.newChild(parent.context()).name(description).start()); } }
private TraceScope newOrChildSpan(final String description, final Span parent) { if (parent == null) { return new TraceScope(brave, tracer.newTrace().name(description).start()); } return new TraceScope(brave, tracer.newChild(parent.context()).name(description).start()); } }
span = scopedBraveTracer.newTrace(); } else if ((context = reference.unwrap()) != null) {
private Span createSpan(String spanName, String path) { Span currentSpan = tracer.currentSpan(); if (currentSpan != null) { return tracer.newChild(currentSpan.context()).name(spanName).tag(CALL_PATH, path).start(); } return tracer.newTrace().name(spanName).tag(CALL_PATH, path).start(); }
private Span createSpan(String spanName, String path) { Span currentSpan = tracer.currentSpan(); if (currentSpan != null) { return tracer.newChild(currentSpan.context()).name(spanName).tag(CALL_PATH, path).start(); } return tracer.newTrace().name(spanName).tag(CALL_PATH, path).start(); }
@Override public void createChildSpan(TracingWrapper<ZipkinWrapper> parent) { operationName = UUID.randomUUID().toString().replace("-",""); if (parent == null) { // root node we start a new trace span = tracing.tracer().newTrace().name(operationName + "-root") .start(); } else { brave.Span parentClient = parent.get().tracing.tracer().newChild(parent.get().span.context()) .kind(Kind.CLIENT) .name(operationName + "-client") .start(); // TODO if I finish this later the span is cached // and joined with server span and reported as a single span. // to properly solve this we have to look into the tags. // However there is another problem jaeger adds only one span.kind // (even if span contains cs,cr,sr,ss) // And it filters out core annotations, so there is no way how to find out // that there is a dependency link in this span. // https://github.com/jaegertracing/jaeger/issues/451 parentClient.finish(); span = tracing.tracer().joinSpan(parentClient.context()) .name(operationName + "-server") .kind(Kind.SERVER) .start(); } }