This repository has been archived by the owner on Dec 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metrics: removes delegate field from prometheus timer metric
We often need the ability to update label values on a timer that's in flight and originally we would create a delegate, that was a prometheus Observer when the timer is started. This isn't needed as we can just create the observer on the fly when we want to stop the timer and observe the duration, allowing us to set the labels that can be passed in.
- Loading branch information
Showing
4 changed files
with
26 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
package collectors | ||
|
||
// TimerHandle is a type used to map running timers for defered observations. | ||
type TimerHandle struct{} | ||
|
||
// TimerOptions is used to configure a timer with labels and histogram boundaries. | ||
type TimerOptions struct { | ||
Description string | ||
Labels []string | ||
HistogramBoundaries []float64 | ||
} | ||
|
||
// Timer is a named metric with labels. It allows concurrent use by returning a handle | ||
// when the timer is started. This handle is used to lookup a running timer to record the duration. | ||
type Timer interface { | ||
WithLabels([]Label) (Timer, error) | ||
// WithLabels returns a new Timer with labels attached. | ||
WithLabels(...Label) Timer | ||
Start() *TimerHandle | ||
ObserveDuration(*TimerHandle) | ||
ObserveDuration(*TimerHandle, ...Label) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters