MCPcopy
hub / github.com/prometheus/pushgateway / MetricFamiliesMap

Function MetricFamiliesMap

testutil/metric_families.go:26–40  ·  view source on GitHub ↗

MetricFamiliesMap creates the map needed in the MetricFamilies field of a WriteRequest from the provided reference metric families. While doing so, it creates deep copies of the metric families so that modifications that might happen during processing of the WriteRequest will not affect the referenc

(mfs ...*dto.MetricFamily)

Source from the content-addressed store, hash-verified

24// happen during processing of the WriteRequest will not affect the reference
25// metric families.
26func MetricFamiliesMap(mfs ...*dto.MetricFamily) map[string]*dto.MetricFamily {
27 m := map[string]*dto.MetricFamily{}
28 for _, mf := range mfs {
29 buf, err := proto.Marshal(mf)
30 if err != nil {
31 panic(err)
32 }
33 mfCopy := &dto.MetricFamily{}
34 if err := proto.Unmarshal(buf, mfCopy); err != nil {
35 panic(err)
36 }
37 m[mf.GetName()] = mfCopy
38 }
39 return m
40}

Callers 8

TestNoPersistenceFunction · 0.92
TestRejectTimestampsFunction · 0.92
TestSanitizeLabelsFunction · 0.92
TestReplaceFunction · 0.92
TestGetMetricFamiliesMapFunction · 0.92
TestMetricsAPIFunction · 0.92

Calls

no outgoing calls

Tested by 8

TestNoPersistenceFunction · 0.74
TestRejectTimestampsFunction · 0.74
TestSanitizeLabelsFunction · 0.74
TestReplaceFunction · 0.74
TestGetMetricFamiliesMapFunction · 0.74
TestMetricsAPIFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…