Skip to content

Commit

Permalink
Remove _info suffix.
Browse files Browse the repository at this point in the history
  • Loading branch information
constanca-m committed Sep 25, 2023
1 parent b7b76eb commit 4a2c943
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions metricbeat/helper/prometheus/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ cc_seconds_created 123.456`
info :=
`# TYPE info_metric info
# HELP info_metric help
info_metric{foo="bar"} 1 2`
info_metric_info{foo="bar"} 1 2`
infoMetricFamily := MetricFamily{
Name: stringp("info_metric"),
Help: stringp("help"),
Expand All @@ -1256,7 +1256,7 @@ info_metric{foo="bar"} 1 2`
Value: "bar",
},
},
Name: stringp("info_metric"),
Name: stringp("info_metric_info"),
Info: &Info{
Value: int64p(1),
},
Expand Down
7 changes: 5 additions & 2 deletions metricbeat/helper/prometheus/textparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ const (
suffixSum = "_sum"
suffixBucket = "_bucket"
suffixCreated = "_created"
suffixInfo = "_info"
)

// Counters have _total suffix
Expand Down Expand Up @@ -604,7 +605,8 @@ func ParseMetricFamilies(b []byte, contentType string, ts time.Time) ([]*MetricF
value := int64(v)
var info = &Info{Value: &value}
metric = &OpenMetric{Name: &metricName, Info: info, Label: labelPairs}
lookupMetricName = metricName
// remove the _info suffix
lookupMetricName = strings.TrimSuffix(metricName, suffixInfo)
case textparse.MetricTypeSummary:
lookupMetricName, metric = summaryMetricName(metricName, v, qv, lbls.String(), summariesByName)
metric.Label = labelPairs
Expand Down Expand Up @@ -654,7 +656,8 @@ func ParseMetricFamilies(b []byte, contentType string, ts time.Time) ([]*MetricF

fam, ok = metricFamiliesByName[lookupMetricName]
if !ok {
fam = &MetricFamily{Type: mt}
// If the family metric does not exist, create a new one with the lookup name
fam = &MetricFamily{Name: &lookupMetricName, Type: mt}
metricFamiliesByName[lookupMetricName] = fam
}

Expand Down

0 comments on commit 4a2c943

Please sign in to comment.