Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit b6868b1

Browse files
author
Ladislav Prskavec
committed
Allow only some custom tags
1 parent 1c18c01 commit b6868b1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

client.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
var routerMetricsKeys = []string{"dyno", "method", "status", "path", "host", "code", "desc", "at"}
2121
var sampleMetricsKeys = []string{"source"}
2222
var scalingMetricsKeys = []string{"mailer", "web"}
23+
var customMetricsKeys = []string{"media_type", "output_type", "route"}
2324

2425
type Client struct {
2526
*statsd.Client
@@ -176,15 +177,13 @@ func (c *Client) sendScalingMsg(data *logMetrics) {
176177
}
177178
}
178179

179-
func (c *Client) sendMetricsMsg(data *logMetrics) {
180180

181+
func (c *Client) sendMetricsMsg(data *logMetrics) {
181182
tags := *data.tags
182-
for k, v := range data.metrics {
183-
if strings.Index(k, "#") != -1 {
184-
if _, err := strconv.Atoi(v.Val); err != nil {
185-
m := strings.Replace(strings.Split(k, "#")[1], "_", ".", -1)
186-
tags = append(tags, m+":"+v.Val)
187-
}
183+
184+
for _, mk := range customMetricsKeys {
185+
if v, ok := data.metrics[mk]; ok {
186+
tags = append(tags, mk+":"+v.Val)
188187
}
189188
}
190189

0 commit comments

Comments
 (0)