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

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

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

Tracer.containsSameSpansInSameOrder介绍

暂无

代码示例

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

if (!containsSameSpansInSameOrder(currentSpanStack, registerMe)) {

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

@Test
@UseDataProvider("dataProviderForContainsSameSpansInSameOrder")
public void containsSameSpansInSameOrder_should_work_as_expected_for_known_data(Deque<Span> stack, Deque<Span> otherStack, boolean expected, String testId) {
  assertThat(Tracer.getInstance().containsSameSpansInSameOrder(stack, otherStack)).isEqualTo(expected).withFailMessage("Test failed: " + testId);
}

代码示例来源: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

@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);
}

相关文章