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 ( import (
"io" "io"
"net"
"os"
"strings" "strings"
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
@ -27,10 +29,17 @@ type Config struct {
// SetDefaults sets the default values. // SetDefaults sets the default values.
func (c *Config) SetDefaults() { func (c *Config) SetDefaults() {
c.LocalAgentHostPort = "localhost:8126" host, ok := os.LookupEnv("DD_AGENT_HOST")
c.GlobalTag = "" if !ok {
c.Debug = false host = "localhost"
c.PrioritySampling = false }
port, ok := os.LookupEnv("DD_TRACE_AGENT_PORT")
if !ok {
port = "8126"
}
c.LocalAgentHostPort = net.JoinHostPort(host, port)
} }
// Setup sets up the tracer. // Setup sets up the tracer.