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

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

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

Tracer.getInstance介绍

暂无

代码示例

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

private void clearTracerSpanLifecycleListeners() {
  List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
  for (SpanLifecycleListener listener : listeners) {
    Tracer.getInstance().removeSpanLifecycleListener(listener);
  }
}

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

protected CloseableHttpResponse propagateHeadersAndExecute(
    HttpRoute route,
    HttpRequestWrapper request,
    HttpClientContext clientContext,
    HttpExecutionAware execAware
  ) throws IOException, HttpException {
    propagateTracingHeaders(request, Tracer.getInstance().getCurrentSpan());
    return protocolExec.execute(route, request, clientContext, execAware);
  }
};

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

private void clearTracerSpanLifecycleListeners() {
  List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
  for (SpanLifecycleListener listener : listeners) {
    Tracer.getInstance().removeSpanLifecycleListener(listener);
  }
}

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

private void clearTracerSpanLifecycleListeners() {
  List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
  for (SpanLifecycleListener listener : listeners) {
    Tracer.getInstance().removeSpanLifecycleListener(listener);
  }
}

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

private void removeSpanRecorderLifecycleListener() {
  List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
  for (SpanLifecycleListener listener : listeners) {
    if (listener instanceof SpanRecorder) {
      Tracer.getInstance().removeSpanLifecycleListener(listener);
    }
  }
}

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

private void clearTracerSpanLifecycleListeners() {
  List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
  for (SpanLifecycleListener listener : listeners) {
    Tracer.getInstance().removeSpanLifecycleListener(listener);
  }
}

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

private void removeSpanRecorderLifecycleListener() {
  List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
  for (SpanLifecycleListener listener : listeners) {
    if (listener instanceof SpanRecorder) {
      Tracer.getInstance().removeSpanLifecycleListener(listener);
    }
  }
}

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

private void clearTracerSpanLifecycleListeners() {
  List<SpanLifecycleListener> listeners = new ArrayList<>(Tracer.getInstance().getSpanLifecycleListeners());
  for (SpanLifecycleListener listener : listeners) {
    Tracer.getInstance().removeSpanLifecycleListener(listener);
  }
}

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

@Override
  public Object answer(InvocationOnMock invocation) throws Throwable {
    currentSpanStackWhenCallableWasCalled.add(Tracer.getInstance().getCurrentSpanStackCopy());
    currentMdcInfoWhenCallableWasCalled.add(MDC.getCopyOfContextMap());
    if (throwExceptionDuringCall)
      throw new RuntimeException("kaboom");
    return null;
  }
}).when(callableMock).call();

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

private Span findCompletedSpanByCriteria(Predicate<Span> criteria) {
  Tracer.getInstance().setSpanLoggingRepresentation(Tracer.SpanLoggingRepresentation.KEY_VALUE);
  List<Span> matchingSpans = spanRecorder.completedSpans.stream().filter(criteria).collect(Collectors.toList());
  assertThat(matchingSpans)
    .withFailMessage(
      "Expected to find exactly 1 span matching the specified criteria - instead found: "
      + matchingSpans.size()
    )
    .hasSize(1);
  return matchingSpans.get(0);
}

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

@Test(expected = IllegalArgumentException.class)
public void setRootSpanSamplingStrategy_should_explode_if_passed_null() {
  // expect
  Tracer.getInstance().setRootSpanSamplingStrategy(null);
}

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

private Pair<Deque<Span>, Map<String, String>> setupCurrentThreadWithTracingInfo() {
  resetTracing();
  Tracer.getInstance().startRequestWithRootSpan("request-" + UUID.randomUUID().toString());
  return Pair.of(Tracer.getInstance().getCurrentSpanStackCopy(), MDC.getCopyOfContextMap());
}

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

@Test
public void close_completes_the_span_as_expected_overall_request_span() {
  // given
  Span overallSpan = Tracer.getInstance().startRequestWithRootSpan("root");
  assertThat(Tracer.getInstance().getCurrentSpan()).isSameAs(overallSpan);
  assertThat(overallSpan.isCompleted()).isFalse();
  // when
  overallSpan.close();
  // then
  assertThat(overallSpan.isCompleted()).isTrue();
  assertThat(Tracer.getInstance().getCurrentSpan()).isNull();
}

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

private Pair<Deque<Span>, Map<String, String>> generateTracingInfo() {
  resetTracing();
  Tracer.getInstance().startRequestWithRootSpan("someSpan");
  Pair<Deque<Span>, Map<String, String>> result = Pair.of(
    Tracer.getInstance().getCurrentSpanStackCopy(), new HashMap<>(MDC.getCopyOfContextMap())
  );
  resetTracing();
  return result;
}

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

@Test(expected = IllegalArgumentException.class)
public void startRequestWithChildSpan_throws_IllegalArgumentException_if_passed_null_parent() {
  // expect
  Tracer.getInstance().startRequestWithChildSpan(null, "somechildspan");
  fail("Expected IllegalArgumentException but no exception was thrown");
}

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

private void resetTracing() {
  MDC.clear();
  Tracer.getInstance().unregisterFromThread();
  removeSpanRecorderLifecycleListener();
}

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

@Before
public void beforeMethod() {
  removeSpanRecorderLifecycleListener();
  spanRecorder = new SpanRecorder();
  Tracer.getInstance().addSpanLifecycleListener(spanRecorder);
}

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

@Before
public void beforeMethod() {
  clearTracerSpanLifecycleListeners();
  spanRecorder = new SpanRecorder();
  Tracer.getInstance().addSpanLifecycleListener(spanRecorder);
}

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

@Before
public void beforeMethod() {
  clearTracerSpanLifecycleListeners();
  spanRecorder = new SpanRecorder();
  Tracer.getInstance().addSpanLifecycleListener(spanRecorder);
}

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

@Before
public void beforeMethod() {
  resetTracing();
  spanRecorder = new SpanRecorder();
  Tracer.getInstance().addSpanLifecycleListener(spanRecorder);
}

相关文章