Metric fixes

Squashed commit of the following:

commit c6eb4d8bbf80320ec2b6d416c77659b0343e5e47
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date:   Mon Jul 19 16:52:57 2021 +0100

    Fix bug

commit d420966d9ac44936728960a8d38602662b58f1c3
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date:   Mon Jul 19 16:46:12 2021 +0100

    Update metric

commit 0ad6e37846e2ebbbd0e33a38274094bd15b8f11b
Author: Neil Alexander <neilalexander@users.noreply.github.com>
Date:   Mon Jul 19 16:30:14 2021 +0100

    Fix observe for calculateStateDurations
main
Neil Alexander 2021-07-19 17:20:55 +01:00
parent eb2a8e4c0b
commit 09d3bab838
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
1 changed files with 4 additions and 5 deletions

View File

@ -428,12 +428,12 @@ var calculateStateDurations = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ prometheus.HistogramOpts{
Namespace: "dendrite", Namespace: "dendrite",
Subsystem: "roomserver", 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", Help: "How long it takes to calculate the state after a list of events",
Buckets: []float64{ // milliseconds 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, 1000, 2000, 3000, 4000, 5000, 6000,
7000, 8000, 9000, 10000, 15000, 20000, 7000, 8000, 9000, 10000, 15000, 20000, 30000,
}, },
}, },
// Takes two labels: // Takes two labels:
@ -501,9 +501,8 @@ func (c *calculateStateMetrics) stop(stateNID types.StateSnapshotNID, err error)
} else { } else {
outcome = "failure" outcome = "failure"
} }
endTime := time.Now()
calculateStateDurations.WithLabelValues(c.algorithm, outcome).Observe( 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( calculateStatePrevEventLength.WithLabelValues(c.algorithm, outcome).Observe(
float64(c.prevEventLength), float64(c.prevEventLength),