MCPcopy
hub / github.com/prometheus/client_golang / collectGoMetrics

Function collectGoMetrics

prometheus/go_collector_latest_test.go:233–259  ·  view source on GitHub ↗
(t *testing.T, opts internal.GoCollectorOptions)

Source from the content-addressed store, hash-verified

231}
232
233func collectGoMetrics(t *testing.T, opts internal.GoCollectorOptions) []Metric {
234 t.Helper()
235
236 c := NewGoCollector(func(o *internal.GoCollectorOptions) {
237 o.DisableMemStatsLikeMetrics = opts.DisableMemStatsLikeMetrics
238 o.RuntimeMetricSumForHist = opts.RuntimeMetricSumForHist
239 o.RuntimeMetricRules = opts.RuntimeMetricRules
240 }).(*goCollector)
241
242 // Collect all metrics.
243 ch := make(chan Metric)
244 var wg sync.WaitGroup
245 var metrics []Metric
246 wg.Add(1)
247 go func() {
248 defer wg.Done()
249 for metric := range ch {
250 metrics = append(metrics, metric)
251 }
252 }()
253 c.Collect(ch)
254 close(ch)
255
256 wg.Wait()
257
258 return metrics
259}
260
261func TestMemStatsEquivalence(t *testing.T) {
262 var msReal, msFake runtime.MemStats

Callers 3

TestBatchHistogramFunction · 0.85

Calls 4

WaitMethod · 0.80
NewGoCollectorFunction · 0.70
AddMethod · 0.65
CollectMethod · 0.65

Tested by

no test coverage detected