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

Function addWithExemplar

prometheus/promhttp/instrument_server.go:43–49  ·  view source on GitHub ↗

addWithExemplar is a wrapper for [prometheus.ExemplarAdder.AddWithExemplar], which falls back to [prometheus.Counter.Add] if no labels are provided.

(obs prometheus.Counter, val float64, labels map[string]string)

Source from the content-addressed store, hash-verified

41// addWithExemplar is a wrapper for [prometheus.ExemplarAdder.AddWithExemplar],
42// which falls back to [prometheus.Counter.Add] if no labels are provided.
43func addWithExemplar(obs prometheus.Counter, val float64, labels map[string]string) {
44 if labels == nil {
45 obs.Add(val)
46 return
47 }
48 obs.(prometheus.ExemplarAdder).AddWithExemplar(val, labels)
49}
50
51// InstrumentHandlerInFlight is a middleware that wraps the provided
52// http.Handler. It sets the provided prometheus.Gauge to the number of

Callers 2

InstrumentHandlerCounterFunction · 0.85

Calls 2

AddMethod · 0.65
AddWithExemplarMethod · 0.65

Tested by

no test coverage detected