Tabnine Logo
Tracer.startRequestWithRootSpan
Code IndexAdd Tabnine to your IDE (free)

How to use
startRequestWithRootSpan
method
in
com.nike.wingtips.Tracer

Best Java code snippets using com.nike.wingtips.Tracer.startRequestWithRootSpan (Showing top 20 results out of 315)

origin: Nike-Inc/wingtips

@Test
public void getCurrentSpan_should_return_current_span() throws Exception {
  // given
  Tracer tracer = Tracer.getInstance();
  tracer.startRequestWithRootSpan("test-span");
  // when
  Span span = tracer.getCurrentSpan();
  // then
  assertThat(span).isNotNull();
  assertThat(span.getSpanName()).isEqualTo("test-span");
}
origin: Nike-Inc/wingtips

private TracingState generateTracingStateOnCurrentThread() {
  Tracer.getInstance().startRequestWithRootSpan(UUID.randomUUID().toString());
  Tracer.getInstance().startSubSpan(UUID.randomUUID().toString(), Span.SpanPurpose.LOCAL_ONLY);
  return TracingState.getCurrentThreadTracingState();
}
origin: Nike-Inc/wingtips

private TracingState generateTracingStateOnCurrentThread() {
  Tracer.getInstance().startRequestWithRootSpan(UUID.randomUUID().toString());
  Tracer.getInstance().startSubSpan(UUID.randomUUID().toString(), SpanPurpose.LOCAL_ONLY);
  return TracingState.getCurrentThreadTracingState();
}
origin: Nike-Inc/wingtips

@Test(expected = IllegalArgumentException.class)
public void starting_a_request_with_null_span_name_should_throw_IllegalArgumentException() {
  // expect
  Tracer.getInstance().startRequestWithRootSpan(null);
  fail("Expected IllegalArgumentException but no exception was thrown");
}
origin: Nike-Inc/wingtips

@Test
public void getCurrentTracerManagedSpanStatus_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(nonCurrentRootSpan.getCurrentTracerManagedSpanStatus())
    .isEqualTo(TracerManagedSpanStatus.MANAGED_NON_CURRENT_ROOT_SPAN);
  assertThat(nonCurrentSubspan.getCurrentTracerManagedSpanStatus())
    .isEqualTo(TracerManagedSpanStatus.MANAGED_NON_CURRENT_SUB_SPAN);
}
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 getCurrentTracerManagedSpanStatus_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 = manuallyCreatedSpan.getCurrentTracerManagedSpanStatus();
  TracerManagedSpanStatus tmssCompleted = completedSpan.getCurrentTracerManagedSpanStatus();
  // then
  assertThat(tmssManual).isEqualTo(TracerManagedSpanStatus.UNMANAGED_SPAN);
  assertThat(tmssCompleted).isEqualTo(TracerManagedSpanStatus.UNMANAGED_SPAN);
}
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>> setupCurrentThreadWithTracingInfo() {
  resetTracing();
  Tracer.getInstance().startRequestWithRootSpan("request-" + UUID.randomUUID().toString());
  return Pair.of(Tracer.getInstance().getCurrentSpanStackCopy(), MDC.getCopyOfContextMap());
}
origin: Nike-Inc/riposte

public static ChannelHandlerContextMocks mockChannelHandlerContextWithTraceInfo(String userId) {
  if (Tracer.getInstance().getCurrentSpan() == null) {
    Tracer.getInstance().startRequestWithRootSpan("mockChannelHandlerContext", userId);
  }
  ChannelHandlerContextMocks channelHandlerMocks = mockChannelHandlerContext();
  when(channelHandlerMocks.mockHttpProcessingState.getLoggerMdcContextMap()).thenReturn(MDC.getCopyOfContextMap());
  when(channelHandlerMocks.mockHttpProcessingState.getDistributedTraceStack()).thenReturn(Tracer.getInstance().getCurrentSpanStackCopy());
  return channelHandlerMocks;
}
origin: Nike-Inc/wingtips

@Test
public void handleSpanCloseMethod_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
  Tracer.getInstance().handleSpanCloseMethod(overallSpan);
  // then
  assertThat(overallSpan.isCompleted()).isTrue();
  assertThat(Tracer.getInstance().getCurrentSpan()).isNull();
}
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 close_completes_the_span_as_expected_subspan() {
  // given
  Span parentSpan = Tracer.getInstance().startRequestWithRootSpan("root");
  Span subspan = Tracer.getInstance().startSubSpan("subspan", SpanPurpose.LOCAL_ONLY);
  assertThat(Tracer.getInstance().getCurrentSpan()).isSameAs(subspan);
  assertThat(subspan.isCompleted()).isFalse();
  // when
  subspan.close();
  // then
  assertThat(subspan.isCompleted()).isTrue();
  assertThat(Tracer.getInstance().getCurrentSpan()).isSameAs(parentSpan);
}
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

@Test
public void handleSpanCloseMethod_completes_the_span_as_expected_subspan() {
  // given
  Span parentSpan = Tracer.getInstance().startRequestWithRootSpan("root");
  Span subspan = Tracer.getInstance().startSubSpan("subspan", SpanPurpose.LOCAL_ONLY);
  assertThat(Tracer.getInstance().getCurrentSpan()).isSameAs(subspan);
  assertThat(subspan.isCompleted()).isFalse();
  // when
  Tracer.getInstance().handleSpanCloseMethod(subspan);
  // then
  assertThat(subspan.isCompleted()).isTrue();
  assertThat(Tracer.getInstance().getCurrentSpan()).isSameAs(parentSpan);
}
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

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/riposte

private Pair<Deque<Span>, Map<String, String>> generateTracingAndMdcInfo() {
  resetTracingAndMdc();
  Tracer.getInstance().startRequestWithRootSpan("someSpan");
  Pair<Deque<Span>, Map<String, String>> result = Pair.of(
    Tracer.getInstance().getCurrentSpanStackCopy(), new HashMap<>(MDC.getCopyOfContextMap())
  );
  resetTracingAndMdc();
  return result;
}
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(),
    (Map<String, String>)new HashMap<>(MDC.getCopyOfContextMap())
  );
  resetTracing();
  return result;
}
com.nike.wingtipsTracerstartRequestWithRootSpan

Javadoc

Starts new span stack (i.e. new incoming request) without a parent span by creating a root span with the given span name. If you have parent span info then you should call #startRequestWithChildSpan(Span,String) or #startRequestWithSpanInfo(String,String,String,boolean,String,SpanPurpose) instead). The newly created root span will have a span purpose of SpanPurpose#SERVER.

NOTE: This method will cause the returned span's Span#getUserId() to contain null. If you have a user ID you should use #startRequestWithRootSpan(String,String) instead.

WARNING: This wipes out any existing spans on the span stack for this thread and starts fresh, therefore this should only be called at the request's entry point when it's expected that the span stack should be empty. If you need to start a child span in the middle of a request somewhere then you should call #startSubSpan(String,SpanPurpose) instead.

Popular methods of Tracer

  • getInstance
  • getCurrentSpan
  • addSpanLifecycleListener
    Adds the given listener to the #spanLifecycleListeners list using java.util.List#add(Object). This m
  • getSpanLifecycleListeners
  • removeSpanLifecycleListener
    Returns the value of calling java.util.List#remove(Object) on #spanLifecycleListeners.
  • getCurrentSpanStackCopy
  • unregisterFromThread
  • completeRequestSpan
  • startSpanInCurrentContext
  • registerWithThread
  • startSubSpan
  • completeSubSpan
  • startSubSpan,
  • completeSubSpan,
  • startRequestWithChildSpan,
  • setSpanLoggingRepresentation,
  • configureMDC,
  • containsSameSpansInSameOrder,
  • getCurrentManagedStatusForSpan,
  • getCurrentSpanStackSize,
  • getCurrentTracingStateCopy

Popular in Java

  • Making http requests using okhttp
  • onCreateOptionsMenu (Activity)
  • setScale (BigDecimal)
  • compareTo (BigDecimal)
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Reference (javax.naming)
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JTable (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now