From f379f6b4b4ce02f1eb453c22330a99ec14cb1c11 Mon Sep 17 00:00:00 2001 From: Max Ignatenko Date: Sun, 27 Oct 2024 12:21:59 +0000 Subject: [PATCH] fix: tweak histogram buckets --- cmd/plc-mirror/metrics.go | 5 +++-- cmd/plc-mirror/serve.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/plc-mirror/metrics.go b/cmd/plc-mirror/metrics.go index a5cbdad..2a5cc4a 100644 --- a/cmd/plc-mirror/metrics.go +++ b/cmd/plc-mirror/metrics.go @@ -16,6 +16,7 @@ var requestCount = promauto.NewCounterVec(prometheus.CounterOpts{ }, []string{"status"}) var requestLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{ - Name: "plcmirror_response_latency_millisecond", - Help: "Latency of responses.", + Name: "plcmirror_response_latency_millisecond", + Help: "Latency of responses.", + Buckets: prometheus.ExponentialBucketsRange(1, 30000, 20), }, []string{"status"}) diff --git a/cmd/plc-mirror/serve.go b/cmd/plc-mirror/serve.go index ef739a1..bff15ff 100644 --- a/cmd/plc-mirror/serve.go +++ b/cmd/plc-mirror/serve.go @@ -67,7 +67,7 @@ func (s *Server) serve(ctx context.Context, req *http.Request) convreq.HttpRespo start := time.Now() updateMetrics := func(c int) { requestCount.WithLabelValues(fmt.Sprint(c)).Inc() - requestLatency.WithLabelValues(fmt.Sprint(c)).Observe(float64(time.Now().Sub(start).Milliseconds())) + requestLatency.WithLabelValues(fmt.Sprint(c)).Observe(float64(time.Now().Sub(start)) / float64(time.Millisecond)) } delay := time.Since(s.mirror.LastSuccess())