diff --git a/CHANGELOG.md b/CHANGELOG.md index 18392a6..b4d4c06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +- Add unreleased items here. + +## [1.2.0] - 2018-03-01 + - Update build to test with Go 1.9, drop support for 1.7 since `dep` now requires Go 1.8+. Go 1.7 users can still use this library but must manage their own dependencies. - Add `WithRate(rate float)` to the DataDog client to limit traffic sent to the `dogstatsd` daemon. The set rate will be applied to all calls made with the returned `Client`. +- Automatically assign tags to events. ## [1.1.0] - 2017-08-01 diff --git a/metrics/datadog.go b/metrics/datadog.go index f4b1764..1efe4b4 100644 --- a/metrics/datadog.go +++ b/metrics/datadog.go @@ -79,6 +79,10 @@ func (c *DataDogClient) Gauge(name string, value float64) { // Event tracks an event that may be relevant to other metrics. func (c *DataDogClient) Event(e *statsd.Event) { + if len(c.tagMap) > 0 { + e.Tags = append(e.Tags, c.tagsList()...) + } + c.client.Event(e) } diff --git a/metrics/datadog_test.go b/metrics/datadog_test.go index f6b581e..0face6f 100644 --- a/metrics/datadog_test.go +++ b/metrics/datadog_test.go @@ -63,4 +63,17 @@ func TestDataDogClient(t *testing.T) { if !reflect.DeepEqual(actual, expected) { t.Fatalf("Expected %v to equal %v", actual, expected) } + + // Events should get tags assigned automatically. + e := &statsd.Event{ + Title: "Test event", + } + + datadog.WithTags(map[string]string{ + "tag1": "value1", + }).Event(e) + + if !reflect.DeepEqual(e.Tags, []string{"tag1:value1"}) { + t.Fatalf("Expected event to have tags '[tag1:value1]'. Found '%v'", e.Tags) + } }