diff --git a/instrumentation/grpc/src/main/java/brave/grpc/TracingServerInterceptor.java b/instrumentation/grpc/src/main/java/brave/grpc/TracingServerInterceptor.java index 5f57b10167..d277da517e 100644 --- a/instrumentation/grpc/src/main/java/brave/grpc/TracingServerInterceptor.java +++ b/instrumentation/grpc/src/main/java/brave/grpc/TracingServerInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2020 The OpenZipkin Authors + * Copyright 2013-2022 The OpenZipkin Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -167,6 +167,10 @@ final class TracingServerCallListener extends SimpleForwardingServerCallL try (Scope scope = currentTraceContext.maybeScope(context)) { delegate().onCancel(); } + Span span = spanRef.getAndSet(null); + if (span != null) { + span.finish(); + } } @Override public void onComplete() {