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)
| 24 | // happen during processing of the WriteRequest will not affect the reference |
| 25 | // metric families. |
| 26 | func 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 | } |
no outgoing calls
searching dependent graphs…