Skip to content

Commit

Permalink
Fix statsd tags (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
cszatmary authored Jun 2, 2022
1 parent 07a90af commit 384cded
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
setup:
# Only install if missing
ifeq (,$(wildcard bin/golangci-lint))
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.46.2
endif

go mod download
Expand Down
4 changes: 4 additions & 0 deletions awsecs/awsecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ func updateTaskDef(ctx context.Context, taskDefARN, gitsha, updateStrategy strin
dockerTags := newTaskInput.ContainerDefinitions[0].DockerLabels
tags := make([]string, 0, len(dockerTags))
for tag, value := range dockerTags {
// Ignore the special Datadog label that is used for logs
if tag == "com.datadoghq.ad.logs" {
continue
}
newTag := fmt.Sprintf("%s:%s", tag, value)
tags = append(tags, newTag)
}
Expand Down
15 changes: 10 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,16 @@ func main() {
}

if ddAgentHost, ok := os.LookupEnv("DD_AGENT_HOST"); ok {
client, err := statsd.New(ddAgentHost, statsd.Option(func(o *statsd.Options) error {
// Try creating an unbuffered client to see if completed events show up
o.MaxMessagesPerPayload = 1
return nil
}))
client, err := statsd.New(
ddAgentHost,
// Set global tags to be included in all events/metrics
statsd.WithTags([]string{"source:gehen"}),
statsd.Option(func(o *statsd.Options) error {
// Try creating an unbuffered client to see if completed events show up
o.MaxMessagesPerPayload = 1
return nil
}),
)
if err != nil {
fatal.ExitErr(err, "Could not create StatsD agent (DD_AGENT_HOST may not be set)")
}
Expand Down

0 comments on commit 384cded

Please sign in to comment.