* @throws Exception on failure
*/
@Test
public void testWriteSpans() throws Exception {
// get a receiver for the spans
SpanReceiver receiver = TracingCompat.newTraceMetricSource();
// which also needs to a source for the metrics system
Metrics.getManager().registerSource("testWriteSpans-source", "source for testWriteSpans",
receiver);
// watch our sink so we know when commits happen
CountDownLatch latch = new CountDownLatch(1);
waitForCommit(latch);
// write some spans
TraceScope trace = Trace.startSpan("Start write test", Sampler.ALWAYS);
Span span = trace.getSpan();
// add a child with some annotations
Span child = span.child("child 1");
child.addTimelineAnnotation("timeline annotation");
TracingCompat.addAnnotation(child, "test annotation", 10);
child.stop();
// sleep a little bit to get some time difference
Thread.sleep(100);
trace.close();
// pass the trace on
receiver.receiveSpan(span);
// wait for the tracer to actually do the write
latch.await();
// look for the writes to make sure they were made