Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Sort tags for statsd
Browse files Browse the repository at this point in the history
  • Loading branch information
thuningxu committed Mar 13, 2017
1 parent 4d6a0d7 commit 9f3c113
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions common/metrics/statsdreporter.go
Expand Up @@ -127,14 +127,26 @@ func mergeDicts(dic1 map[string]string, dic2 map[string]string) (resultDict map[
return
}

// Cherami's metrics are tagged, but here we need to flatten
// it for statsd. We order tags by: Operation, Destination,
// ConsumerGroup, Hostname
var tagsFlattenOrder = []string{
OperationTagName,
DestinationTagName,
ConsumerGroupTagName,
HostnameTagName,
}

// MetricWithPrefix is the default mapping for metrics to statsd keys.
func metricstoPrefix(name string, tags map[string]string) string {
parts := []string{"cherami", name}
parts := []string{name}

for k := range tags {
v, _ := tags[k]
parts = append(parts, clean(v))
for _, tag := range tagsFlattenOrder {
if v, ok := tags[tag]; ok {
parts = append(parts, clean(v))
}
}

return strings.Join(parts, ".")
}

Expand Down

0 comments on commit 9f3c113

Please sign in to comment.