Skip to content

Commit

Permalink
RPC server metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
alpinskiy committed Jun 13, 2024
1 parent 0523f36 commit 22a2df9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions internal/util/common_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import (
)

type RPCServerMetrics struct {
сonnCount *statshouse.MetricRef
commonTags statshouse.Tags
сonnCount *statshouse.MetricRef
workerPoolSize *statshouse.MetricRef
longPollWaiting *statshouse.MetricRef
requestMemory *statshouse.MetricRef
responseMemory *statshouse.MetricRef
commonTags statshouse.Tags
}

func NewRPCServerMetrics(service string) *RPCServerMetrics {
Expand All @@ -23,8 +27,12 @@ func NewRPCServerMetrics(service string) *RPCServerMetrics {
env.DataCenter,
}
return &RPCServerMetrics{
сonnCount: statshouse.Metric("common_rpc_server_conn", tag),
commonTags: tag,
сonnCount: statshouse.Metric("common_rpc_server_conn", tag),
workerPoolSize: statshouse.Metric("common_rpc_server_worker_pool_size", tag),
longPollWaiting: statshouse.Metric("common_rpc_server_longpoll_waiting", tag),
requestMemory: statshouse.Metric("common_rpc_server_request_mem", tag),
responseMemory: statshouse.Metric("common_rpc_server_response_mem", tag),
commonTags: tag,
}
}

Expand All @@ -37,6 +45,13 @@ func (s *RPCServerMetrics) ServerWithMetrics(so *rpc.ServerOptions) {
func (s *RPCServerMetrics) Run(server *rpc.Server) func() {
id := statshouse.StartRegularMeasurement(func(client *statshouse.Client) {
s.сonnCount.Value(float64(server.ConnectionsCurrent()))
workerPoolSize, _ := server.WorkersPoolSize()
s.workerPoolSize.Value(float64(workerPoolSize))
s.longPollWaiting.Value(float64(server.LongPollsWaiting()))
requestMemory, _ := server.RequestsMemory()
s.requestMemory.Value(float64(requestMemory))
responseMemory, _ := server.ResponsesMemory()
s.responseMemory.Value(float64(responseMemory))
})
return func() {
statshouse.StopRegularMeasurement(id)
Expand Down

0 comments on commit 22a2df9

Please sign in to comment.