Skip to content

Commit

Permalink
Prettify output
Browse files Browse the repository at this point in the history
  • Loading branch information
spacefreak86 committed Sep 6, 2023
1 parent de88ba8 commit 267c6d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/expr/functions/legendValue/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package legendValue
import (
"context"
"fmt"
"strings"

"github.com/bookingcom/carbonapi/pkg/expr/helper"
"github.com/bookingcom/carbonapi/pkg/expr/interfaces"
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 267c6d3

Please sign in to comment.