本文整理汇总了Java中com.github.kristofa.brave.Brave.clientSpanThreadBinder方法的典型用法代码示例。如果您正苦于以下问题:Java Brave.clientSpanThreadBinder方法的具体用法?Java Brave.clientSpanThreadBinder怎么用?Java Brave.clientSpanThreadBinder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.kristofa.brave.Brave
的用法示例。
在下文中一共展示了Brave.clientSpanThreadBinder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: clientResponse
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
private void clientResponse(Brave brave, String serviceName, ExchangeSentEvent event) {
Span span = null;
ZipkinState state = event.getExchange().getProperty(ZipkinState.KEY, ZipkinState.class);
if (state != null) {
// only process if it was a zipkin client event
span = state.popClientSpan();
}
if (span != null) {
ClientSpanThreadBinder clientBinder = brave.clientSpanThreadBinder();
clientBinder.setCurrentSpan(span);
brave.clientResponseInterceptor().handle(new ZipkinClientResponseAdaptor(this, event.getExchange(), event.getEndpoint()));
// and reset binder
clientBinder.setCurrentSpan(null);
if (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("clientResponse[service=%s, traceId=%20s, spanId=%20s, parentId=%20s]", serviceName, traceId, spanId, parentId));
} else {
LOG.debug(String.format("clientResponse[service=%s, traceId=%20s, spanId=%20s]", serviceName, traceId, spanId));
}
}
}
}
}
示例3: ZipkinSchedulerInterceptor
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public ZipkinSchedulerInterceptor(final Brave brave) {
this(brave.serverSpanThreadBinder(), brave.clientSpanThreadBinder());
}
示例4: ZipkinEventBusClientInterceptor
import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public ZipkinEventBusClientInterceptor(final Brave brave) {
this(brave.serverSpanThreadBinder(), brave.clientSpanThreadBinder(),
brave.clientRequestInterceptor(), brave.clientResponseInterceptor(), brave.localTracer());
}