com.nike.wingtips.Span.generateChildSpan()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中com.nike.wingtips.Span.generateChildSpan()方法的一些代码示例,展示了Span.generateChildSpan()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Span.generateChildSpan()方法的具体详情如下:
包路径:com.nike.wingtips.Span
类名称:Span
方法名:generateChildSpan

Span.generateChildSpan介绍

暂无

代码示例

代码示例来源:origin: Nike-Inc/wingtips

@DataProvider
public static Object[][] spanStackDataProvider() {
  Span rootSpan = Span.generateRootSpanForNewTrace("rootspan", SpanPurpose.SERVER).build();
  Span childSpan = rootSpan.generateChildSpan("childSpan", SpanPurpose.CLIENT);
  return new Object[][] {
      { null },
      { new LinkedList<>() },
      { new LinkedList<>(Collections.singleton(rootSpan)) },
      { new LinkedList<>(Arrays.asList(rootSpan, childSpan)) }
  };
}

代码示例来源:origin: Nike-Inc/wingtips

? parentSpan.generateChildSpan(spanName, spanPurpose)
: Span.generateRootSpanForNewTrace(spanName, spanPurpose).withSampleable(isNextRootSpanSampleable()).build();

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void registerWithThread_should_work_as_advertised() {
  // given
  Tracer tracer = Tracer.getInstance();
  Deque<Span> newSpanStack = new LinkedList<>();
  Span parentSpan = Span.newBuilder("foo", SpanPurpose.LOCAL_ONLY).build();
  Span subspan = Span.newBuilder("bar", SpanPurpose.LOCAL_ONLY).build();
  newSpanStack.push(parentSpan);
  newSpanStack.push(subspan);
  assertThat(MDC.get(Tracer.TRACE_ID_MDC_KEY)).isNull();
  assertThat(MDC.get(Tracer.SPAN_JSON_MDC_KEY)).isNull();
  // when
  tracer.registerWithThread(newSpanStack);
  // then
  // our stack was registered, so subspan should be current
  assertThat(MDC.get(Tracer.TRACE_ID_MDC_KEY)).isEqualTo(subspan.getTraceId());
  assertThat(MDC.get(Tracer.SPAN_JSON_MDC_KEY)).isEqualTo(subspan.toJSON());
  assertThat(tracer.getCurrentSpan()).isEqualTo(subspan);
  // a *copy* of the stack we passed in should have been registered, and modifying the original stack should not affect Tracer's stack
  Deque<Span> spanStack = getSpanStackThreadLocal().get();
  assertThat(Tracer.getInstance().containsSameSpansInSameOrder(spanStack, newSpanStack)).isTrue();
  assertThat(spanStack).isNotSameAs(newSpanStack);
  newSpanStack.push(subspan.generateChildSpan("subsub", SpanPurpose.LOCAL_ONLY));
  assertThat(newSpanStack).hasSize(3);
  assertThat(spanStack).hasSize(2);
}

代码示例来源:origin: Nike-Inc/wingtips

Span childSpan = parentSpan.generateChildSpan(childSpanName, childSpanPurpose);
long afterCallNanos = System.nanoTime();
long afterCallEpochMicros = TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis());

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void registerWithThread_should_work_as_advertised_if_existing_stack_is_empty() {
  // given
  getSpanStackThreadLocal().set(new LinkedList<Span>());
  Tracer tracer = Tracer.getInstance();
  Deque<Span> newSpanStack = new LinkedList<>();
  Span parentSpan = Span.newBuilder("foo", SpanPurpose.LOCAL_ONLY).build();
  Span subspan = Span.newBuilder("bar", SpanPurpose.LOCAL_ONLY).build();
  newSpanStack.push(parentSpan);
  newSpanStack.push(subspan);
  assertThat(MDC.get(Tracer.TRACE_ID_MDC_KEY)).isNull();
  assertThat(MDC.get(Tracer.SPAN_JSON_MDC_KEY)).isNull();
  // when
  tracer.registerWithThread(newSpanStack);
  // then
  // our stack was registered, so subspan should be current
  assertThat(MDC.get(Tracer.TRACE_ID_MDC_KEY)).isEqualTo(subspan.getTraceId());
  assertThat(MDC.get(Tracer.SPAN_JSON_MDC_KEY)).isEqualTo(subspan.toJSON());
  assertThat(tracer.getCurrentSpan()).isEqualTo(subspan);
  // a *copy* of the stack we passed in should have been registered, and modifying the original stack should not affect Tracer's stack
  Deque<Span> spanStack = getSpanStackThreadLocal().get();
  assertThat(Tracer.getInstance().containsSameSpansInSameOrder(spanStack, newSpanStack)).isTrue();
  assertThat(spanStack).isNotSameAs(newSpanStack);
  newSpanStack.push(subspan.generateChildSpan("subsub", SpanPurpose.LOCAL_ONLY));
  assertThat(newSpanStack).hasSize(3);
  assertThat(spanStack).hasSize(2);
}

代码示例来源:origin: Nike-Inc/wingtips

Span childSpan = parentSpan.generateChildSpan(childSpanName, childSpanPurpose);
long afterCallNanos = System.nanoTime();
long afterCallEpochMicros = TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis());

相关文章