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

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

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

Tracer.getCurrentManagedStatusForSpan介绍

暂无

代码示例

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

/**
 * @return this span's *current* status relative to {@link Tracer} on the current thread at the time this method is
 * called. This status is recalculated every time this method is called and is only relevant/correct until {@link
 * Tracer}'s state is modified (i.e. by starting a subspan, completing a span, using any of the asynchronous helper
 * methods to modify the span stack in any way, etc), so it should only be considered relevant for the moment the
 * call is made.
 *
 * <p>NOTE: Most app-level developers should not need to worry about this at all.
 */
public TracerManagedSpanStatus getCurrentTracerManagedSpanStatus() {
  return Tracer.getInstance().getCurrentManagedStatusForSpan(this);
}

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

@Test
public void getCurrentManagedStatusForSpan_works_as_expected_for_managed_noncurrent() {
  // given
  Span nonCurrentRootSpan = Tracer.getInstance().startRequestWithRootSpan("root");
  Span nonCurrentSubspan = Tracer.getInstance().startSubSpan("subspan1", SpanPurpose.LOCAL_ONLY);
  Span currentSubspan = Tracer.getInstance().startSubSpan("subspan2", SpanPurpose.LOCAL_ONLY);
  // expect
  assertThat(Tracer.getInstance().getCurrentManagedStatusForSpan(nonCurrentRootSpan))
    .isEqualTo(TracerManagedSpanStatus.MANAGED_NON_CURRENT_ROOT_SPAN);
  assertThat(Tracer.getInstance().getCurrentManagedStatusForSpan(nonCurrentSubspan))
    .isEqualTo(TracerManagedSpanStatus.MANAGED_NON_CURRENT_SUB_SPAN);
}

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

@Test
public void getCurrentManagedStatusForSpan_works_as_expected_for_managed_current() {
  {
    // given
    Span currentRootSpan = Tracer.getInstance().startRequestWithRootSpan("root");
    // when
    TracerManagedSpanStatus tmss = Tracer.getInstance().getCurrentManagedStatusForSpan(currentRootSpan);
    // then
    assertThat(tmss).isEqualTo(TracerManagedSpanStatus.MANAGED_CURRENT_ROOT_SPAN);
  }
  {
    // and given
    Span currentSubspan = Tracer.getInstance().startSubSpan("subspan", SpanPurpose.LOCAL_ONLY);
    // when
    TracerManagedSpanStatus tmss = Tracer.getInstance().getCurrentManagedStatusForSpan(currentSubspan);
    // then
    assertThat(tmss).isEqualTo(TracerManagedSpanStatus.MANAGED_CURRENT_SUB_SPAN);
  }
}

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

@Test
public void getCurrentManagedStatusForSpan_works_as_expected_for_unmanaged() {
  // given
  Span manuallyCreatedSpan = Span.newBuilder("manuallyCreatedSpan", SpanPurpose.LOCAL_ONLY).build();
  Span completedSpan = Tracer.getInstance().startRequestWithRootSpan("completedSpan");
  Tracer.getInstance().completeRequestSpan();
  // when
  TracerManagedSpanStatus tmssManual = Tracer.getInstance().getCurrentManagedStatusForSpan(manuallyCreatedSpan);
  TracerManagedSpanStatus tmssCompleted = Tracer.getInstance().getCurrentManagedStatusForSpan(completedSpan);
  // then
  assertThat(tmssManual).isEqualTo(TracerManagedSpanStatus.UNMANAGED_SPAN);
  assertThat(tmssCompleted).isEqualTo(TracerManagedSpanStatus.UNMANAGED_SPAN);
}

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

TracerManagedSpanStatus currentManagedState = getCurrentManagedStatusForSpan(span);
switch(currentManagedState) {
  case MANAGED_CURRENT_ROOT_SPAN:

相关文章