MCPcopy
hub / github.com/prometheus/prometheus / Merge

Method Merge

util/annotations/annotations.go:58–75  ·  view source on GitHub ↗

Merge adds the contents of the second set of Annotations to the first, modifying the first in-place, and returns the merged first Annotations for convenience.

(aa Annotations)

Source from the content-addressed store, hash-verified

56// Merge adds the contents of the second set of Annotations to the first, modifying
57// the first in-place, and returns the merged first Annotations for convenience.
58func (a *Annotations) Merge(aa Annotations) Annotations {
59 if *a == nil {
60 if aa == nil {
61 return nil
62 }
63 *a = Annotations{}
64 }
65 for key, val := range aa {
66 if prevVal, exists := (*a)[key]; exists {
67 var anErr annoError
68 if errors.As(val, &anErr) {
69 val = anErr.Merge(prevVal)
70 }
71 }
72 (*a)[key] = val
73 }
74 return *a
75}
76
77// AsErrors is a convenience function to return the annotations map as a slice
78// of errors.

Callers 13

ErrSearchResultSetFunction · 0.95
mergeResultsMethod · 0.95
WarningsMethod · 0.95
NextMethod · 0.95
WarningsMethod · 0.95
rangeEvalMethod · 0.95
rangeEvalAggMethod · 0.95
evalMethod · 0.95
extrapolatedRateFunction · 0.95
funcHistogramQuantileFunction · 0.95

Calls 1

MergeMethod · 0.95

Tested by 1

WarningsMethod · 0.76