Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions metrics/datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
13 changes: 13 additions & 0 deletions metrics/datadog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}