当前位置: 首页>>代码示例>>Java>>正文


Java Brave.clientSpanThreadBinder方法代码示例

本文整理汇总了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));
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:ZipkinTracer.java

示例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));
                }
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:ZipkinTracer.java

示例3: ZipkinSchedulerInterceptor

import com.github.kristofa.brave.Brave; //导入方法依赖的package包/类
public ZipkinSchedulerInterceptor(final Brave brave) {
  this(brave.serverSpanThreadBinder(), brave.clientSpanThreadBinder());
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:4,代码来源:ZipkinSchedulerInterceptor.java

示例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());
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:5,代码来源:ZipkinEventBusClientInterceptor.java


注:本文中的com.github.kristofa.brave.Brave.clientSpanThreadBinder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。