From 09d3bab8380fd59f855d05ea743062b52fca4045 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Mon, 19 Jul 2021 17:20:55 +0100 Subject: [PATCH] Metric fixes Squashed commit of the following: commit c6eb4d8bbf80320ec2b6d416c77659b0343e5e47 Author: Neil Alexander Date: Mon Jul 19 16:52:57 2021 +0100 Fix bug commit d420966d9ac44936728960a8d38602662b58f1c3 Author: Neil Alexander Date: Mon Jul 19 16:46:12 2021 +0100 Update metric commit 0ad6e37846e2ebbbd0e33a38274094bd15b8f11b Author: Neil Alexander Date: Mon Jul 19 16:30:14 2021 +0100 Fix observe for calculateStateDurations --- roomserver/state/state.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/roomserver/state/state.go b/roomserver/state/state.go index b28bda7f..3d71dbb6 100644 --- a/roomserver/state/state.go +++ b/roomserver/state/state.go @@ -428,12 +428,12 @@ var calculateStateDurations = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: "dendrite", Subsystem: "roomserver", - Name: "calculate_state_duration_microseconds", + Name: "calculate_state_duration_milliseconds", Help: "How long it takes to calculate the state after a list of events", Buckets: []float64{ // milliseconds - 5, 10, 25, 50, 75, 100, 250, 500, + 5, 10, 25, 50, 75, 100, 200, 300, 400, 500, 1000, 2000, 3000, 4000, 5000, 6000, - 7000, 8000, 9000, 10000, 15000, 20000, + 7000, 8000, 9000, 10000, 15000, 20000, 30000, }, }, // Takes two labels: @@ -501,9 +501,8 @@ func (c *calculateStateMetrics) stop(stateNID types.StateSnapshotNID, err error) } else { outcome = "failure" } - endTime := time.Now() calculateStateDurations.WithLabelValues(c.algorithm, outcome).Observe( - float64(endTime.Sub(c.startTime).Nanoseconds()) / 1000., + float64(time.Since(c.startTime).Milliseconds()), ) calculateStatePrevEventLength.WithLabelValues(c.algorithm, outcome).Observe( float64(c.prevEventLength),