diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/MetricsView.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/MetricsView.java index da44a975200c..75b5710d5e9f 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/MetricsView.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/MetricsView.java @@ -30,6 +30,7 @@ private static Set buildAlwaysInclude() { view.add(SemanticAttributes.RPC_SYSTEM); view.add(SemanticAttributes.RPC_SERVICE); view.add(SemanticAttributes.RPC_METHOD); + view.add(SemanticAttributes.RPC_GRPC_STATUS_CODE); return view; } diff --git a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.java b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.java index f63f6dc27c9f..c7f194afe059 100644 --- a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.java +++ b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.java @@ -227,7 +227,10 @@ public void onCompleted() { equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.OK.value())))))); testing() .waitAndAssertMetrics( "io.opentelemetry.grpc-1.6", @@ -253,7 +256,10 @@ public void onCompleted() { equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.OK.value())))))); } private ManagedChannel createChannel(Server server) throws Exception { 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 e37514c98f08..6c48247ac432 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 @@ -217,7 +217,10 @@ public void sayHello( equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.OK.value())))))); testing() .waitAndAssertMetrics( "io.opentelemetry.grpc-1.6", @@ -242,7 +245,10 @@ public void sayHello( equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.OK.value())))))); } @Test @@ -398,7 +404,10 @@ public void sayHello( equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.OK.value())))))); testing() .waitAndAssertMetrics( "io.opentelemetry.grpc-1.6", @@ -423,7 +432,10 @@ public void sayHello( equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.OK.value())))))); } @Test @@ -587,7 +599,10 @@ public void onCompleted() { equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.OK.value())))))); testing() .waitAndAssertMetrics( "io.opentelemetry.grpc-1.6", @@ -612,7 +627,10 @@ public void onCompleted() { equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.OK.value())))))); } @ParameterizedTest @@ -733,7 +751,10 @@ public void sayHello( equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) status.getCode().value())))))); testing() .waitAndAssertMetrics( "io.opentelemetry.grpc-1.6", @@ -758,7 +779,10 @@ public void sayHello( equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) status.getCode().value())))))); } @ParameterizedTest @@ -880,7 +904,10 @@ public void sayHello( equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.UNKNOWN.value())))))); testing() .waitAndAssertMetrics( "io.opentelemetry.grpc-1.6", @@ -905,7 +932,10 @@ public void sayHello( equalTo( SemanticAttributes.RPC_SERVICE, "example.Greeter"), - equalTo(SemanticAttributes.RPC_SYSTEM, "grpc")))))); + equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), + equalTo( + SemanticAttributes.RPC_GRPC_STATUS_CODE, + (long) Status.Code.UNKNOWN.value())))))); } static class ErrorProvider implements ArgumentsProvider {