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.
(exemplar Labels)
| 68 | // observe exemplar with the duration unless exemplar is nil or provided Observer can't |
| 69 | // be casted to ExemplarObserver. |
| 70 | func (t *Timer) ObserveDurationWithExemplar(exemplar Labels) time.Duration { |
| 71 | d := time.Since(t.begin) |
| 72 | eo, ok := t.observer.(ExemplarObserver) |
| 73 | if ok && exemplar != nil { |
| 74 | eo.ObserveWithExemplar(d.Seconds(), exemplar) |
| 75 | return d |
| 76 | } |
| 77 | if t.observer != nil { |
| 78 | t.observer.Observe(d.Seconds()) |
| 79 | } |
| 80 | return d |
| 81 | } |