promql/parser: simplify BinaryExpr label formatting

Signed-off-by: ADITYA TIWARI <adityatiwari342005@gmail.com>
This commit is contained in:
ADITYA TIWARI 2025-12-15 13:39:15 +00:00
parent 301b9eff44
commit 3a82dcc6c5

View file

@ -155,11 +155,7 @@ func (node *BinaryExpr) getMatchingStr() string {
if vm.On {
vmTag = "on"
}
// Format labels with proper UTF-8 quoting using writeLabels()
b.Reset()
b.WriteString(" ")
b.WriteString(vmTag)
b.WriteString(" (")
b.WriteString(" " + vmTag + " (")
writeLabels(&b, vm.MatchingLabels)
b.WriteString(")")
matching = b.String()
@ -170,11 +166,8 @@ func (node *BinaryExpr) getMatchingStr() string {
if vm.Card == CardManyToOne {
vmCard = "left"
}
// Format labels with proper UTF-8 quoting using writeLabels()
b.Reset()
b.WriteString(" group_")
b.WriteString(vmCard)
b.WriteString(" (")
b.WriteString(" group_" + vmCard + " (")
writeLabels(&b, vm.Include)
b.WriteString(")")
matching += b.String()