-
Notifications
You must be signed in to change notification settings - Fork 455
/
matchers.go
44 lines (35 loc) · 1.05 KB
/
matchers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: AGPL-3.0-only
// Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/pkg/util/matchers.go
// Provenance-includes-license: Apache-2.0
// Provenance-includes-copyright: The Cortex Authors.
package util
import (
"strings"
"github.com/prometheus/prometheus/model/labels"
)
// MultiMatchersStringer implements Stringer for a slice of slices of Prometheus matchers. Useful for logging.
type MultiMatchersStringer [][]*labels.Matcher
func (s MultiMatchersStringer) String() string {
var b strings.Builder
for _, multi := range s {
if b.Len() > 0 {
b.WriteByte(',')
}
b.WriteByte('{')
b.WriteString(MatchersStringer(multi).String())
b.WriteByte('}')
}
return b.String()
}
// MatchersStringer implements Stringer for a slice of Prometheus matchers. Useful for logging.
type MatchersStringer []*labels.Matcher
func (s MatchersStringer) String() string {
var b strings.Builder
for _, m := range s {
if b.Len() > 0 {
b.WriteByte(',')
}
b.WriteString(m.String())
}
return b.String()
}