mirror of
https://github.com/prometheus/prometheus
synced 2025-03-11 07:59:57 +00:00
[PERF] textparse: optimize OM p.isCreatedSeries()
(#15150)
* refac: remove p.Metric usage Signed-off-by: Manik Rana <manikrana54@gmail.com> * perf: use bytes instead of strings Signed-off-by: Manik Rana <manikrana54@gmail.com> * chore: comments Signed-off-by: Manik Rana <Manikrana54@gmail.com> --------- Signed-off-by: Manik Rana <manikrana54@gmail.com> Signed-off-by: Manik Rana <Manikrana54@gmail.com>
This commit is contained in:
parent
b8867f8ead
commit
c3b8582cf4
@ -652,10 +652,9 @@ func (p *OpenMetricsParser) parseLVals(offsets []int, isExemplar bool) ([]int, e
|
||||
|
||||
// isCreatedSeries returns true if the current series is a _created series.
|
||||
func (p *OpenMetricsParser) isCreatedSeries() bool {
|
||||
var newLbs labels.Labels
|
||||
p.Metric(&newLbs)
|
||||
name := newLbs.Get(model.MetricNameLabel)
|
||||
if typeRequiresCT(p.mtype) && strings.HasSuffix(name, "_created") {
|
||||
metricName := p.series[p.offsets[0]-p.start : p.offsets[1]-p.start]
|
||||
// check length so the metric is longer than len("_created")
|
||||
if typeRequiresCT(p.mtype) && len(metricName) >= 8 && string(metricName[len(metricName)-8:]) == "_created" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user