MCPcopy Create free account
hub / github.com/netdata/netdata / addCounter

Method addCounter

src/go/pkg/prometheus/parse.go:259–276  ·  view source on GitHub ↗
(value float64)

Source from the content-addressed store, hash-verified

257}
258
259func (p *promTextParser) addCounter(value float64) {
260 p.currSeries, _, _ = removeLabel(p.currSeries, labels.MetricName)
261
262 if v := len(p.currMF.metrics); v == cap(p.currMF.metrics) {
263 p.currMF.metrics = append(p.currMF.metrics, Metric{
264 labels: copyLabels(p.currSeries),
265 counter: &Counter{value: value},
266 })
267 } else {
268 p.currMF.metrics = p.currMF.metrics[:v+1]
269 if p.currMF.metrics[v].counter == nil {
270 p.currMF.metrics[v].counter = &Counter{}
271 }
272 p.currMF.metrics[v].counter.value = value
273 p.currMF.metrics[v].labels = p.currMF.metrics[v].labels[:0]
274 p.currMF.metrics[v].labels = append(p.currMF.metrics[v].labels, p.currSeries...)
275 }
276}
277
278func (p *promTextParser) addUnknown(value float64) {
279 p.currSeries, _, _ = removeLabel(p.currSeries, labels.MetricName)

Callers 1

parseToMetricFamiliesMethod · 0.95

Calls 2

removeLabelFunction · 0.85
copyLabelsFunction · 0.70

Tested by

no test coverage detected