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

Function HandlerFor

prometheus/promhttp/http.go:108–110  ·  view source on GitHub ↗

HandlerFor returns an uninstrumented http.Handler for the provided Gatherer. The behavior of the Handler is defined by the provided HandlerOpts. Thus, HandlerFor is useful to create http.Handlers for custom Gatherers, with non-default HandlerOpts, and/or with custom (or no) instrumentation. Use the

(reg prometheus.Gatherer, opts HandlerOpts)

Source from the content-addressed store, hash-verified

106// instrumentation. Use the InstrumentMetricHandler function to apply the same
107// kind of instrumentation as it is used by the Handler function.
108func HandlerFor(reg prometheus.Gatherer, opts HandlerOpts) http.Handler {
109 return HandlerForTransactional(prometheus.ToTransactionalGatherer(reg), opts)
110}
111
112// HandlerForTransactional is like HandlerFor, but it uses transactional gather, which
113// can safely change in-place returned *dto.MetricFamily before call to `Gather` and after

Callers 15

ExampleCollectorFunction · 0.92
testHandlerFunction · 0.92
ExampleNewGoCollectorFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92

Calls 2

ToTransactionalGathererFunction · 0.92
HandlerForTransactionalFunction · 0.85

Tested by 7

ExampleCollectorFunction · 0.74
testHandlerFunction · 0.74
ExampleNewGoCollectorFunction · 0.74
TestHandlerTimeoutFunction · 0.68
BenchmarkCompressionFunction · 0.68