本文整理了Java中brave.Tracer.newTrace()
方法的一些代码示例,展示了Tracer.newTrace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tracer.newTrace()
方法的具体详情如下:
包路径:brave.Tracer
类名称:Tracer
方法名:newTrace
[英]Explicitly creates a new trace. The result will be a root span (no parent span ID).
To implicitly create a new trace, or a span within an existing one, use #nextSpan().
[中]显式创建一个新跟踪。结果将是根范围(无父范围ID)。
要隐式创建新跟踪,或在现有跟踪中创建范围,请使用#nextSpan()。
代码示例来源:origin: openzipkin/brave
/**
* 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();
}
代码示例来源:origin: apache/servicecomb-java-chassis
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();
}
代码示例来源:origin: io.zipkin.brave/brave
/**
* 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();
}
代码示例来源:origin: io.zipkin.brave/brave-core
/**
* 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();
}
代码示例来源:origin: io.zipkin.brave/brave-core
@Override Span nextSpan(@Nullable SpanId maybeParent) {
brave.Span span = maybeParent != null
? tracer.newChild(toTraceContext(maybeParent))
: tracer.newTrace();
return Brave.toSpan(toSpanId(span.context()));
}
代码示例来源:origin: ww20081120/framework
Span span = tracer.currentSpan();
if (span == null) {
span = tracer.newTrace();
代码示例来源:origin: apache/cxf
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());
}
}
代码示例来源:origin: org.apache.cxf/cxf-integration-tracing-brave
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());
}
}
代码示例来源:origin: openzipkin-contrib/brave-opentracing
span = scopedBraveTracer.newTrace();
} else if ((context = reference.unwrap()) != null) {
代码示例来源:origin: org.apache.servicecomb/tracing-zipkin
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();
}
代码示例来源:origin: io.servicecomb/tracing-zipkin
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();
}
代码示例来源:origin: jaegertracing/spark-dependencies
@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();
}
}
内容来源于网络,如有侵权,请联系作者删除!