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


Java ActiveSpan.close方法代码示例

本文整理汇总了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());
}
 
开发者ID:ExpediaDotCom,项目名称:haystack-client-java,代码行数:21,代码来源:SpanPropagationTest.java

示例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());
}
 
开发者ID:ExpediaDotCom,项目名称:haystack-client-java,代码行数:25,代码来源:SpanPropagationTest.java

示例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();
  }
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-cloud,代码行数:18,代码来源:ScheduledAspect.java

示例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;
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:18,代码来源:Process.java

示例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();
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:12,代码来源:Process.java

示例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();
}
 
开发者ID:jeqo,项目名称:talk-observing-distributed-systems,代码行数:14,代码来源:AnotherProcess.java


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