MCPcopy
hub / github.com/prometheus/client_golang / NewTimer

Function NewTimer

prometheus/timer.go:44–49  ·  view source on GitHub ↗

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(my

(o Observer)

Source from the content-addressed store, hash-verified

42// // Do actual work.
43// }
44func NewTimer(o Observer) *Timer {
45 return &Timer{
46 begin: time.Now(),
47 observer: o,
48 }
49}
50
51// ObserveDuration records the duration passed since the Timer was created with
52// NewTimer. It calls the Observe method of the Observer provided during

Callers 8

runFunction · 0.92
ExampleTimerFunction · 0.92
handlerFunction · 0.92
TestTimerObserveFunction · 0.85
TestTimerEmptyFunction · 0.85
TestTimerByOutcomeFunction · 0.85

Calls

no outgoing calls

Tested by 8

runFunction · 0.74
ExampleTimerFunction · 0.74
handlerFunction · 0.74
TestTimerObserveFunction · 0.68
TestTimerEmptyFunction · 0.68
TestTimerByOutcomeFunction · 0.68