void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
void closeScope(TraceScope scope) { TraceScope curScope = threadLocalScope.get(); if (curScope != scope) { throwClientError("Can't close TraceScope for " + scope.getSpan().toJson() + " because it is not the current " + "TraceScope in thread " + Thread.currentThread().getName()); } if (tracerPool == null) { throwClientError(toString() + " is closed."); } SpanReceiver[] receivers = tracerPool.getReceivers(); if (receivers == null) { throwClientError(toString() + " is closed."); } ThreadContext context = threadContext.get(); context.popScope(); threadLocalScope.set(scope.getParent()); scope.setParent(null); Span span = scope.getSpan(); span.stop(); for (SpanReceiver receiver : receivers) { receiver.receiveSpan(span); } }
@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); } }
long annoEndTime = System.currentTimeMillis() * 1000; Thread.sleep(500); ms.stop(); long endTime = System.currentTimeMillis() * 1000;