Skip to content

Commit

Permalink
[PERF] textparse: optimize OM p.isCreatedSeries() (#15150)
Browse files Browse the repository at this point in the history
* refac: remove p.Metric usage

Signed-off-by: Manik Rana <[email protected]>

* perf: use bytes instead of strings

Signed-off-by: Manik Rana <[email protected]>

* chore: comments

Signed-off-by: Manik Rana <[email protected]>

---------

Signed-off-by: Manik Rana <[email protected]>
Signed-off-by: Manik Rana <[email protected]>
  • Loading branch information
Maniktherana authored Oct 14, 2024
1 parent b8867f8 commit c3b8582
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions model/textparse/openmetricsparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c3b8582

Please sign in to comment.