Skip to content

Commit

Permalink
fix: fix tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mroyme committed Aug 15, 2024
1 parent b7af3dd commit fc18f4a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion cmd/dogstatsd-local/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ func main() {
debug := flag.Bool("debug", false, "Enable debug mode")
flag.Parse()

extraTags := strings.Split(*rawTags, ",")
var extraTags []string
if *rawTags != "" {
extraTags = strings.Split(*rawTags, ",")
}
logger := getLogger(*debug)

var formatHandler format.Handler
Expand Down
6 changes: 1 addition & 5 deletions internal/format/pretty/pretty.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,5 @@ func (h *Handler) StyledTags(metric messages.DogStatsDMetric, extraTags []string
style := lipgloss.NewStyle().
Foreground(h.Theme.Overlay0()).
Italic(true)
var tags []string
for _, tag := range append(extraTags, metric.Tags...) {
tags = append(tags, strings.TrimSpace(tag))
}
return style.SetString(tags...).Render()
return style.SetString(append(extraTags, metric.Tags...)...).Render()
}
3 changes: 3 additions & 0 deletions internal/messages/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ func parseDogStatsDMetricMessage(buf []byte) (DogStatsDMessage, error) {

if strings.HasPrefix(piece, "#") {
tags := strings.Split(piece[1:], ",")
for i, _ := range tags {
tags[i] = strings.TrimSpace(tags[i])
}
metric.Tags = append(metric.Tags, tags...)
continue
}
Expand Down

0 comments on commit fc18f4a

Please sign in to comment.