Skip to content

Commit

Permalink
Cache metricsfamily help text (#3175)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Knapp <[email protected]>
  • Loading branch information
mknapphrt authored Nov 7, 2024
1 parent 07ee8ef commit 0fddfd1
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 0fddfd1

Please sign in to comment.