Skip to content

Commit

Permalink
fix: grpc_server_started_total metric not reporting custom labels
Browse files Browse the repository at this point in the history
  • Loading branch information
pskrunner14 committed Jul 5, 2023
1 parent e88ecfc commit a879144
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,27 @@ type serverReporter struct {
startTime time.Time
clientUuid string
flowUuid string
first bool
}

func newServerReporter(m *ServerMetrics, rpcType grpcType, fullMethod string) *serverReporter {
r := &serverReporter{
metrics: m,
rpcType: rpcType,
first: true,
}
if r.metrics.serverHandledHistogramEnabled {
r.startTime = time.Now()
}
r.serviceName, r.methodName = splitMethodName(fullMethod)
r.metrics.serverStartedCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName, r.clientUuid, r.flowUuid).Inc()
return r
}

func (r *serverReporter) ReceivedMessage() {
if r.first {
r.metrics.serverStartedCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName, r.clientUuid, r.flowUuid).Inc()
r.first = false
}
r.metrics.serverStreamMsgReceived.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName, r.clientUuid, r.flowUuid).Inc()
if r.metrics.serverHandledHistogramEnabled {
r.startTime = time.Now()
Expand Down

0 comments on commit a879144

Please sign in to comment.