Make rpc.grpc.status_code required
MODIFY
instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java
instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java
@@ -52,7 +52,7 @@ final class TracingClientInterceptor implements ClientInterceptor {
// 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 @@ final class TracingClientInterceptor implements ClientInterceptor {
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 @@ final class TracingClientInterceptor implements ClientInterceptor {
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);

MODIFY
instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java
instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java
@@ -51,7 +51,7 @@ final class TracingServerInterceptor implements ServerInterceptor {
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 @@ final class TracingServerInterceptor implements ServerInterceptor {
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 @@ final class TracingServerInterceptor implements ServerInterceptor {
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 @@ final class TracingServerInterceptor implements ServerInterceptor {
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 @@ final class TracingServerInterceptor implements ServerInterceptor {
try {
delegate().onReady();
} catch (Throwable e) {
- instrumenter.end(context, request, null, e);
+ instrumenter.end(context, request, Status.UNKNOWN, e);
throw e;
}
}

MODIFY
instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java
instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java
@@ -881,7 +881,10 @@ public abstract class AbstractGrpcTest {
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 abstract class AbstractGrpcTest {
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

Make rpc.grpc.status_code required (#6184)