com.github.kristofa.brave.Brave.localTracer()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中com.github.kristofa.brave.Brave.localTracer()方法的一些代码示例,展示了Brave.localTracer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Brave.localTracer()方法的具体详情如下:
包路径:com.github.kristofa.brave.Brave
类名称:Brave
方法名:localTracer

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();
 }
}

相关文章