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

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

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

Brave.serverSpanThreadBinder介绍

[英]Helper object that can be used to propogate server trace state. Typically over different threads.
[中]可用于传播服务器跟踪状态的Helper对象。通常在不同的线程上。

代码示例

代码示例来源:origin: com.github.kristofa/brave-core-spring

@Bean
  @Scope(value = "singleton")
  public ServerSpanThreadBinder serverSpanThreadBinder() {
    return brave.serverSpanThreadBinder();
  }
}

代码示例来源:origin: xuminwlt/j360-dubbo-app-all

public void setBrave(Brave brave) {
  this.brave = brave;
  this.serverRequestInterceptor = checkNotNull(brave.serverRequestInterceptor());
  this.serverResponseInterceptor = checkNotNull(brave.serverResponseInterceptor());
  this.serverSpanThreadBinder = brave.serverSpanThreadBinder();
}

代码示例来源:origin: jgchen/brave-dubbo

public static void setBrave(Brave brave) {
  BraveProviderFilter.brave = brave;
  BraveProviderFilter.serverRequestInterceptor = brave.serverRequestInterceptor();
  BraveProviderFilter.serverResponseInterceptor = brave.serverResponseInterceptor();
  BraveProviderFilter.serverSpanThreadBinder = brave.serverSpanThreadBinder();
}

代码示例来源:origin: io.zipkin.brave/brave-core

@Override public void setClientAddress(Brave brave, Endpoint ca) {
    Span span = brave.serverSpanThreadBinder().get();
    if (span == null) return;
    brave.serverTracer.recorder().address(span, "ca", ca);
  }
};

代码示例来源:origin: io.zipkin.brave/brave-core

BraveExecutorService(ExecutorService wrappedExecutor, Brave brave) { // intentionally hidden
  this.wrappedExecutor = checkNotNull(wrappedExecutor, "wrappedExecutor");
  checkNotNull(brave, "brave");
  this.localSpanThreadBinder = brave.localSpanThreadBinder();
  this.serverSpanThreadBinder = brave.serverSpanThreadBinder();
}

代码示例来源:origin: io.zipkin.brave/brave-core

/**
 * @since 3.17
 */
public static BraveRunnable wrap(Runnable runnable, Brave brave) {
  checkNotNull(brave, "brave"); // auto-value will check the others.
  return new AutoValue_BraveRunnable(
    runnable,
    brave.localSpanThreadBinder(),
    brave.localSpanThreadBinder().getCurrentLocalSpan(),
    brave.serverSpanThreadBinder(),
    brave.serverSpanThreadBinder().getCurrentServerSpan()
  );
}

代码示例来源:origin: io.zipkin.brave/brave-core

/**
 * @since 3.17
 */
public static <T> BraveCallable<T> wrap(Callable<T> callable, Brave brave) {
  checkNotNull(brave, "brave"); // auto-value will check the others.
  return new AutoValue_BraveCallable(
    callable,
    brave.localSpanThreadBinder(),
    brave.localSpanThreadBinder().getCurrentLocalSpan(),
    brave.serverSpanThreadBinder(),
    brave.serverSpanThreadBinder().getCurrentServerSpan()
  );
}

代码示例来源:origin: io.zipkin.brave/brave-spring-web-servlet-interceptor

ServletHandlerInterceptor(Builder b) { // intentionally hidden
  this.requestInterceptor = b.brave.serverRequestInterceptor();
  this.responseInterceptor = b.brave.serverResponseInterceptor();
  this.serverThreadBinder = b.brave.serverSpanThreadBinder();
  this.spanNameProvider = b.spanNameProvider;
  this.serverTracer = b.brave.serverTracer();
  this.maybeAddClientAddressFromRequest = MaybeAddClientAddressFromRequest.create(b.brave);
}

代码示例来源:origin: xuminwlt/j360-dubbo-app-all

protected HttpBraveServletFilter(Builder b,Set paths) { // intentionally hidden
  this.requestInterceptor = b.brave.serverRequestInterceptor();
  this.responseInterceptor = b.brave.serverResponseInterceptor();
  this.spanNameProvider = b.spanNameProvider;
  this.serverTracer = b.brave.serverTracer();
  this.maybeAddClientAddressFromRequest = MaybeAddClientAddressFromRequest.create(b.brave);
  this.maybeAddClientHeaderParamFromRequest = MaybeAddClientHeaderParamFromRequest.create(b.brave);
  this.serverSpanThreadBinder = b.brave.serverSpanThreadBinder();
  this.appliedPaths = paths;
}

代码示例来源:origin: io.zipkin/zipkin-java-server

@Override
public void addInterceptors(InterceptorRegistry registry) {
 ServerTracer tracer = brave.serverTracer();
 ServletHandlerInterceptor traceInterceptor = new ServletHandlerInterceptor(
   new ServerRequestInterceptor(tracer), new ServerResponseInterceptor(tracer),
   new DefaultSpanNameProvider(), brave.serverSpanThreadBinder());
 registry.addInterceptor(new NoPOSTHandlerInterceptorAdapter(traceInterceptor));
}

代码示例来源:origin: io.zipkin.brave/brave-core

public final void accept(T input) {
 ServerSpan serverSpan = brave.serverSpanThreadBinder().getCurrentServerSpan();
 Span span = serverSpan != null ? serverSpan.getSpan() : null;
 if (span == null) return;

代码示例来源:origin: io.zipkin.brave/brave-http-tests

@Test
public void usesExistingTraceId_server() throws Exception {
 server.enqueue(new MockResponse());
 brave.serverTracer().setStateUnknown("test");
 ServerSpan parent = brave.serverSpanThreadBinder().getCurrentServerSpan();
 try {
  get(client, "/foo");
 } finally {
  brave.serverTracer().clearCurrentSpan();
 }
 RecordedRequest request = server.takeRequest();
 assertThat(request.getHeader("x-b3-traceId"))
   .endsWith(IdConversion.convertToString(parent.getSpan().getTrace_id()));
 assertThat(request.getHeader("x-b3-parentspanid"))
   .endsWith(IdConversion.convertToString(parent.getSpan().getId()));
}

代码示例来源:origin: io.zipkin.brave/brave-http-tests

@Test
public void usesParentFromInvocationTime_server() throws Exception {
 server.enqueue(new MockResponse().setBodyDelay(1, TimeUnit.SECONDS));
 server.enqueue(new MockResponse());
 brave.serverTracer().setStateUnknown("test");
 ServerSpan parent = brave.serverSpanThreadBinder().getCurrentServerSpan();
 try {
  getAsync(client, "/foo");
  getAsync(client, "/foo");
 } finally {
  brave.serverTracer().clearCurrentSpan();
 }
 // changing the server span after the fact!
 brave.serverTracer().setStateUnknown("test");
 try {
  for (int i = 0; i < 2; i++) {
   RecordedRequest request = server.takeRequest();
   assertThat(request.getHeader("x-b3-traceId"))
     .endsWith(IdConversion.convertToString(parent.getSpan().getTrace_id()));
   assertThat(request.getHeader("x-b3-parentspanid"))
     .endsWith(IdConversion.convertToString(parent.getSpan().getId()));
  }
 } finally {
  brave.serverTracer().clearCurrentSpan();
 }
}

相关文章