Skip to content

Commit

Permalink
chore: add websocket total counter
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenvechain committed Nov 25, 2024
1 parent c108db4 commit 24b7f90
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
metricHTTPReqCounter = metrics.LazyLoadCounterVec("api_request_count", []string{"name", "code", "method"})
metricHTTPReqDuration = metrics.LazyLoadHistogramVec("api_duration_ms", []string{"name", "code", "method"}, metrics.BucketHTTPReqs)
metricActiveWebsocketCount = metrics.LazyLoadGaugeVec("api_active_websocket_count", []string{"subject"})
metricWebsocketCounter = metrics.LazyLoadCounterVec("api_websocket_count", []string{"subject"})
)

// metricsResponseWriter is a wrapper around http.ResponseWriter that captures the status code.
Expand Down Expand Up @@ -82,6 +83,7 @@ func metricsMiddleware(next http.Handler) http.Handler {
mrw := newMetricsResponseWriter(w)
if subscription != "" {
metricActiveWebsocketCount().AddWithLabel(1, map[string]string{"subject": subscription})
metricWebsocketCounter().AddWithLabel(1, map[string]string{"subject": subscription})
}

next.ServeHTTP(mrw, r)
Expand Down

0 comments on commit 24b7f90

Please sign in to comment.