Use Datadog tracer environment variables to setup default config

This commit is contained in:
Gian Ortiz 2021-01-06 13:08:03 -03:00 committed by GitHub
parent a3327c4430
commit 759d17547a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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.