Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add grpc status code to metrics attrs #6556

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private static Set<AttributeKey> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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 {
Expand Down