Skip to content

Commit

Permalink
transport label for ping_pong_duration_seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Jul 13, 2024
1 parent 8e6bd0c commit a672c71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (c *Client) checkPong() {
}
lastSeen := c.lastSeen
c.mu.RUnlock()
c.node.metrics.observePingPongDuration(time.Duration(lastSeen-lastPing) * time.Nanosecond)
c.node.metrics.observePingPongDuration(time.Duration(lastSeen-lastPing)*time.Nanosecond, c.transport.Name())
if lastSeen < lastPing {
go func() { c.Disconnect(DisconnectNoPong) }()
return
Expand Down
10 changes: 5 additions & 5 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type metrics struct {

pubSubLagHistogram prometheus.Histogram
broadcastDurationHistogram prometheus.Histogram
pingPongDurationHistogram prometheus.Histogram
pingPongDurationHistogram *prometheus.HistogramVec
}

func (m *metrics) observeCommandDuration(frameType protocol.FrameType, d time.Duration) {
Expand Down Expand Up @@ -132,8 +132,8 @@ func (m *metrics) observeBroadcastDuration(started time.Time) {
m.broadcastDurationHistogram.Observe(time.Since(started).Seconds())
}

func (m *metrics) observePingPongDuration(duration time.Duration) {
m.pingPongDurationHistogram.Observe(duration.Seconds())
func (m *metrics) observePingPongDuration(duration time.Duration, transport string) {
m.pingPongDurationHistogram.WithLabelValues(transport).Observe(duration.Seconds())
}

func (m *metrics) setBuildInfo(version string) {
Expand Down Expand Up @@ -443,7 +443,7 @@ func initMetricsRegistry(registry prometheus.Registerer, metricsNamespace string
Help: "Count of recover operations.",
}, []string{"recovered"})

m.pingPongDurationHistogram = prometheus.NewHistogram(prometheus.HistogramOpts{
m.pingPongDurationHistogram = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: metricsNamespace,
Subsystem: "client",
Name: "ping_pong_duration_seconds",
Expand All @@ -452,7 +452,7 @@ func initMetricsRegistry(registry prometheus.Registerer, metricsNamespace string
0.000100, 0.000250, 0.000500, // Microsecond resolution.
0.001, 0.005, 0.010, 0.025, 0.050, 0.100, 0.250, 0.500, // Millisecond resolution.
1.0, 2.5, 5.0, 10.0, // Second resolution.
}})
}}, []string{"transport"})

m.transportConnectCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: metricsNamespace,
Expand Down

0 comments on commit a672c71

Please sign in to comment.