Skip to content

Commit

Permalink
Allow only some custom tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladislav Prskavec committed Jul 8, 2016
1 parent 1c18c01 commit b6868b1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
var routerMetricsKeys = []string{"dyno", "method", "status", "path", "host", "code", "desc", "at"}
var sampleMetricsKeys = []string{"source"}
var scalingMetricsKeys = []string{"mailer", "web"}
var customMetricsKeys = []string{"media_type", "output_type", "route"}

type Client struct {
*statsd.Client
Expand Down Expand Up @@ -176,15 +177,13 @@ func (c *Client) sendScalingMsg(data *logMetrics) {
}
}

func (c *Client) sendMetricsMsg(data *logMetrics) {

func (c *Client) sendMetricsMsg(data *logMetrics) {
tags := *data.tags
for k, v := range data.metrics {
if strings.Index(k, "#") != -1 {
if _, err := strconv.Atoi(v.Val); err != nil {
m := strings.Replace(strings.Split(k, "#")[1], "_", ".", -1)
tags = append(tags, m+":"+v.Val)
}

for _, mk := range customMetricsKeys {
if v, ok := data.metrics[mk]; ok {
tags = append(tags, mk+":"+v.Val)
}
}

Expand Down

0 comments on commit b6868b1

Please sign in to comment.