Open
Description
When the statsd client is created with a non-empty address but without ports. For example localhost
instead of localhost:8125
it should rely on DD_DOGSTATSD_PORT to set the port properly. However the code has a bug where populating the variable containing the result of this envar is never used.
In the code here: https://github.com/DataDog/datadog-go/blob/master/statsd/statsd.go#L310-L344
envPort := ""
if addr == "" {
addr = os.Getenv(agentHostEnvVarName)
envPort = os.Getenv(agentPortEnvVarName)
agentURL, _ := os.LookupEnv(agentURLEnvVarName)
agentURL = parseAgentURL(agentURL)
// agentURLEnvVarName has priority over agentHostEnvVarName
if agentURL != "" {
return agentURL
}
}
envPort is only set within this if statement, later on it is used like so:
if envPort != "" {
addr = fmt.Sprintf("%s:%s", addr, envPort)
} else {
addr = fmt.Sprintf("%s:%s", addr, defaultUDPPort)
}
which means that the else statement will be called always if the addr was not empty
Metadata
Metadata
Assignees
Labels
No labels