diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java index c2ee83b329b3..9244eb879822 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java @@ -52,7 +52,7 @@ public ClientCall interceptCall( // call other interceptors result = next.newCall(method, callOptions); } catch (Throwable e) { - instrumenter.end(context, request, null, e); + instrumenter.end(context, request, Status.UNKNOWN, e); throw e; } } @@ -100,7 +100,7 @@ public void start(Listener responseListener, Metadata headers) { new TracingClientCallListener(responseListener, parentContext, context, request), headers); } catch (Throwable e) { - instrumenter.end(context, request, null, e); + instrumenter.end(context, request, Status.UNKNOWN, e); throw e; } } @@ -110,7 +110,7 @@ public void sendMessage(REQUEST message) { try (Scope ignored = context.makeCurrent()) { super.sendMessage(message); } catch (Throwable e) { - instrumenter.end(context, request, null, e); + instrumenter.end(context, request, Status.UNKNOWN, e); throw e; } Span span = Span.fromContext(context); diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java index b79ec2cbd8a5..eb9801dca7e3 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java @@ -51,7 +51,7 @@ public ServerCall.Listener interceptCall( try (Scope ignored = context.makeCurrent()) { return new TracingServerCall<>(call, context, request).start(headers, next); } catch (Throwable e) { - instrumenter.end(context, request, null, e); + instrumenter.end(context, request, Status.UNKNOWN, e); throw e; } } @@ -132,7 +132,7 @@ public void onHalfClose() { try { delegate().onHalfClose(); } catch (Throwable e) { - instrumenter.end(context, request, null, e); + instrumenter.end(context, request, Status.UNKNOWN, e); throw e; } } @@ -145,10 +145,10 @@ public void onCancel() { Span.fromContext(context).setAttribute("grpc.canceled", true); } } catch (Throwable e) { - instrumenter.end(context, request, null, e); + instrumenter.end(context, request, Status.UNKNOWN, e); throw e; } - instrumenter.end(context, request, null, null); + instrumenter.end(context, request, Status.CANCELLED, null); } @Override @@ -156,7 +156,7 @@ public void onComplete() { try { delegate().onComplete(); } catch (Throwable e) { - instrumenter.end(context, request, null, e); + instrumenter.end(context, request, Status.UNKNOWN, e); throw e; } } @@ -166,7 +166,7 @@ public void onReady() { try { delegate().onReady(); } catch (Throwable e) { - instrumenter.end(context, request, null, e); + instrumenter.end(context, request, Status.UNKNOWN, e); throw e; } } diff --git a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java index dd87b7db9ecc..9fbb17402abd 100644 --- a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java +++ b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java @@ -881,7 +881,10 @@ public void sayHello( val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, - SemanticAttributes.NetTransportValues.IP_TCP)) + SemanticAttributes.NetTransportValues.IP_TCP), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.UNKNOWN.value())) .hasEventsSatisfying( events -> { assertThat(events).hasSize(2); @@ -1289,7 +1292,10 @@ public void onCompleted() { val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, - SemanticAttributes.NetTransportValues.IP_TCP)) + SemanticAttributes.NetTransportValues.IP_TCP), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.CANCELLED.value())) .hasEventsSatisfyingExactly( event -> event