JaegerSpan implements Span { @Override public JaegerSpanContext context() { synchronized (this) { return context; } } protected  JaegerSpan(
      JaegerTracer tracer,
      String operationName,
      JaegerSpanContext context,
      long startTimeMicroseconds,
      long startTimeNanoTicks,
      boolean computeDurationViaNanoTicks,
      Map<String, Object> tags,
      List<Reference> references); long getStart(); boolean isFinished(); long getDuration(); JaegerTracer getTracer(); List<Reference> getReferences(); Map<String, Object> getTags(); @Override JaegerSpan setOperationName(String operationName); String getOperationName(); String getServiceName(); List<LogData> getLogs(); @Override JaegerSpan setBaggageItem(String key, String value); @Override String getBaggageItem(String key); @Override String toString(); @Override JaegerSpanContext context(); @Override void finish(); @Override void finish(long finishMicros); @Override synchronized JaegerSpan setTag(String key, String value); @Override synchronized JaegerSpan setTag(String key, boolean value); @Override synchronized JaegerSpan setTag(String key, Number value); @Override synchronized Span setTag(Tag<T> tag, T value); @Override JaegerSpan log(Map<String, ?> fields); @Override JaegerSpan log(long timestampMicroseconds, Map<String, ?> fields); @Override JaegerSpan log(String event); @Override JaegerSpan log(long timestampMicroseconds, String event);  }
@Test public void testTraceId64Bit() { tracer = new JaegerTracer.Builder("traceId64Bit").build(); jaegerSpan = tracer.buildSpan("foo").start(); assertEquals(0, jaegerSpan.context().getTraceIdHigh()); }
@Test public void testTraceId128Bit() { tracer = new JaegerTracer.Builder("traceId128Bit").withTraceId128Bit().build(); jaegerSpan = tracer.buildSpan("foo").start(); assertNotEquals(0, jaegerSpan.context().getTraceIdHigh()); }
@Test public void testToTraceId() { assertEquals(jaegerSpan.context().getTraceId(), jaegerSpan.context().toTraceId()); }
@Test public void testToSpanId() { assertEquals(Utils.to16HexString(jaegerSpan.context().getSpanId()), jaegerSpan.context().toSpanId()); }
@Test public void testSpanDetectsSamplingPriorityGreaterThanZero() { JaegerSpan jaegerSpan = tracer.buildSpan("test-service-operation").start(); Tags.SAMPLING_PRIORITY.set(jaegerSpan, 1); JaegerSpanContext context = jaegerSpan.context(); assertEquals(context.getFlags() & JaegerSpanContext.flagSampled, JaegerSpanContext.flagSampled); assertEquals(context.getFlags() & JaegerSpanContext.flagDebug, JaegerSpanContext.flagDebug); }
@Test public void testSpanDetectsSamplingPriorityLessThanZero() { JaegerSpan jaegerSpan = tracer.buildSpan("test-service-operation").start(); assertEquals( JaegerSpanContext.flagSampled, jaegerSpan.context().getFlags() & JaegerSpanContext.flagSampled ); Tags.SAMPLING_PRIORITY.set(jaegerSpan, -1); assertEquals( 0, jaegerSpan.context().getFlags() & JaegerSpanContext.flagSampled ); }