gocollector: Attach original runtime/metrics metric name to help. (#1… · prometheus/client_golang@7ce5089 (original) (raw)

Original file line number Diff line number Diff line change
@@ -205,6 +205,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
205 205 // to fail here. This condition is tested in TestExpectedRuntimeMetrics.
206 206 continue
207 207 }
208 +help := attachOriginalName(d.Description.Description, d.Name)
208 209
209 210 sampleBuf = append(sampleBuf, metrics.Sample{Name: d.Name})
210 211 sampleMap[d.Name] = &sampleBuf[len(sampleBuf)-1]
@@ -216,7 +217,7 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
216 217 m = newBatchHistogram(
217 218 NewDesc(
218 219 BuildFQName(namespace, subsystem, name),
219 -d.Description.Description,
220 +help,
220 221 nil,
221 222 nil,
222 223 ),
@@ -228,15 +229,15 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
228 229 Namespace: namespace,
229 230 Subsystem: subsystem,
230 231 Name: name,
231 -Help: d.Description.Description,
232 +Help: help,
232 233 },
233 234 )
234 235 } else {
235 236 m = NewGauge(GaugeOpts{
236 237 Namespace: namespace,
237 238 Subsystem: subsystem,
238 239 Name: name,
239 -Help: d.Description.Description,
240 +Help: help,
240 241 })
241 242 }
242 243 metricSet = append(metricSet, m)
@@ -286,6 +287,10 @@ func NewGoCollector(opts ...func(o *internal.GoCollectorOptions)) Collector {
286 287 }
287 288 }
288 289
290 +func attachOriginalName(desc, origName string) string {
291 +return fmt.Sprintf("%s Sourced from %s", desc, origName)
292 +}
293 +
289 294 // Describe returns all descriptions of the collector.
290 295 func (c *goCollector) Describe(ch chan<- *Desc) {
291 296 c.base.Describe(ch)