@Override public void close() { if (Thread.currentThread().getId() != threadId) { throw new IllegalStateException( "scope closed in a different thread: " + Thread.currentThread().getName(), caller); } delegate.close(); }
@Override public void process(HttpRequest request, HttpContext context) { Scope scope = (Scope) context.getAttribute(Scope.class.getName()); if (scope == null) return; context.removeAttribute(Scope.class.getName()); scope.close(); } }
void noticesDifferentContext(Scope scope) { try (Scope scope2 = currentTraceContext.maybeScope(context2)) { assertThat(scope2).isNotEqualTo(Scope.NOOP); assertThat(currentTraceContext.get()) .isEqualTo(context2); verifyImplicitContext(context2); } finally { scope.close(); } }
@Override public void onComplete() { if (done) return; done = true; Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onComplete(); } finally { scope.close(); } }
@Override public void connect(Consumer<? super Disposable> connection) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally source.connect(connection); } finally { scope.close(); } } }
@Override public void onSuccess(T value) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onSuccess(value); } finally { scope.close(); } }
@Override public void connect(Consumer<? super Disposable> connection) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally source.connect(connection); } finally { scope.close(); } } }
@Override public void onError(Throwable t) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onError(t); } finally { scope.close(); } }
void noticesDifferentSpanId(Scope scope) { TraceContext differentSpanId = context.toBuilder().spanId(context.spanId() + 1L).build(); try (Scope scope2 = currentTraceContext.maybeScope(differentSpanId)) { assertThat(scope2).isNotEqualTo(Scope.NOOP); assertThat(currentTraceContext.get()) .isEqualTo(differentSpanId); verifyImplicitContext(differentSpanId); } finally { scope.close(); } }
@Override public void onError(Throwable t) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onError(t); } finally { scope.close(); } }
@Override public void onComplete() { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onComplete(); } finally { scope.close(); } }
/** Clears the scope to prevent remote reporters from accidentally tracing */ void finishInNullScope(Span span) { Scope ws = currentTraceContext.maybeScope(null); try { span.finish(); } finally { ws.close(); } } }
@Override public void onNext(T t) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onNext(t); } finally { scope.close(); } }
@Override public void onError(Throwable t) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onError(t); } finally { scope.close(); } }
@Override public void onNext(T t) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onNext(t); } finally { scope.close(); } }
@Override public void onComplete() { if (done) return; done = true; Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onComplete(); } finally { scope.close(); } } }
@Override public void onSuccess(T value) { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onSuccess(value); } finally { scope.close(); } }
Span handleStart(Req request, Span span) { if (span.isNoop()) return span; Scope ws = currentTraceContext.maybeScope(span.context()); try { parseRequest(request, span); } finally { ws.close(); } // all of the above parsing happened before a timestamp on the span return span.start(); }
@Override public void onComplete() { Scope scope = contextScoper.maybeScope(assembled); try { // retrolambda can't resolve this try/finally downstream.onComplete(); } finally { scope.close(); } }
@Override public void finish() { scope.close(); if (!pendingSpans.remove(context)) return; // don't double-report state.finishTimestamp(clock.currentTimeMicroseconds()); finishedSpanHandler.handle(context, state); }