Skip to content

Commit

Permalink
Represent bytes only as B
Browse files Browse the repository at this point in the history
  • Loading branch information
jeschkies committed Nov 20, 2023
1 parent eaac0fb commit 259a4d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions pkg/logql/log/label_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"strconv"
"strings"
"time"
"unicode"

"github.com/dustin/go-humanize"
"github.com/prometheus/prometheus/model/labels"
Expand Down Expand Up @@ -214,13 +213,7 @@ func (d *BytesLabelFilter) RequiredLabelNames() []string {
}

func (d *BytesLabelFilter) String() string {
b := strings.Map(func(r rune) rune {
if unicode.IsSpace(r) {
return -1
}
return r
}, humanize.Bytes(d.Value)) // TODO: discuss whether this should just be bytes, B, to be more accurate.
return fmt.Sprintf("%s%s%s", d.Name, d.Type, b)
return fmt.Sprintf("%s%s%dB", d.Name, d.Type, d.Value)
}

type DurationLabelFilter struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/logql/syntax/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,7 @@ var ParseTestCases = []struct {
MultiStages: MultiStageExpr{
newLabelParserExpr(OpParserTypeJSON, ""),
&LabelFilterExpr{
LabelFilterer: log.NewBytesLabelFilter(log.LabelFilterGreaterThanOrEqual, "size", 2_748_779_070),
LabelFilterer: log.NewBytesLabelFilter(log.LabelFilterGreaterThanOrEqual, "size", 2_748_779_069),
},
},
},
Expand Down

0 comments on commit 259a4d5

Please sign in to comment.