Beispiel #1
0
 /**
  * Sets the current Trace/Span state. Using this method indicates we are part of an existing
  * trace/span.
  *
  * @param traceId Trace id.
  * @param spanId Span id.
  * @param parentSpanId Parent span id. Can be <code>null</code>.
  * @param name Name should not be empty or <code>null</code>.
  * @see ServerTracer#setStateNoTracing()
  * @see ServerTracer#setStateUnknown(String)
  */
 public void setStateCurrentTrace(
     long traceId, long spanId, @Nullable Long parentSpanId, @Nullable String name) {
   checkNotBlank(name, "Null or blank span name");
   spanAndEndpoint()
       .state()
       .setCurrentServerSpan(ServerSpan.create(traceId, spanId, parentSpanId, name));
 }
 @Test
 public void testGetAndSetCurrentServerSpan() {
   assertEquals(ServerSpan.create(null), serverAndClientSpanState.getCurrentServerSpan());
   serverAndClientSpanState.setCurrentServerSpan(mockServerSpan);
   assertSame(mockServerSpan, serverAndClientSpanState.getCurrentServerSpan());
   assertNull("Should not have been modified.", serverAndClientSpanState.getCurrentClientSpan());
 }
Beispiel #3
0
 /**
  * Sets the current Trace/Span state. Using this method indicates that we got no information about
  * being part of an existing trace or about the fact that we should not trace the current request.
  * In this case the ServerTracer will decide what to do.
  *
  * @param spanName The name of our current request/span.
  */
 public void setStateUnknown(String spanName) {
   checkNotBlank(spanName, "Null or blank span name");
   for (TraceFilter traceFilter : traceFilters()) {
     if (traceFilter.trace(spanName) == false) {
       spanAndEndpoint().state().setCurrentServerSpan(ServerSpan.NOT_SAMPLED);
       return;
     }
   }
   long newSpanId = randomGenerator().nextLong();
   spanAndEndpoint()
       .state()
       .setCurrentServerSpan(ServerSpan.create(newSpanId, newSpanId, null, spanName));
 }