summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/armon/go-metrics/circonus/circonus.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/armon/go-metrics/circonus/circonus.go')
-rw-r--r--vendor/github.com/armon/go-metrics/circonus/circonus.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/armon/go-metrics/circonus/circonus.go b/vendor/github.com/armon/go-metrics/circonus/circonus.go
index c6e3974b5..eb41b9945 100644
--- a/vendor/github.com/armon/go-metrics/circonus/circonus.go
+++ b/vendor/github.com/armon/go-metrics/circonus/circonus.go
@@ -5,6 +5,7 @@ package circonus
import (
"strings"
+ "github.com/armon/go-metrics"
cgm "github.com/circonus-labs/circonus-gometrics"
)
@@ -61,6 +62,12 @@ func (s *CirconusSink) SetGauge(key []string, val float32) {
s.metrics.SetGauge(flatKey, int64(val))
}
+// SetGaugeWithLabels sets value for a gauge metric with the given labels
+func (s *CirconusSink) SetGaugeWithLabels(key []string, val float32, labels []metrics.Label) {
+ flatKey := s.flattenKeyLabels(key, labels)
+ s.metrics.SetGauge(flatKey, int64(val))
+}
+
// EmitKey is not implemented in circonus
func (s *CirconusSink) EmitKey(key []string, val float32) {
// NOP
@@ -72,12 +79,24 @@ func (s *CirconusSink) IncrCounter(key []string, val float32) {
s.metrics.IncrementByValue(flatKey, uint64(val))
}
+// IncrCounterWithLabels increments a counter metric with the given labels
+func (s *CirconusSink) IncrCounterWithLabels(key []string, val float32, labels []metrics.Label) {
+ flatKey := s.flattenKeyLabels(key, labels)
+ s.metrics.IncrementByValue(flatKey, uint64(val))
+}
+
// AddSample adds a sample to a histogram metric
func (s *CirconusSink) AddSample(key []string, val float32) {
flatKey := s.flattenKey(key)
s.metrics.RecordValue(flatKey, float64(val))
}
+// AddSampleWithLabels adds a sample to a histogram metric with the given labels
+func (s *CirconusSink) AddSampleWithLabels(key []string, val float32, labels []metrics.Label) {
+ flatKey := s.flattenKeyLabels(key, labels)
+ s.metrics.RecordValue(flatKey, float64(val))
+}
+
// Flattens key to Circonus metric name
func (s *CirconusSink) flattenKey(parts []string) string {
joined := strings.Join(parts, "`")
@@ -90,3 +109,11 @@ func (s *CirconusSink) flattenKey(parts []string) string {
}
}, joined)
}
+
+// Flattens the key along with labels for formatting, removes spaces
+func (s *CirconusSink) flattenKeyLabels(parts []string, labels []metrics.Label) string {
+ for _, label := range labels {
+ parts = append(parts, label.Value)
+ }
+ return s.flattenKey(parts)
+}