本文整理匯總了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();
}
}
}
示例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);
}
示例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");
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}