Skip to content

Commit

Permalink
feat: improve duration usability (#42)
Browse files Browse the repository at this point in the history
Co-authored-by: Iusupov Anton <yusupovanton@outlook.com>
  • Loading branch information
antoniusupov and Iusupov Anton authored Aug 14, 2024
1 parent 651b149 commit 67ebc1e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions metrics/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package metrics

import (
"context"
"time"

"github.com/prometheus/client_golang/prometheus"
)
Expand Down Expand Up @@ -136,15 +137,16 @@ func (s Series) Error(message string) (string, prometheus.Labels) {
}

// Duration returns the metric name and labels for recording a duration.
func (s Series) Duration() (string, prometheus.Labels) {
func (s Series) Duration(d time.Duration) (string, prometheus.Labels, float64) {
labels := prometheus.Labels{
"series_type": s.seriesType.String(),
"sub_type": s.subType,
"operation": s.operation,
"status": seriesTypeDuration,
"message": "",
}
return "operation_duration_seconds", mergeLabels(labels, s.labels)

return "operation_duration_seconds", mergeLabels(labels, s.labels), d.Seconds()
}

// appendOperation appends the operation to the Series operation string.
Expand Down

0 comments on commit 67ebc1e

Please sign in to comment.