SpanContextHandlerTracer implements Tracer { @Override public void annotateSpan(TraceContext traceContext, Labels labels) { for (TraceSink sink : sinks) { sink.annotateSpan(traceContext.getHandle().getCurrentSpanContext(), labels); } } 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 testAnnotateSpan() { SpanContext current = new SpanContext(new TraceId(BigInteger.valueOf(1)), new SpanId(2), new TraceOptions()); TraceContext inProgressContext = new TraceContext(new DetachedSpanContextHandle(current)); Labels labels = Labels.builder().add("foo", "bar").build(); tracer.annotateSpan(inProgressContext, labels); assertThat(sink.annotateEvents).hasSize(1); TestTraceSink.AnnotateEvent annotateEvent = sink.annotateEvents.get(0); assertThat(annotateEvent.context).isEqualTo(current); assertThat(annotateEvent.labels).isEqualTo(labels); }