mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Sort labelnames for federation.
This makes unittests with multiple labels possible, and may be needed for performance with the new ingestion text parser.
This commit is contained in:
parent
dbb65846f1
commit
d42e01b07c
|
@ -85,7 +85,16 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
||||||
Untyped: &dto.Untyped{},
|
Untyped: &dto.Untyped{},
|
||||||
}
|
}
|
||||||
|
|
||||||
for ln, lv := range s.Metric {
|
// Sort labelnames for unittest consistency.
|
||||||
|
labelnames := make([]string, 0, len(s.Metric))
|
||||||
|
for ln := range s.Metric {
|
||||||
|
labelnames = append(labelnames, string(ln))
|
||||||
|
}
|
||||||
|
sort.Strings(labelnames)
|
||||||
|
|
||||||
|
for _, labelname := range labelnames {
|
||||||
|
ln := model.LabelName(labelname)
|
||||||
|
lv := s.Metric[ln]
|
||||||
if lv == "" {
|
if lv == "" {
|
||||||
// No value means unset. Never consider those labels.
|
// No value means unset. Never consider those labels.
|
||||||
// This is also important to protect against nameless metrics.
|
// This is also important to protect against nameless metrics.
|
||||||
|
|
Loading…
Reference in a new issue