MCPcopy
hub / github.com/prometheus/prometheus / AddToLabels

Method AddToLabels

schema/labels.go:105–115  ·  view source on GitHub ↗

AddToLabels adds metric schema metadata as labels into the labels.ScratchBuilder. Empty Metadata fields will be ignored (not added).

(b *labels.ScratchBuilder)

Source from the content-addressed store, hash-verified

103// AddToLabels adds metric schema metadata as labels into the labels.ScratchBuilder.
104// Empty Metadata fields will be ignored (not added).
105func (m Metadata) AddToLabels(b *labels.ScratchBuilder) {
106 if m.Name != "" {
107 b.Add(model.MetricNameLabel, m.Name)
108 }
109 if !m.IsTypeEmpty() {
110 b.Add(model.MetricTypeLabel, string(m.Type))
111 }
112 if m.Unit != "" {
113 b.Add(model.MetricUnitLabel, m.Unit)
114 }
115}
116
117// SetToLabels injects metric schema metadata as labels into the labels.Builder.
118// It follows the labels.Builder.Set semantics, so empty Metadata fields will

Callers 7

LabelsMethod · 0.95
LabelsMethod · 0.95
appendV2Method · 0.80
TestMetadataFunction · 0.80

Calls 2

IsTypeEmptyMethod · 0.95
AddMethod · 0.65