private TraceScope newScopeImpl(ThreadContext context, String description, SpanId parentId) { Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, null); }
@Override public Span child(String childDescription) { return new MilliSpan.Builder(). begin(System.currentTimeMillis()). end(0). description(childDescription). parents(new SpanId[] {spanId}). spanId(spanId.newChildId()). tracerId(tracerId). build(); }
@Override public Span child(String childDescription) { return new MilliSpan.Builder(). begin(System.currentTimeMillis()). end(0). description(childDescription). parents(new SpanId[] {spanId}). spanId(spanId.newChildId()). tracerId(tracerId). build(); }
@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); } }
@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 testJsonSerializationWithRandomLongValue() throws Exception { SpanId parentId = SpanId.fromRandom(); MilliSpan span = new MilliSpan.Builder(). description("foospan"). begin(ThreadLocalRandom.current().nextLong()). end(ThreadLocalRandom.current().nextLong()). parents(new SpanId[] { parentId }). tracerId("b2404.halxg.com:8080"). spanId(parentId.newChildId()). build(); String json = span.toJson(); MilliSpan dspan = MilliSpan.fromJson(json); compareSpans(span, dspan); }
@Test public void testJsonSerializationWithNegativeLongValue() throws Exception { MilliSpan span = new MilliSpan.Builder(). description("foospan"). begin(-1L). end(-1L). parents(new SpanId[] { new SpanId(-1L, -1L) }). tracerId("b2404.halxg.com:8080"). spanId(new SpanId(-1L, -2L)). build(); String json = span.toJson(); MilliSpan dspan = MilliSpan.fromJson(json); compareSpans(span, dspan); }
@Test public void testJsonSerialization() throws Exception { MilliSpan span = new MilliSpan.Builder(). description("foospan"). begin(123L). end(456L). parents(new SpanId[] { new SpanId(7L, 7L) }). tracerId("b2404.halxg.com:8080"). spanId(new SpanId(7L, 8L)). build(); String json = span.toJson(); MilliSpan dspan = MilliSpan.fromJson(json); compareSpans(span, dspan); }
private TraceScope newScopeImpl(ThreadContext context, String description, SpanId parentId) { Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, null); }
private TraceScope newScopeImpl(ThreadContext context, String description) { Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(EMPTY_PARENT_ARRAY). spanId(SpanId.fromRandom()). build(); return context.pushNewScope(this, span, null); }
private TraceScope newScopeImpl(ThreadContext context, String description, TraceScope parentScope) { SpanId parentId = parentScope.getSpan().getSpanId(); Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, parentScope); }
private TraceScope newScopeImpl(ThreadContext context, String description, TraceScope parentScope, SpanId secondParentId) { SpanId parentId = parentScope.getSpan().getSpanId(); Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId, secondParentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, parentScope); }
private TraceScope newScopeImpl(ThreadContext context, String description, TraceScope parentScope) { SpanId parentId = parentScope.getSpan().getSpanId(); Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, parentScope); }
private TraceScope newScopeImpl(ThreadContext context, String description, TraceScope parentScope, SpanId secondParentId) { SpanId parentId = parentScope.getSpan().getSpanId(); Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId, secondParentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, parentScope); }
private TraceScope newScopeImpl(ThreadContext context, String description, TraceScope parentScope) { SpanId parentId = parentScope.getSpan().getSpanId(); Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, parentScope); }
private TraceScope newScopeImpl(ThreadContext context, String description, SpanId parentId) { Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, null); }
private TraceScope newScopeImpl(ThreadContext context, String description) { Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(EMPTY_PARENT_ARRAY). spanId(SpanId.fromRandom()). build(); return context.pushNewScope(this, span, null); }
@Override public Span child(String childDescription) { return new MilliSpan.Builder(). begin(System.currentTimeMillis()). end(0). description(childDescription). parents(new SpanId[] {spanId}). spanId(spanId.newChildId()). tracerId(tracerId). build(); }
private TraceScope newScopeImpl(ThreadContext context, String description, TraceScope parentScope, SpanId secondParentId) { SpanId parentId = parentScope.getSpan().getSpanId(); Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(new SpanId[] { parentId, secondParentId }). spanId(parentId.newChildId()). build(); return context.pushNewScope(this, span, parentScope); }
private TraceScope newScopeImpl(ThreadContext context, String description) { Span span = new MilliSpan.Builder(). tracerId(tracerId). begin(System.currentTimeMillis()). description(description). parents(EMPTY_PARENT_ARRAY). spanId(SpanId.fromRandom()). build(); return context.pushNewScope(this, span, null); }