MCPcopy Create free account
hub / github.com/prometheus/common / readingLabels

Method readingLabels

expfmt/text_parse.go:318–334  ·  view source on GitHub ↗

readingLabels represents the state where the last byte read (now in p.currentByte) is either the first byte of the label set (i.e. a '{'), or the first byte of the value (otherwise).

()

Source from the content-addressed store, hash-verified

316// p.currentByte) is either the first byte of the label set (i.e. a '{'), or the
317// first byte of the value (otherwise).
318func (p *TextParser) readingLabels() stateFn {
319 // Summaries/histograms are special. We have to reset the
320 // currentLabels map, currentQuantile and currentBucket before starting to
321 // read labels.
322 if p.currentMF.GetType() == dto.MetricType_SUMMARY ||
323 p.currentMF.GetType() == dto.MetricType_HISTOGRAM ||
324 p.currentMF.GetType() == dto.MetricType_GAUGE_HISTOGRAM {
325 p.currentLabels = map[string]string{}
326 p.currentLabels[string(model.MetricNameLabel)] = p.currentMF.GetName()
327 p.currentQuantile = math.NaN()
328 p.currentBucket = math.NaN()
329 }
330 if p.currentByte != '{' {
331 return p.readingValue
332 }
333 return p.startLabelName
334}
335
336// startLabelName represents the state where the next byte read from p.buf is
337// the start of a label name (or whitespace leading up to it).

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected