From 759d17547a11dd62cdf96189c61ffacedae1b0da Mon Sep 17 00:00:00 2001 From: Gian Ortiz Date: Wed, 6 Jan 2021 13:08:03 -0300 Subject: [PATCH] Use Datadog tracer environment variables to setup default config --- pkg/tracing/datadog/datadog.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/tracing/datadog/datadog.go b/pkg/tracing/datadog/datadog.go index a64f81b4a..12c86c018 100644 --- a/pkg/tracing/datadog/datadog.go +++ b/pkg/tracing/datadog/datadog.go @@ -2,6 +2,8 @@ package datadog import ( "io" + "net" + "os" "strings" "github.com/opentracing/opentracing-go" @@ -27,10 +29,17 @@ type Config struct { // SetDefaults sets the default values. func (c *Config) SetDefaults() { - c.LocalAgentHostPort = "localhost:8126" - c.GlobalTag = "" - c.Debug = false - c.PrioritySampling = false + host, ok := os.LookupEnv("DD_AGENT_HOST") + if !ok { + host = "localhost" + } + + port, ok := os.LookupEnv("DD_TRACE_AGENT_PORT") + if !ok { + port = "8126" + } + + c.LocalAgentHostPort = net.JoinHostPort(host, port) } // Setup sets up the tracer.