Span implements Closeable, Serializable { public boolean isCompleted() { return durationNanos != null; } Span(String traceId, String parentSpanId, String spanId, String spanName, boolean sampleable, String userId,
                SpanPurpose spanPurpose, long spanStartTimeEpochMicros, Long spanStartTimeNanos, Long durationNanos,
                Map<String,String> tags, List<TimestampedAnnotation> annotations
    ); protected  Span(); static Builder generateRootSpanForNewTrace(String spanName, SpanPurpose spanPurpose); Span generateChildSpan(String spanName, SpanPurpose spanPurpose); static Builder newBuilder(String spanName, SpanPurpose spanPurpose); static Builder newBuilder(Span copy); String getTraceId(); String getSpanId(); String getParentSpanId(); String getSpanName(); boolean isSampleable(); String getUserId(); long getSpanStartTimeEpochMicros(); long getSpanStartTimeNanos(); SpanPurpose getSpanPurpose(); boolean isCompleted(); Long getDurationNanos(); TracerManagedSpanStatus getCurrentTracerManagedSpanStatus(); Map<String,String> getTags(); void putTag(String key, String value); void removeTag(String key); List<TimestampedAnnotation> getTimestampedAnnotations(); void addTimestampedAnnotationForCurrentTime(String value); void addTimestampedAnnotation(TimestampedAnnotation timestampedAnnotation); @Override String toString(); String toKeyValueString(); String toJSON(); @Override void close(); @Override boolean equals(Object o); @Override int hashCode(); @Deprecated static Span fromKeyValueString(String keyValueStr); @Deprecated static Span fromJSON(String json); @Deprecated
    static final String TRACE_ID_FIELD; @Deprecated
    static final String PARENT_SPAN_ID_FIELD; @Deprecated
    static final String SPAN_ID_FIELD; @Deprecated
    static final String SPAN_NAME_FIELD; @Deprecated
    static final String SAMPLEABLE_FIELD; @Deprecated
    static final String USER_ID_FIELD; @Deprecated
    static final String SPAN_PURPOSE_FIELD; @Deprecated
    static final String START_TIME_EPOCH_MICROS_FIELD; @Deprecated
    static final String DURATION_NANOS_FIELD; }
@DataProvider(value = { "true", "false" }) @Test public void span_is_autocloseable_using_try_with_resources_block_overall_request_span( boolean throwExceptionInTryBlock ) { Span span = null; Throwable caughtEx = null; try(Span autocloseableSpan = Tracer.getInstance().startRequestWithRootSpan("root")) { assertThat(Tracer.getInstance().getCurrentSpan()).isSameAs(autocloseableSpan); span = autocloseableSpan; if (throwExceptionInTryBlock) { throw new RuntimeException("kaboom"); } } catch(Throwable t) { caughtEx = t; } assertThat(span.isCompleted()).isTrue(); assertThat(Tracer.getInstance().getCurrentSpan()).isNull(); if (throwExceptionInTryBlock) { assertThat(caughtEx).isNotNull(); } else { assertThat(caughtEx).isNull(); } }
@DataProvider(value = { "true", "false" }) @Test public void span_is_autocloseable_using_try_with_resources_block_subspan( boolean throwExceptionInTryBlock ) { Span parentSpan = Tracer.getInstance().startRequestWithRootSpan("root"); Span subspan = null; Throwable caughtEx = null; try(Span autocloseableSubspan = Tracer.getInstance().startSubSpan("subspan", SpanPurpose.LOCAL_ONLY)) { assertThat(Tracer.getInstance().getCurrentSpan()).isSameAs(autocloseableSubspan); subspan = autocloseableSubspan; if (throwExceptionInTryBlock) { throw new RuntimeException("kaboom"); } } catch(Throwable t) { caughtEx = t; } assertThat(subspan.isCompleted()).isTrue(); assertThat(Tracer.getInstance().getCurrentSpan()).isSameAs(parentSpan); if (throwExceptionInTryBlock) { assertThat(caughtEx).isNotNull(); } else { assertThat(caughtEx).isNull(); } }