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

Function WithLabelFromCtx

prometheus/promhttp/option.go:80–84  ·  view source on GitHub ↗

WithLabelFromCtx registers a label for dynamic resolution with access to context. See the example for ExampleInstrumentHandlerWithLabelResolver for example usage

(name string, valueFn LabelValueFromCtx)

Source from the content-addressed store, hash-verified

78// WithLabelFromCtx registers a label for dynamic resolution with access to context.
79// See the example for ExampleInstrumentHandlerWithLabelResolver for example usage
80func WithLabelFromCtx(name string, valueFn LabelValueFromCtx) Option {
81 return optionApplyFunc(func(o *options) {
82 o.extraLabelsFromCtx[name] = valueFn
83 })
84}

Callers 2

TestLabelCheckFunction · 0.85
ExampleWithLabelFromCtxFunction · 0.85

Calls 1

optionApplyFuncFuncType · 0.85

Tested by 2

TestLabelCheckFunction · 0.68
ExampleWithLabelFromCtxFunction · 0.68