Skip to content

Commit

Permalink
Add Dogstatsd metrics for both duplicate and blank events.
Browse files Browse the repository at this point in the history
  • Loading branch information
darron committed Nov 29, 2015
1 parent ccc134a commit cf69446
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
26 changes: 26 additions & 0 deletions commands/dogstatsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,29 @@ func StatsdRunTime(start time.Time, exec string, watchType string, watchId strin
statsd.Gauge(metricName, float64(milliseconds), tags)
}
}

func StatsdDuplicate(watchType string, watchId string) {
if DogStatsd {
statsd, _ := godspeed.NewDefault()
defer statsd.Conn.Close()
tags := make([]string, 2)
watchTypeTag := fmt.Sprintf("watchtype:%s", watchType)
watchIdTag := fmt.Sprintf("watchid:%s", watchId)
tags = append(tags, watchTypeTag)
tags = append(tags, watchIdTag)
metricName := fmt.Sprintf("%s.duplicate", MetricPrefix)
statsd.Incr(metricName, tags)
}
}

func StatsdBlank(watchType string) {
if DogStatsd {
statsd, _ := godspeed.NewDefault()
defer statsd.Conn.Close()
tags := make([]string, 1)
watchTypeTag := fmt.Sprintf("watchtype:%s", watchType)
tags = append(tags, watchTypeTag)
metricName := fmt.Sprintf("%s.blank", MetricPrefix)
statsd.Incr(metricName, tags)
}
}
4 changes: 2 additions & 2 deletions commands/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func startEvent(cmd *cobra.Command, args []string) {
StatsdRunTime(start, Exec, "event", EventName, strconv.FormatInt(lTime, 10))
} else {
RunTime(start, "duplicate", fmt.Sprintf("watch='event' exec='%s' ltime='%d'", Exec, lTime))
StatsdDuplicate("event", EventName)
}

} else {
RunTime(start, "blank", fmt.Sprintf("watch='event' exec='%s'", Exec))
StatsdBlank("event")
}

}

func checkEventFlags() {
Expand Down
2 changes: 2 additions & 0 deletions commands/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ func startKey(cmd *cobra.Command, args []string) {
StatsdRunTime(start, Exec, "key", d.getKey(), shaValue)
} else {
RunTime(start, "duplicate", fmt.Sprintf("watch='key' exec='%s' sha='%s'", Exec, shaValue))
StatsdDuplicate("key", d.getKey())
}
} else {
RunTime(start, "blank", fmt.Sprintf("watch='key' exec='%s'", Exec))
StatsdBlank("key")
}
}

Expand Down

0 comments on commit cf69446

Please sign in to comment.