Skip to content

Commit

Permalink
Merge pull request prometheus#14949 from Maniktherana/minor-fixes-ct
Browse files Browse the repository at this point in the history
refac: make typeRequiresCT private
  • Loading branch information
ArthurSens authored Sep 20, 2024
2 parents 9215252 + 315165e commit ca18f29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions model/textparse/openmetricsparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (p *OpenMetricsParser) Exemplar(e *exemplar.Exemplar) bool {
// CreatedTimestamp returns the created timestamp for a current Metric if exists or nil.
// NOTE(Maniktherana): Might use additional CPU/mem resources due to deep copy of parser required for peeking given 1.0 OM specification on _created series.
func (p *OpenMetricsParser) CreatedTimestamp() *int64 {
if !TypeRequiresCT(p.mtype) {
if !typeRequiresCT(p.mtype) {
// Not a CT supported metric type, fast path.
return nil
}
Expand Down Expand Up @@ -302,8 +302,8 @@ func (p *OpenMetricsParser) CreatedTimestamp() *int64 {
}
}

// TypeRequiresCT returns true if the metric type requires a _created timestamp.
func TypeRequiresCT(t model.MetricType) bool {
// typeRequiresCT returns true if the metric type requires a _created timestamp.
func typeRequiresCT(t model.MetricType) bool {
switch t {
case model.MetricTypeCounter, model.MetricTypeSummary, model.MetricTypeHistogram:
return true
Expand Down Expand Up @@ -594,7 +594,7 @@ 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") {
if typeRequiresCT(p.mtype) && strings.HasSuffix(name, "_created") {
return true
}
return false
Expand Down
2 changes: 1 addition & 1 deletion model/textparse/promparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func checkParseResultsWithCT(t *testing.T, p Parser, exp []expectedParse, ctLine
if ctLinesRemoved {
// Are CT series skipped?
_, typ := p.Type()
if TypeRequiresCT(typ) && strings.HasSuffix(res.Get(labels.MetricName), "_created") {
if typeRequiresCT(typ) && strings.HasSuffix(res.Get(labels.MetricName), "_created") {
t.Fatalf("we exped created lines skipped")
}
}
Expand Down

0 comments on commit ca18f29

Please sign in to comment.