當前位置: 首頁>>代碼示例>>Java>>正文


Java Tracer.buildSpan方法代碼示例

本文整理匯總了Java中io.opentracing.Tracer.buildSpan方法的典型用法代碼示例。如果您正苦於以下問題:Java Tracer.buildSpan方法的具體用法?Java Tracer.buildSpan怎麽用?Java Tracer.buildSpan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.opentracing.Tracer的用法示例。


在下文中一共展示了Tracer.buildSpan方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: intercept

import io.opentracing.Tracer; //導入方法依賴的package包/類
@Override
public void intercept(FixedInvocation inv) {

    EnableTracing enableOpentracing = inv.getMethod().getAnnotation(EnableTracing.class);
    Tracer tracer = JbootOpentracingManager.me().getTracer();
    Span span = null;

    if (enableOpentracing != null && tracer != null) {
        String spanName = StringUtils.isBlank(enableOpentracing.value())
                ? inv.getController().getClass().getName() + "." + inv.getMethodName()
                : enableOpentracing.value();

        Tracer.SpanBuilder spanBuilder = tracer.buildSpan(spanName);

        span = spanBuilder.startManual();

        span.setTag("requestId", StringUtils.uuid());
        JbootSpanContext.add(span);
    }


    try {
        inv.invoke();
    } finally {
        if (span != null) {
            span.finish();
            JbootSpanContext.release();
        }
    }

}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:32,代碼來源:OpentracingInterceptor.java

示例2: startServerSpan

import io.opentracing.Tracer; //導入方法依賴的package包/類
public static Scope startServerSpan(Tracer tracer, javax.ws.rs.core.HttpHeaders httpHeaders,
        String operationName) {
    // format the headers for extraction
    MultivaluedMap<String, String> rawHeaders = httpHeaders.getRequestHeaders();
    final HashMap<String, String> headers = new HashMap<String, String>();
    for (String key : rawHeaders.keySet()) {
        headers.put(key, rawHeaders.get(key).get(0));
    }

    Tracer.SpanBuilder spanBuilder;
    try {
        SpanContext parentSpanCtx = tracer.extract(Format.Builtin.HTTP_HEADERS, new TextMapExtractAdapter(headers));
        if (parentSpanCtx == null) {
            spanBuilder = tracer.buildSpan(operationName);
        } else {
            spanBuilder = tracer.buildSpan(operationName).asChildOf(parentSpanCtx);
        }
    } catch (IllegalArgumentException e) {
        spanBuilder = tracer.buildSpan(operationName);
    }
    // TODO could add more tags like http.url
    return spanBuilder.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER).startActive(true);
}
 
開發者ID:yurishkuro,項目名稱:opentracing-tutorial,代碼行數:24,代碼來源:Tracing.java

示例3: testGetTracerResolved

import io.opentracing.Tracer; //導入方法依賴的package包/類
@Test(expected=DummyTracer.DummyCalled.class)
public void testGetTracerResolved() {
    OpenTracingHelper helper = new OpenTracingHelper(null);
    Tracer tracer = helper.getTracer();

    assertNotNull(tracer);

    tracer.buildSpan("Test");
}
 
開發者ID:opentracing-contrib,項目名稱:java-agent,代碼行數:10,代碼來源:OpenTracingHelperTest.java

示例4: processRefererTrace

import io.opentracing.Tracer; //導入方法依賴的package包/類
protected Result processRefererTrace(Tracer tracer, Invoker<?> invoker, Invocation inv) {
        String operationName = JbootDubboTracingFilterKits.buildOperationName(invoker,inv);
        Tracer.SpanBuilder spanBuilder = tracer.buildSpan(operationName);
        Span activeSpan = JbootDubboTracingFilterKits.getActiveSpan();
        if (activeSpan != null) {
            spanBuilder.asChildOf(activeSpan);
        }
        Span span = spanBuilder.startManual();
//        span.setTag("requestId", request.getRequestId());

        attachTraceInfo(tracer, span, inv);
        return JbootDubboTracingFilterKits.process(invoker, inv, span);

    }
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:15,代碼來源:JbootDubboConsumerTracingFilter.java

示例5: extractTraceInfo

import io.opentracing.Tracer; //導入方法依賴的package包/類
protected Span extractTraceInfo(Tracer tracer, Invoker<?> invoker, Invocation inv) {
    String operationName = JbootDubboTracingFilterKits.buildOperationName(invoker, inv);
    Tracer.SpanBuilder span = tracer.buildSpan(operationName);
    try {
        SpanContext spanContext = tracer.extract(Format.Builtin.TEXT_MAP, new TextMapExtractAdapter(inv.getAttachments()));
        if (spanContext != null) {
            span.asChildOf(spanContext);
        }
    } catch (Exception e) {
        span.withTag("Error", "extract from request fail, error msg:" + e.getMessage());
    }
    return span.startManual();
}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:14,代碼來源:JbootDubboProviderTracingFilter.java

示例6: processRefererTrace

import io.opentracing.Tracer; //導入方法依賴的package包/類
/**
 * process trace in client end
 *
 * @param caller
 * @param request
 * @return
 */
protected Response processRefererTrace(Tracer tracer, Caller<?> caller, Request request) {
    String operationName = buildOperationName(request);
    Tracer.SpanBuilder spanBuilder = tracer.buildSpan(operationName);
    Span activeSpan = getActiveSpan();
    if (activeSpan != null) {
        spanBuilder.asChildOf(activeSpan);
    }
    Span span = spanBuilder.startManual();
    span.setTag("requestId", request.getRequestId());

    attachTraceInfo(tracer, span, request);
    return process(caller, request, span);

}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:22,代碼來源:JbootMotanTracingFilter.java

示例7: extractTraceInfo

import io.opentracing.Tracer; //導入方法依賴的package包/類
protected Span extractTraceInfo(Request request, Tracer tracer) {
    String operationName = buildOperationName(request);
    Tracer.SpanBuilder span = tracer.buildSpan(operationName);
    try {
        SpanContext spanContext = tracer.extract(Format.Builtin.TEXT_MAP, new TextMapExtractAdapter(request.getAttachments()));
        if (spanContext != null) {
            span.asChildOf(spanContext);
        }
    } catch (Exception e) {
        span.withTag("Error", "extract from request fail, error msg:" + e.getMessage());
    }
    return span.startManual();
}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:14,代碼來源:JbootMotanTracingFilter.java


注:本文中的io.opentracing.Tracer.buildSpan方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。