GetMetricWith returns the Metric for the given Labels map (the label names must match those of the variable labels in Desc). If that label map is accessed for the first time, a new Metric is created. Implications of creating a Metric without using it and keeping the Metric for later use are the same
(labels Labels)
| 236 | // around MetricVec, implementing a vector for a specific Metric implementation, |
| 237 | // for example GaugeVec. |
| 238 | func (m *MetricVec) GetMetricWith(labels Labels) (Metric, error) { |
| 239 | labels, closer := constrainLabels(m.desc, labels) |
| 240 | defer closer() |
| 241 | |
| 242 | h, err := m.hashLabels(labels) |
| 243 | if err != nil { |
| 244 | return nil, err |
| 245 | } |
| 246 | |
| 247 | return m.getOrCreateMetricWithLabels(h, labels, m.curry), nil |
| 248 | } |
| 249 | |
| 250 | func (m *MetricVec) hashLabelValues(vals []string) (uint64, error) { |
| 251 | if err := validateLabelValues(vals, len(m.desc.variableLabels.names)-len(m.curry)); err != nil { |
nothing calls this directly
no test coverage detected