Skip to content

Commit cf69446

Browse files
committed
Add Dogstatsd metrics for both duplicate and blank events.
1 parent ccc134a commit cf69446

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

commands/dogstatsd.go

+26
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,29 @@ func StatsdRunTime(start time.Time, exec string, watchType string, watchId strin
3131
statsd.Gauge(metricName, float64(milliseconds), tags)
3232
}
3333
}
34+
35+
func StatsdDuplicate(watchType string, watchId string) {
36+
if DogStatsd {
37+
statsd, _ := godspeed.NewDefault()
38+
defer statsd.Conn.Close()
39+
tags := make([]string, 2)
40+
watchTypeTag := fmt.Sprintf("watchtype:%s", watchType)
41+
watchIdTag := fmt.Sprintf("watchid:%s", watchId)
42+
tags = append(tags, watchTypeTag)
43+
tags = append(tags, watchIdTag)
44+
metricName := fmt.Sprintf("%s.duplicate", MetricPrefix)
45+
statsd.Incr(metricName, tags)
46+
}
47+
}
48+
49+
func StatsdBlank(watchType string) {
50+
if DogStatsd {
51+
statsd, _ := godspeed.NewDefault()
52+
defer statsd.Conn.Close()
53+
tags := make([]string, 1)
54+
watchTypeTag := fmt.Sprintf("watchtype:%s", watchType)
55+
tags = append(tags, watchTypeTag)
56+
metricName := fmt.Sprintf("%s.blank", MetricPrefix)
57+
statsd.Incr(metricName, tags)
58+
}
59+
}

commands/event.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ func startEvent(cmd *cobra.Command, args []string) {
4444
StatsdRunTime(start, Exec, "event", EventName, strconv.FormatInt(lTime, 10))
4545
} else {
4646
RunTime(start, "duplicate", fmt.Sprintf("watch='event' exec='%s' ltime='%d'", Exec, lTime))
47+
StatsdDuplicate("event", EventName)
4748
}
48-
4949
} else {
5050
RunTime(start, "blank", fmt.Sprintf("watch='event' exec='%s'", Exec))
51+
StatsdBlank("event")
5152
}
52-
5353
}
5454

5555
func checkEventFlags() {

commands/key.go

+2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ func startKey(cmd *cobra.Command, args []string) {
4040
StatsdRunTime(start, Exec, "key", d.getKey(), shaValue)
4141
} else {
4242
RunTime(start, "duplicate", fmt.Sprintf("watch='key' exec='%s' sha='%s'", Exec, shaValue))
43+
StatsdDuplicate("key", d.getKey())
4344
}
4445
} else {
4546
RunTime(start, "blank", fmt.Sprintf("watch='key' exec='%s'", Exec))
47+
StatsdBlank("key")
4648
}
4749
}
4850

0 commit comments

Comments
 (0)