mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: generate more human-friendly result in TagFilters.String
This commit is contained in:
parent
819bb36852
commit
f055dbefda
1 changed files with 18 additions and 7 deletions
|
@ -76,9 +76,15 @@ func (tfs *TagFilters) Add(key, value []byte, isNegative, isRegexp bool) error {
|
||||||
func (tfs *TagFilters) String() string {
|
func (tfs *TagFilters) String() string {
|
||||||
var bb bytes.Buffer
|
var bb bytes.Buffer
|
||||||
fmt.Fprintf(&bb, "AccountID=%d, ProjectID=%d ", tfs.accountID, tfs.projectID)
|
fmt.Fprintf(&bb, "AccountID=%d, ProjectID=%d ", tfs.accountID, tfs.projectID)
|
||||||
for i := range tfs.tfs {
|
if len(tfs.tfs) == 0 {
|
||||||
|
fmt.Fprintf(&bb, "{}")
|
||||||
|
return bb.String()
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&bb, "{%s", tfs.tfs[0].String())
|
||||||
|
for i := range tfs.tfs[1:] {
|
||||||
fmt.Fprintf(&bb, ", %s", tfs.tfs[i].String())
|
fmt.Fprintf(&bb, ", %s", tfs.tfs[i].String())
|
||||||
}
|
}
|
||||||
|
fmt.Fprintf(&bb, "}")
|
||||||
return bb.String()
|
return bb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,11 +127,16 @@ type tagFilter struct {
|
||||||
|
|
||||||
// String returns human-readable tf value.
|
// String returns human-readable tf value.
|
||||||
func (tf *tagFilter) String() string {
|
func (tf *tagFilter) String() string {
|
||||||
var bb bytes.Buffer
|
op := "="
|
||||||
fmt.Fprintf(&bb, "[isNegative=%v, isRegexp=%v, prefix=%q", tf.isNegative, tf.isRegexp, tf.prefix)
|
if tf.isNegative {
|
||||||
fmt.Fprintf(&bb, ", orSuffixes=%v, reSuffixMatch=%p", tf.orSuffixes, tf.reSuffixMatch)
|
op = "!="
|
||||||
fmt.Fprintf(&bb, "]")
|
if tf.isRegexp {
|
||||||
return bb.String()
|
op = "!~"
|
||||||
|
}
|
||||||
|
} else if tf.isRegexp {
|
||||||
|
op = "=~"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s%s%q", tf.key, op, tf.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tf *tagFilter) Marshal(dst []byte, accountID, projectID uint32) []byte {
|
func (tf *tagFilter) Marshal(dst []byte, accountID, projectID uint32) []byte {
|
||||||
|
|
Loading…
Reference in a new issue