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

Function NewConstHistogram

prometheus/histogram.go:1362–1382  ·  view source on GitHub ↗

NewConstHistogram returns a metric representing a Prometheus histogram with fixed values for the count, sum, and bucket counts. As those parameters cannot be changed, the returned value does not implement the Histogram interface (but only the Metric interface). Users of this package will not have mu

(
	desc *Desc,
	count uint64,
	sum float64,
	buckets map[float64]uint64,
	labelValues ...string,
)

Source from the content-addressed store, hash-verified

1360// NewConstHistogram returns an error if the length of labelValues is not
1361// consistent with the variable labels in Desc or if Desc is invalid.
1362func NewConstHistogram(
1363 desc *Desc,
1364 count uint64,
1365 sum float64,
1366 buckets map[float64]uint64,
1367 labelValues ...string,
1368) (Metric, error) {
1369 if desc.err != nil {
1370 return nil, desc.err
1371 }
1372 if err := validateLabelValues(labelValues, len(desc.variableLabels.names)); err != nil {
1373 return nil, err
1374 }
1375 return &constHistogram{
1376 desc: desc,
1377 count: count,
1378 sum: sum,
1379 buckets: buckets,
1380 labelPairs: MakeLabelPairs(desc, labelValues),
1381 }, nil
1382}
1383
1384// MustNewConstHistogram is a version of NewConstHistogram that panics where
1385// NewConstHistogram would have returned an error.

Callers 1

MustNewConstHistogramFunction · 0.85

Calls 2

validateLabelValuesFunction · 0.85
MakeLabelPairsFunction · 0.85

Tested by

no test coverage detected