Skip to content

Commit

Permalink
Cache metricsfamily help text
Browse files Browse the repository at this point in the history
  • Loading branch information
mknapphrt committed Nov 7, 2024
1 parent 07ee8ef commit 92575a3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions collector/textfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,16 @@ func (c *textFileCollector) Update(ch chan<- prometheus.Metric) error {
}
}

mfHelp := make(map[string]*string)
for _, mf := range parsedFamilies {
if mf.Help == nil {
if help, ok := mfHelp[*mf.Name]; ok {
mf.Help = help
continue
}
help := fmt.Sprintf("Metric read from %s", strings.Join(metricsNamesToFiles[*mf.Name], ", "))
mf.Help = &help
mfHelp[*mf.Name] = &help
}
}

Expand Down

0 comments on commit 92575a3

Please sign in to comment.