kubernetes/vendor/github.com/prometheus/client_golang/prometheus/timer.go

type Timer

// NewTimer creates a new Timer. The provided Observer is used to observe a
// duration in seconds. If the Observer implements ExemplarObserver, passing exemplar
// later on will be also supported.
// Timer is usually used to time a function call in the
// following way:
//
//	func TimeMe() {
//	    timer := NewTimer(myHistogram)
//	    defer timer.ObserveDuration()
//	    // Do actual work.
//	}
//
// or
//
//	func TimeMeWithExemplar() {
//		    timer := NewTimer(myHistogram)
//		    defer timer.ObserveDurationWithExemplar(exemplar)
//		    // Do actual work.
//		}
func NewTimer(o Observer) *Timer {}

// ObserveDuration records the duration passed since the Timer was created with
// NewTimer. It calls the Observe method of the Observer provided during
// construction with the duration in seconds as an argument. The observed
// duration is also returned. ObserveDuration is usually called with a defer
// statement.
//
// Note that this method is only guaranteed to never observe negative durations
// if used with Go1.9+.
func (t *Timer) ObserveDuration() time.Duration {}

// ObserveDurationWithExemplar is like ObserveDuration, but it will also
// observe exemplar with the duration unless exemplar is nil or provided Observer can't
// be casted to ExemplarObserver.
func (t *Timer) ObserveDurationWithExemplar(exemplar Labels) time.Duration {}