From 267c6d3926d125d291b69c57b4543623b804954b Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Tue, 23 May 2023 15:58:40 +0200 Subject: [PATCH] Prettify output --- pkg/expr/functions/legendValue/function.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/expr/functions/legendValue/function.go b/pkg/expr/functions/legendValue/function.go index d9f06fad..84e2a5d3 100644 --- a/pkg/expr/functions/legendValue/function.go +++ b/pkg/expr/functions/legendValue/function.go @@ -3,6 +3,7 @@ package legendValue import ( "context" "fmt" + "strings" "github.com/bookingcom/carbonapi/pkg/expr/helper" "github.com/bookingcom/carbonapi/pkg/expr/interfaces" @@ -54,7 +55,7 @@ func (f *legendValue) Do(ctx context.Context, e parser.Expr, from, until int32, var results []*types.MetricData for _, a := range arg { - r := *a + var values []string for _, method := range methods { summaryVal, _, err := helper.SummarizeValues(method, a.Values) if err != nil { @@ -72,9 +73,11 @@ func (f *legendValue) Do(ctx context.Context, e parser.Expr, from, until int32, } else { return nil, fmt.Errorf("%s is not supported for system", system) } - r.Name = fmt.Sprintf("%s (%s: %s)", r.Name, method, summary) + values = append(values, fmt.Sprintf("%s: %s", method, summary) } - + + r := *a + r.Name = fmt.Sprintf("%s (%s)", r.Name, strings.Join(values, ", ")) results = append(results, &r) } return results, nil