NewGaugeVec creates a new GaugeVec based on the provided GaugeVecOpts.
(opts GaugeVecOpts)
| 158 | |
| 159 | // NewGaugeVec creates a new GaugeVec based on the provided GaugeVecOpts. |
| 160 | func (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 |