Skip to content

Commit

Permalink
Merge pull request #89 from KevinPike/concurrenyInUse-statsd
Browse files Browse the repository at this point in the history
Add statsd metric for concurrencyInUse
  • Loading branch information
afex committed May 2, 2018
2 parents b6b54cf + 0a5b890 commit fa1af6a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugins/statsd_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type StatsdCollector struct {
deadlinePrefix string
totalDurationPrefix string
runDurationPrefix string
concurrencyInUsePrefix string
sampleRate float32
}

Expand Down Expand Up @@ -109,6 +110,7 @@ func (s *StatsdCollectorClient) NewStatsdCollector(name string) metricCollector.
deadlinePrefix: name + ".contextDeadlineExceeded",
totalDurationPrefix: name + ".totalDuration",
runDurationPrefix: name + ".runDuration",
concurrencyInUsePrefix: name + ".concurrencyInUse",
sampleRate: s.sampleRate,
}
}
Expand Down Expand Up @@ -137,6 +139,13 @@ func (g *StatsdCollector) updateTimerMetric(prefix string, dur time.Duration) {
}
}

func (g *StatsdCollector) updateTimingMetric(prefix string, i int64) {
err := g.client.Timing(prefix, i, g.sampleRate)
if err != nil {
log.Printf("Error sending statsd metrics %s", prefix)
}
}

func (g *StatsdCollector) Update(r metricCollector.MetricResult) {
if r.Successes > 0 {
g.setGauge(g.circuitOpenPrefix, 0)
Expand All @@ -157,6 +166,7 @@ func (g *StatsdCollector) Update(r metricCollector.MetricResult) {
g.incrementCounterMetric(g.deadlinePrefix, r.ContextDeadlineExceeded)
g.updateTimerMetric(g.totalDurationPrefix, r.TotalDuration)
g.updateTimerMetric(g.runDurationPrefix, r.RunDuration)
g.updateTimingMetric(g.concurrencyInUsePrefix, int64(100*r.ConcurrencyInUse))
}

// Reset is a noop operation in this collector.
Expand Down

0 comments on commit fa1af6a

Please sign in to comment.