SpanContextHandlerTracer implements Tracer { @Override public void setStackTrace(TraceContext traceContext, StackTrace stackTrace) { for (TraceSink sink : sinks) { sink.setStackTrace(traceContext.getHandle().getCurrentSpanContext(), stackTrace); } } SpanContextHandlerTracer(Set<TraceSink> sinks, SpanContextHandler contextHandler, SpanContextFactory spanContextFactory, TimestampFactory timestampFactory);  SpanContextHandlerTracer(TraceSink sink, SpanContextHandler contextHandler, SpanContextFactory spanContextFactory, TimestampFactory timestampFactory); @Override TraceContext startSpan(String name); @Override TraceContext startSpan(String name, StartSpanOptions options); @Override void endSpan(TraceContext traceContext); @Override void endSpan(TraceContext traceContext, EndSpanOptions options); @Override void annotateSpan(TraceContext traceContext, Labels labels); @Override void setStackTrace(TraceContext traceContext, StackTrace stackTrace);  }
@Test public void testSetStackTrace() { SpanContext current = new SpanContext(new TraceId(BigInteger.valueOf(1)), new SpanId(2), new TraceOptions()); TraceContext inProgressContext = new TraceContext(new DetachedSpanContextHandle(current)); StackTrace stackTrace = StackTrace.builder() .add("testClass", "testMethod", "testFile", 1, 2).build(); tracer.setStackTrace(inProgressContext, stackTrace); assertThat(sink.stackTraceEvents).hasSize(1); TestTraceSink.StackTraceEvent annotateEvent = sink.stackTraceEvents.get(0); assertThat(annotateEvent.context).isEqualTo(current); assertThat(annotateEvent.stackTrace).isEqualTo(stackTrace); }