From 0fddfd1ba530c954dc042c5d138de82ecd4e4ff1 Mon Sep 17 00:00:00 2001 From: mknapphrt <39998367+mknapphrt@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:46:38 -0500 Subject: [PATCH] Cache metricsfamily help text (#3175) Signed-off-by: Mark Knapp --- collector/textfile.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/collector/textfile.go b/collector/textfile.go index 134083af..3e0cc459 100644 --- a/collector/textfile.go +++ b/collector/textfile.go @@ -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 } }