本文整理汇总了Java中com.github.kristofa.brave.Brave.serverSpanThreadBinder方法的典型用法代码示例。如果您正苦于以下问题:Java Brave.serverSpanThreadBinder方法的具体用法?Java Brave.serverSpanThreadBinder怎么用?Java Brave.serverSpanThreadBinder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.kristofa.brave.Brave
的用法示例。
在下文中一共展示了Brave.serverSpanThreadBinder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clientRequest
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
private void clientRequest(Brave brave, String serviceName, ExchangeSendingEvent event) {
ClientSpanThreadBinder clientBinder = brave.clientSpanThreadBinder();
ServerSpanThreadBinder serverBinder = brave.serverSpanThreadBinder();
// reuse existing span if we do multiple requests from the same
ZipkinState state = event.getExchange().getProperty(ZipkinState.KEY, ZipkinState.class);
if (state == null) {
state = new ZipkinState();
event.getExchange().setProperty(ZipkinState.KEY, state);
}
// if we started from a server span then lets reuse that when we call a downstream service
ServerSpan last = state.peekServerSpan();
if (last != null) {
serverBinder.setCurrentSpan(last);
}
brave.clientRequestInterceptor().handle(new ZipkinClientRequestAdapter(this, serviceName, event.getExchange(), event.getEndpoint()));
// store span after request
Span span = clientBinder.getCurrentClientSpan();
state.pushClientSpan(span);
// and reset binder
clientBinder.setCurrentSpan(null);
serverBinder.setCurrentSpan(null);
if (span != null && LOG.isDebugEnabled()) {
String traceId = "" + span.getTrace_id();
String spanId = "" + span.getId();
String parentId = span.getParent_id() != null ? "" + span.getParent_id() : null;
if (LOG.isDebugEnabled()) {
if (parentId != null) {
LOG.debug(String.format("clientRequest [service=%s, traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, parentId));
} else {
LOG.debug(String.format("clientRequest [service=%s, traceId=%20s, spanId=%20s]", serviceName, traceId, spanId));
}
}
}
}
示例2: serverRequest
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
private ServerSpan serverRequest(Brave brave, String serviceName, Exchange exchange) {
ServerSpanThreadBinder serverBinder = brave.serverSpanThreadBinder();
// reuse existing span if we do multiple requests from the same
ZipkinState state = exchange.getProperty(ZipkinState.KEY, ZipkinState.class);
if (state == null) {
state = new ZipkinState();
exchange.setProperty(ZipkinState.KEY, state);
}
// if we started from a another server span then lets reuse that
ServerSpan last = state.peekServerSpan();
if (last != null) {
serverBinder.setCurrentSpan(last);
}
brave.serverRequestInterceptor().handle(new ZipkinServerRequestAdapter(this, exchange));
// store span after request
ServerSpan span = serverBinder.getCurrentServerSpan();
state.pushServerSpan(span);
// and reset binder
serverBinder.setCurrentSpan(null);
if (span != null && span.getSpan() != null && LOG.isDebugEnabled()) {
String traceId = "" + span.getSpan().getTrace_id();
String spanId = "" + span.getSpan().getId();
String parentId = span.getSpan().getParent_id() != null ? "" + span.getSpan().getParent_id() : null;
if (LOG.isDebugEnabled()) {
if (parentId != null) {
LOG.debug(String.format("serverRequest [service=%s, traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, parentId));
} else {
LOG.debug(String.format("serverRequest [service=%s, traceId=%20s, spanId=%20s]", serviceName, traceId, spanId));
}
}
}
return span;
}
示例3: serverResponse
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
private void serverResponse(Brave brave, String serviceName, Exchange exchange) {
ServerSpan span = null;
ZipkinState state = exchange.getProperty(ZipkinState.KEY, ZipkinState.class);
if (state != null) {
// only process if it was a zipkin server event
span = state.popServerSpan();
}
if (span != null) {
ServerSpanThreadBinder serverBinder = brave.serverSpanThreadBinder();
serverBinder.setCurrentSpan(span);
brave.serverResponseInterceptor().handle(new ZipkinServerResponseAdapter(this, exchange));
// and reset binder
serverBinder.setCurrentSpan(null);
if (span.getSpan() != null && LOG.isDebugEnabled()) {
String traceId = "" + span.getSpan().getTrace_id();
String spanId = "" + span.getSpan().getId();
String parentId = span.getSpan().getParent_id() != null ? "" + span.getSpan().getParent_id() : null;
if (LOG.isDebugEnabled()) {
if (parentId != null) {
LOG.debug(String.format("serverResponse[service=%s, traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, parentId));
} else {
LOG.debug(String.format("serverResponse[service=%s, traceId=%20s, spanId=%20s]", serviceName, traceId, spanId));
}
}
}
}
}
示例4: BraveResultSetFuture
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
BraveResultSetFuture(ResultSetFuture delegate, Brave brave) {
this.delegate = delegate;
this.threadBinder = brave.serverSpanThreadBinder();
this.parent = threadBinder.getCurrentServerSpan();
}
示例5: ZipkinWebHandler
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public ZipkinWebHandler(final Brave brave) {
this(brave.serverSpanThreadBinder(), brave.serverRequestInterceptor(), brave.serverResponseInterceptor());
}
示例6: ZipkinSchedulerInterceptor
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public ZipkinSchedulerInterceptor(final Brave brave) {
this(brave.serverSpanThreadBinder(), brave.clientSpanThreadBinder());
}
示例7: ZipkinEventBusClientInterceptor
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public ZipkinEventBusClientInterceptor(final Brave brave) {
this(brave.serverSpanThreadBinder(), brave.clientSpanThreadBinder(),
brave.clientRequestInterceptor(), brave.clientResponseInterceptor(), brave.localTracer());
}
示例8: ZipkinEventBusServerInterceptor
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public ZipkinEventBusServerInterceptor(final Brave brave) {
this(brave.serverSpanThreadBinder(), brave.serverRequestInterceptor(), brave.serverResponseInterceptor(), brave.localTracer());
}
示例9: AsyncHandler
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public AsyncHandler(Client client, Brave brave) {
this.client = Objects.requireNonNull(client);
this.braveExecutorService = new BraveExecutorService(Executors.newFixedThreadPool(10),
brave.serverSpanThreadBinder());
}
示例10: UsersHandler
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public UsersHandler(UserDAO userDAO, Client client, Brave brave) {
this.userDAO = userDAO;
this.client = Objects.requireNonNull(client);
this.braveExecutorService = new BraveExecutorService(Executors.newFixedThreadPool(10),
brave.serverSpanThreadBinder());
}