@Test(expected = EmptyStackException.class) public void testEndingASpanMoreThanOnce() { final SpanSink sink = mock(SpanSink.class); SpanSinkRegistry.register(sink); Span trace = SpanHelper.startTrace("The Trace"); trace.end(); assertTrue(SpanHelper.captureSpans().isEmpty()); verify(sink).record(trace); trace.end(); }
public final void end() { duration = System.nanoTime() - duration; Optional<SpanContext> context = SpanHelper.currentContext(); if (context.isPresent()) { context.get().endSpan(this); afterClose(); } else { throw new IllegalStateException("Span.end() from a detached span."); } }
Span implements AutoCloseable, SpanData { public final void end() { duration = System.nanoTime() - duration; Optional<SpanContext> context = SpanHelper.currentContext(); if (context.isPresent()) { context.get().endSpan(this); afterClose(); } else { throw new IllegalStateException("Span.end() from a detached span."); } } }
Span implements AutoCloseable, SpanData { public final void end() { duration = System.nanoTime() - duration; Optional<SpanContext> context = SpanHelper.currentContext(); if (context.isPresent()) { context.get().endSpan(this); afterClose(); } else { throw new IllegalStateException("Span.end() from a detached span."); } } protected  Span(Optional<BigInteger> parentSpanId, BigInteger spanId, String name, BigInteger traceId, long startTime, long startNanos, TraceLevel traceLevel); }
Span implements AutoCloseable, SpanData { public final void end() { duration = System.nanoTime() - duration; Optional<SpanContext> context = SpanHelper.currentContext(); if (context.isPresent()) { context.get().endSpan(this); afterClose(); } else { throw new IllegalStateException("Span.end() from a detached span."); } } protected  Span(Optional<BigInteger> parentSpanId, BigInteger spanId, String name, BigInteger traceId, long startTime, long startNanos, TraceLevel traceLevel); abstract void addAnnotation(String name); abstract void addAnnotation(String name, String message); final void end(); @Override final void close(); final BigInteger getTraceId(); final BigInteger getSpanId(); final Optional<BigInteger> getParentSpanId(); final String getName(); final String getHost(); @SuppressWarnings("UnusedDeclaration") final Integer getPid(); @Override final long getStartTime(); @Override final long getDuration(); @Override final List<AnnotationData> getAnnotations(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); }
Span implements AutoCloseable, SpanData { public final void end() { duration = System.nanoTime() - duration; Optional<SpanContext> context = SpanHelper.currentContext(); if (context.isPresent()) { context.get().endSpan(this); afterClose(); } else { throw new IllegalStateException("Span.end() from a detached span."); } } protected  Span(Optional<BigInteger> parentSpanId, BigInteger spanId, String name, BigInteger traceId, long startTime, long startNanos, TraceLevel traceLevel); abstract void addAnnotation(String name); abstract void addAnnotation(String name, String message); final void end(); @Override final void close(); final BigInteger getTraceId(); final BigInteger getSpanId(); final Optional<BigInteger> getParentSpanId(); final String getName(); final String getHost(); @SuppressWarnings("UnusedDeclaration") final Integer getPid(); @Override final long getStartTime(); @Override final long getDuration(); @Override final List<AnnotationData> getAnnotations(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }