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

node: add status code support to gRPC metrics #409

Merged
merged 1 commit into from
Jul 24, 2024
Merged

Conversation

bas-vk
Copy link
Contributor

@bas-vk bas-vk commented Jul 15, 2024

Add the following metrics:

  • grpc_unary_status_code[proc,status], unary calls grouped by procedure and status
  • grpc_server_stream_status_code[proc,status], server streams grouped by procedure and status

Client streams are more complicated to capture the status code. Since we don't those client streams metrics are not enhanced with status.

@bas-vk bas-vk force-pushed the basvk/grpcmetrics branch 3 times, most recently from 2e964d0 to 4991948 Compare July 16, 2024 12:30
@bas-vk bas-vk marked this pull request as ready for review July 16, 2024 14:05
@bas-vk bas-vk requested a review from sergekh2 as a code owner July 16, 2024 14:05
return next(ctx, req)
resp, err := next(ctx, req)

s.With(prometheus.Labels{"status": fmt.Sprintf("%d", statusCode(err))}).Inc()
Copy link
Contributor

@sergekh2 sergekh2 Jul 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for status, lets use text name - it's way easier to work with metrics then.

also please extract river error, if present, and use it's code, then protocol.Err_name gives you text name for the given code (works for grpc/connect codes as well).

Underlying error can be extracted by Unwrap or error.As

unaryInflight: s.metrics.NewGaugeVecEx("grpc_unary_inflight", "gRPC unary calls in flight", "proc"),
openClientStreams: s.metrics.NewGaugeVecEx("grpc_open_client_streams", "gRPC open client streams", "proc"),
openServerStreams: s.metrics.NewGaugeVecEx("grpc_open_server_streams", "gRPC open server streams", "proc"),
rpcDuration: s.rpcDuration,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure why durations is initialized this way, I think it can be removed from Service and be moved here for consistently. (also it's "method" on duration and "proc" here, lets unify)

@bas-vk bas-vk force-pushed the basvk/grpcmetrics branch from 4991948 to 69db95b Compare July 18, 2024 08:04
@bas-vk bas-vk force-pushed the basvk/grpcmetrics branch from 69db95b to 711a2fc Compare July 22, 2024 13:31
@bas-vk bas-vk force-pushed the basvk/grpcmetrics branch from 711a2fc to d4d3c25 Compare July 24, 2024 08:29
@bas-vk bas-vk merged commit 2730008 into main Jul 24, 2024
5 of 7 checks passed
@bas-vk bas-vk deleted the basvk/grpcmetrics branch July 24, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants