From 04bba78d61778bf7fd35dfba82f425321a0f09ed Mon Sep 17 00:00:00 2001 From: Clayton O'Neill Date: Mon, 13 May 2019 14:30:38 -0400 Subject: [PATCH] Add support for Datadog distribution type This adds the ability to accept Datadog's distribution type and treat it like a histogram/summary. Signed-off-by: Clayton O'Neill --- README.md | 2 ++ bridge_test.go | 20 ++++++++++++++++++++ exporter.go | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 46dfe95..cb8dc48 100644 --- a/README.md +++ b/README.md @@ -224,6 +224,8 @@ mappings: job: "${1}_server" ``` +Note that timers will be accepted with the `ms`, `h`, and `d` statsd types. The first two are timers and histograms and the `d` type is for DataDog's "distribution" type. The distribution type is treated identically to timers and histograms. + ### Regular expression matching Another capability when using YAML configuration is the ability to define matches diff --git a/bridge_test.go b/bridge_test.go index 33d4716..688d7bd 100644 --- a/bridge_test.go +++ b/bridge_test.go @@ -67,6 +67,26 @@ func TestHandlePacket(t *testing.T) { labels: map[string]string{}, }, }, + }, { + name: "simple histogram", + in: "foo:200|h", + out: Events{ + &TimerEvent{ + metricName: "foo", + value: 200, + labels: map[string]string{}, + }, + }, + }, { + name: "simple distribution", + in: "foo:200|d", + out: Events{ + &TimerEvent{ + metricName: "foo", + value: 200, + labels: map[string]string{}, + }, + }, }, { name: "datadog tag extension", in: "foo:100|c|#tag1:bar,tag2:baz", diff --git a/exporter.go b/exporter.go index d62a4bb..829ab33 100644 --- a/exporter.go +++ b/exporter.go @@ -571,7 +571,7 @@ func buildEvent(statType, metric string, value float64, relative bool, labels ma relative: relative, labels: labels, }, nil - case "ms", "h": + case "ms", "h", "d": return &TimerEvent{ metricName: metric, value: float64(value),