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

Function NewHistogram

prometheus/histogram.go:523–533  ·  view source on GitHub ↗

NewHistogram creates a new Histogram based on the provided HistogramOpts. It panics if the buckets in HistogramOpts are not in strictly increasing order. The returned implementation also implements ExemplarObserver. It is safe to perform the corresponding type assertion. Exemplars are tracked separ

(opts HistogramOpts)

Source from the content-addressed store, hash-verified

521// perform the corresponding type assertion. Exemplars are tracked separately
522// for each bucket.
523func NewHistogram(opts HistogramOpts) Histogram {
524 return newHistogram(
525 NewDesc(
526 BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
527 opts.Help,
528 nil,
529 opts.ConstLabels,
530 ),
531 opts,
532 )
533}
534
535func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogram {
536 if len(desc.variableLabels.names) != len(labelValues) {

Callers 15

ExampleHistogramFunction · 0.92
testHandlerFunction · 0.92
TestToFloat64Function · 0.92
NewHistogramMethod · 0.92
NewMetricsFunction · 0.92
mainFunction · 0.92
mainFunction · 0.92
TestTimerObserveFunction · 0.70

Calls 3

newHistogramFunction · 0.85
NewDescFunction · 0.85
BuildFQNameFunction · 0.85

Tested by 15

ExampleHistogramFunction · 0.74
testHandlerFunction · 0.74
TestToFloat64Function · 0.74
TestTimerObserveFunction · 0.56
benchmarkHistogramWriteFunction · 0.56
TestHistogramConcurrencyFunction · 0.56