AppEngineTracer implements Tracer { @Override public void annotateSpan(TraceContext traceContext, Labels labels) { checkNotNull(traceContext); checkNotNull(labels); Span span = getSpan(traceContext); for (Label label : labels.getLabels()) { span.setLabel(label.getKey(), label.getValue()); } } AppEngineTracer(com.google.appengine.api.labs.trace.TraceService traceService); @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 annotateSpan() { when(mockTraceService.startSpan("test span")).thenReturn(mockSpan); TraceContext traceContext = tracer.startSpan("test span"); tracer.annotateSpan( traceContext, Labels.builder().add("key1", "value1").add("key2", "value2").build()); verify(mockSpan).setLabel("key1", "value1"); verify(mockSpan).setLabel("key2", "value2"); verifyNoMoreInteractions(mockSpan); }