Skip to content

Add flag to allow disabling Datadog/statsd #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 12 additions & 8 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ type Worker struct {
s3Concurrency int

// Other Flags.
datadogHost string
statsdPrefix string
datadogEnabled bool
datadogHost string
statsdPrefix string
}

// Init is designed to be called only once. This function initialized the context of the application,
Expand Down Expand Up @@ -143,6 +144,7 @@ func (w *Worker) Init() {
"Kafka topic used to store uploaded S3 files.")

// Define other flags.
flag.BoolVar(&w.datadogEnabled, "datadog", true, "Enable sending metrics to Statsd/Datadog")
flag.StringVar(&w.datadogHost, "datadog-host",
flagutil.EnvOrDefault("DATADOG_HOST", "localhost:2585"),
"The host where the datadog agents listens to.")
Expand Down Expand Up @@ -243,13 +245,15 @@ func (w *Worker) Init() {
DefaultBufferConfig: bufferConfig,
})

// Setup datadog metrics client.
metrics, err = statsd.New(w.datadogHost)
if err != nil {
glog.Fatal(err)
if w.datadogEnabled {
// Setup datadog metrics client.
metrics, err = statsd.New(w.datadogHost)
if err != nil {
glog.Fatal(err)
}
metrics.Namespace = fmt.Sprintf("%s.", w.statsdPrefix)
glog.Infof("created datadog client host=%s", w.datadogHost)
}
metrics.Namespace = fmt.Sprintf("%s.", w.statsdPrefix)
glog.Infof("created datadog client host=%s", w.datadogHost)

// Setup Cloud Providers.
if w.s3enabled {
Expand Down