From 37165a8ddca314fac61f0af30c2c13b0ef9078af Mon Sep 17 00:00:00 2001 From: Kyle McCullough Date: Thu, 20 Sep 2018 10:13:53 -0500 Subject: [PATCH] Add flag to allow disabling Datadog/statsd --- worker.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/worker.go b/worker.go index 3705ac6..574c13e 100644 --- a/worker.go +++ b/worker.go @@ -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, @@ -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.") @@ -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 {