[baseserver] Expose gRPC prometheus metrics #9879
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, prometheus metrics are not part of our default interceptors used across all gRPC servers. This is because every server handles is slightly differently. As part of ongoing WIP migration of existing gRPC servers onto base-server, it's necessary to be able to expose gRPC metrics with configurable prometheus registry.
This PR ensures that with, or without, a custom
prometheus.Registry
, gRPC metrics are exposed as long as the server serves gRPC traffic.Related Issue(s)
Fixes #
How to test
Unit tests
or
cd components/public-api-server && go run main.go
cd dev/gpctl && go run main.go api workspaces get --id 123 --token foo --address localhost:9501 --insecure
- the token here doesn't matter, we just need to hit it even with bad authcurl localhost:9500/metrics
and observe at least the following metrics:"grpc_server_handled_total", "grpc_server_handling_seconds", "grpc_server_started_total"
Release Notes
Documentation
NONE