/** * Wrapper method to add key-value pair to TraceInfo of actual span */ public static void addKVAnnotation(String key, String value){ Span span = Tracer.getCurrentSpan(); if (span != null) { span.addKVAnnotation(key, value); } }
args = args.substring(0, 2048); scope.getSpan().addKVAnnotation("args", args);
Span span = Tracer.getCurrentSpan(); if (span != null) { span.addKVAnnotation("maxWriteToDiskMs", Long.toString(maxWriteToDiskMs));
public void addKVAnnotation(String key, String value) { span.addKVAnnotation(key, value); }
public void addKVAnnotation(String key, String value) { span.addKVAnnotation(key, value); }
public void addKVAnnotation(String key, String value) { span.addKVAnnotation(key, value); }
/** * Wrapper method to add key-value pair to TraceInfo of actual span */ public static void addKVAnnotation(String key, String value){ Span span = Tracer.getCurrentSpan(); if (span != null) { span.addKVAnnotation(key, value); } }
/** * Wrapper method to add key-value pair to TraceInfo of actual span */ public static void addKVAnnotation(String key, String value){ Span span = Tracer.getCurrentSpan(); if (span != null) { span.addKVAnnotation(key, value); } }
args = args.substring(0, 2048); scope.getSpan().addKVAnnotation("args", args);
@Test(timeout=120000) public void testSimpleTraces() throws IOException, InterruptedException { Tracer tracer = newTracer(); Span rootSpan = new MilliSpan.Builder(). description("root"). spanId(new SpanId(100, 100)). tracerId("test"). begin(System.currentTimeMillis()). build(); TraceScope rootScope = tracer.newScope("root"); TraceScope innerOne = tracer.newScope("innerOne"); TraceScope innerTwo = tracer.newScope("innerTwo"); innerTwo.close(); Assert.assertTrue(flumeServer.nextEventBodyAsString().contains("innerTwo")); innerOne.close(); Assert.assertTrue(flumeServer.nextEventBodyAsString().contains("innerOne")); rootSpan.addKVAnnotation("foo", "bar"); rootSpan.addTimelineAnnotation("timeline"); rootScope.close(); Assert.assertTrue(flumeServer.nextEventBodyAsString().contains("root")); tracer.close(); }
@Test public void testSimpleTraces() throws IOException, InterruptedException { FakeZipkinTransport transport = new FakeZipkinTransport(); Tracer tracer = newTracer(transport); Span rootSpan = new MilliSpan.Builder(). description("root"). spanId(new SpanId(100, 100)). tracerId("test"). begin(System.currentTimeMillis()). build(); TraceScope rootScope = tracer.newScope("root"); TraceScope innerOne = tracer.newScope("innerOne"); TraceScope innerTwo = tracer.newScope("innerTwo"); innerTwo.close(); Assert.assertTrue(transport.nextMessageAsSpan().getName().contains("innerTwo")); innerOne.close(); Assert.assertTrue(transport.nextMessageAsSpan().getName().contains("innerOne")); rootSpan.addKVAnnotation("foo", "bar"); rootSpan.addTimelineAnnotation("timeline"); rootScope.close(); Assert.assertTrue(transport.nextMessageAsSpan().getName().contains("root")); tracer.close(); }
@Test public void testHTraceToZipkin() throws IOException { Span rootSpan = new MilliSpan.Builder(). description(ROOT_SPAN_DESC). parents(new SpanId[] { } ). spanId(new SpanId(100, 100)). tracerId("test"). begin(System.currentTimeMillis()). build(); Span innerOne = rootSpan.child("Some good work"); Span innerTwo = innerOne.child("Some more good work"); innerTwo.stop(); innerOne.stop(); rootSpan.addKVAnnotation("foo", "bar"); rootSpan.addTimelineAnnotation("timeline"); rootSpan.stop(); for (Span s : new Span[] {rootSpan, innerOne, innerTwo}) { com.twitter.zipkin.gen.Span zs = new HTraceToZipkinConverter(12345, (short) 12).convert(s); assertSpansAreEquivalent(s, zs); } }