MCPcopy Create free account
hub / github.com/prometheus/client_golang / ExampleTimer

Function ExampleTimer

prometheus/example_timer_test.go:29–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27})
28
29func ExampleTimer() {
30 // timer times this example function. It uses a Histogram, but a Summary
31 // would also work, as both implement Observer. Check out
32 // https://prometheus.io/docs/practices/histograms/ for differences.
33 timer := prometheus.NewTimer(requestDuration)
34 defer timer.ObserveDuration()
35
36 // Do something here that takes time.
37 time.Sleep(time.Duration(rand.NormFloat64()*10000+50000) * time.Microsecond)
38}

Callers

nothing calls this directly

Calls 2

ObserveDurationMethod · 0.95
NewTimerFunction · 0.92

Tested by

no test coverage detected