Add Prometheus gauge for current gRPC client connections#545
Add Prometheus gauge for current gRPC client connections#545czarcas7ic wants to merge 1 commit intozcash:masterfrom
Conversation
f7f5dae to
20e0785
Compare
|
I can't get this to work in testing. It's probably something in my environment. |
|
Its working on my machine too
@LarryRuane I think your issue is a more general setup issue, e.g. no prometheus running in the first place. Did you install prometheus? and then I ask claude to install it |
LarryRuane
left a comment
There was a problem hiding this comment.
Did you install prometheus?
No, I didn't; I'm sure that's the problem. But I don't really need to run it, I'm fine with merging this since some have asked for it, and it's easy to add. I verified that there is no noticeable difference in performance or memory usage with this PR compared to without it. I ran both tests (go test ./... and ./smoke-test.bash) and there are no failures. I did not test the actual functionality (but I'm sure it's okay).
ACK 20e0785

A node runner mentioned having the number of connections as a Prometheus metric would be helpful for them, so added it here.
Summary
grpc_server_connections_currentPrometheus gauge that tracks active gRPC client connectionsstats.Handlerinterface (ConnBegin/ConnEnd)google.golang.org/grpc/stats(part of grpc-go) andpromauto(part of existing prometheus/client_golang)Changes
cmd/connstats.go— defines the gauge and aconnStatsHandlerimplementingstats.Handlercmd/root.go— wiresgrpc.StatsHandler(&connStatsHandler{})into both the TLS and non-TLSgrpc.NewServer()callscmd/connstats_test.go— unit tests for increment/decrement and passthrough behaviorgo.mod—go mod tidypromoted two already-present indirect deps to directTesting