本文整理了Java中com.github.kristofa.brave.Brave.localTracer()
方法的一些代码示例,展示了Brave.localTracer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Brave.localTracer()
方法的具体详情如下:
包路径:com.github.kristofa.brave.Brave
类名称:Brave
方法名:localTracer
[英]Returns a tracer used to log in-process activity.
[中]返回用于记录进程内活动的跟踪程序。
代码示例来源:origin: io.zipkin/zipkin-java-server
public TraceWritesSpanStore(Brave brave, SpanStore delegate) {
this.tracer = brave.localTracer();
this.delegate = delegate;
this.component = delegate.getClass().getSimpleName();
}
代码示例来源:origin: io.zipkin/zipkin-java-server
public void record(ApplicationEvent event) {
annotations.put(event.getClass().getSimpleName().replace("Event", ""), timestamp + microsSinceInit());
// record duration and flush the trace if we're done
if (event instanceof ApplicationReadyEvent) {
long duration = microsSinceInit(); // get duration now, as below logic might skew things.
ApplicationReadyEvent ready = (ApplicationReadyEvent) event;
LocalTracer tracer = ready.getApplicationContext().getBeanFactory()
.getBean(Brave.class).localTracer();
tracer.startNewSpan("spring-boot", "bootstrap", timestamp);
annotations.forEach(tracer::submitAnnotation);
tracer.finishSpan(duration);
}
}
代码示例来源:origin: io.zipkin.brave/brave-http-tests
@Test
public void usesExistingTraceId_local() throws Exception {
server.enqueue(new MockResponse());
SpanId parent = brave.localTracer().startNewSpan(getClass().getSimpleName(), "test");
try {
get(client, "/foo");
} finally {
brave.localTracer().finishSpan();
}
RecordedRequest request = server.takeRequest();
assertThat(request.getHeader("x-b3-traceId"))
.isEqualTo(parent.traceIdString());
assertThat(request.getHeader("x-b3-parentspanid"))
.endsWith(IdConversion.convertToString(parent.spanId));
}
代码示例来源:origin: io.zipkin.brave/brave-http-tests
/**
* This tests that the parent is determined at the time the request was made, not when the request
* was executed.
*/
@Test
public void usesParentFromInvocationTime_local() throws Exception {
server.enqueue(new MockResponse().setBodyDelay(1, TimeUnit.SECONDS));
server.enqueue(new MockResponse());
SpanId parent = brave.localTracer().startNewSpan(getClass().getSimpleName(), "test");
try {
getAsync(client, "/foo");
getAsync(client, "/foo");
} finally {
brave.localTracer().finishSpan();
}
// changing the local span after the fact!
brave.localTracer().startNewSpan(getClass().getSimpleName(), "test");
try {
for (int i = 0; i < 2; i++) {
RecordedRequest request = server.takeRequest();
assertThat(request.getHeader("x-b3-traceId"))
.isEqualTo(parent.traceIdString());
assertThat(request.getHeader("x-b3-parentspanid"))
.endsWith(IdConversion.convertToString(parent.spanId));
}
} finally {
brave.localTracer().finishSpan();
}
}
内容来源于网络,如有侵权,请联系作者删除!