本文整理汇总了Java中io.opentracing.ActiveSpan.close方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveSpan.close方法的具体用法?Java ActiveSpan.close怎么用?Java ActiveSpan.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.opentracing.ActiveSpan
的用法示例。
在下文中一共展示了ActiveSpan.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testActiveSpanPropagation
import io.opentracing.ActiveSpan; //导入方法依赖的package包/类
@Test
public void testActiveSpanPropagation() {
ActiveSpan activeParent = tracer.buildSpan("active-span").startActive();
tracer.buildSpan("child-active-span").startActive().deactivate();
Assert.assertEquals("Haven't closed the parent", 1, dispatcher.getReportedSpans().size());
Assert.assertEquals(activeParent, tracer.activeSpan());
activeParent.close();
Assert.assertEquals("Parent closed", 2, dispatcher.getReportedSpans().size());
Span child = dispatcher.getReportedSpans().get(0);
Span parent = dispatcher.getReportedSpans().get(1);
Assert.assertEquals("Child should have a reference", 1, child.getReferences().size());
Assert.assertEquals(References.CHILD_OF, child.getReferences().get(0).getReferenceType());
Assert.assertEquals(parent.context(), child.getReferences().get(0).getContext());
Assert.assertEquals(parent.context().getTraceId(), child.context().getTraceId());
Assert.assertEquals(parent.context().getSpanId(), child.context().getParentId());
}
示例2: testActiveSpanPreSeeded
import io.opentracing.ActiveSpan; //导入方法依赖的package包/类
@Test
public void testActiveSpanPreSeeded() {
ActiveSpan activeParent = tracer.buildSpan("active").startActive();
tracer.buildSpan("child").asChildOf(span).startActive().deactivate();
activeParent.close();
span.finish();
Assert.assertEquals("All spans closed", 3, dispatcher.getReportedSpans().size());
Span child = dispatcher.getReportedSpans().get(0);
Span active = dispatcher.getReportedSpans().get(1);
Span parent = dispatcher.getReportedSpans().get(2);
Assert.assertEquals("Child should have a reference", 1, child.getReferences().size());
Assert.assertEquals(References.CHILD_OF, child.getReferences().get(0).getReferenceType());
Assert.assertEquals(parent.context(), child.getReferences().get(0).getContext());
Assert.assertEquals(parent.context().getTraceId(), child.context().getTraceId());
Assert.assertEquals(parent.context().getSpanId(), child.context().getParentId());
Assert.assertTrue(parent.getReferences().isEmpty());
Assert.assertEquals(new UUID(0l, 0l), parent.context().getParentId());
Assert.assertTrue(active.getReferences().isEmpty());
Assert.assertEquals(new UUID(0l, 0l), active.context().getParentId());
}
示例3: traceBackgroundThread
import io.opentracing.ActiveSpan; //导入方法依赖的package包/类
@Around("execution (@org.springframework.scheduling.annotation.Scheduled * *.*(..))")
public Object traceBackgroundThread(final ProceedingJoinPoint pjp) throws Throwable {
// operation name is method name
ActiveSpan activeSpan = tracer.buildSpan(pjp.getSignature().getName())
.withTag(Tags.COMPONENT.getKey(), COMPONENT_NAME)
.withTag(ExtensionTags.CLASS_TAG.getKey(), pjp.getTarget().getClass().getSimpleName())
.withTag(ExtensionTags.METHOD_TAG.getKey(), pjp.getSignature().getName())
.startActive();
try {
return pjp.proceed();
} catch (Exception ex) {
SpanUtils.captureException(activeSpan, ex);
throw ex;
} finally {
activeSpan.close();
}
}
示例4: run
import io.opentracing.ActiveSpan; //导入方法依赖的package包/类
Map<String, String> run() {
ActiveSpan span = tracer.buildSpan("main")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
.startActive();
waitABit();
childOperation();
span.close();
Map<String, String> map = new HashMap<>();
TextMap carrier = new TextMapInjectAdapter(map);
tracer.inject(span.context(), Format.Builtin.TEXT_MAP, carrier);
return map;
}
示例5: childOperation
import io.opentracing.ActiveSpan; //导入方法依赖的package包/类
private void childOperation() {
ActiveSpan span = tracer.buildSpan("child")
.withTag("transactionId", "1")
.startActive();
waitABit();
span.log("Something happened");
span.close();
}
示例6: run
import io.opentracing.ActiveSpan; //导入方法依赖的package包/类
public void run(Map<String, String> map) {
TextMap carrier = new TextMapExtractAdapter(map);
SpanContext spanContext = tracer.extract(Format.Builtin.TEXT_MAP, carrier);
ActiveSpan span = tracer.buildSpan("main")
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
.addReference(References.FOLLOWS_FROM, spanContext)
.startActive();
waitABit();
span.close();
}