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

Method NewGaugeVec

prometheus/gauge.go:160–177  ·  view source on GitHub ↗

NewGaugeVec creates a new GaugeVec based on the provided GaugeVecOpts.

(opts GaugeVecOpts)

Source from the content-addressed store, hash-verified

158
159// NewGaugeVec creates a new GaugeVec based on the provided GaugeVecOpts.
160func (v2) NewGaugeVec(opts GaugeVecOpts) *GaugeVec {
161 desc := V2.NewDesc(
162 BuildFQName(opts.Namespace, opts.Subsystem, opts.Name),
163 opts.Help,
164 opts.VariableLabels,
165 opts.ConstLabels,
166 )
167 return &GaugeVec{
168 MetricVec: NewMetricVec(desc, func(lvs ...string) Metric {
169 if len(lvs) != len(desc.variableLabels.names) {
170 panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels.names, lvs))
171 }
172 result := &gauge{desc: desc, labelPairs: MakeLabelPairs(desc, lvs)}
173 result.init(result) // Init self-collection.
174 return result
175 }),
176 }
177}
178
179// GetMetricWithLabelValues returns the Gauge for the given slice of label
180// values (same order as the variable labels in Desc). If that combination of

Calls 6

BuildFQNameFunction · 0.85
NewMetricVecFunction · 0.85
MakeLabelPairsFunction · 0.85
NewDescMethod · 0.80
initMethod · 0.80