8000 [BUG] Statsd defaults to 8125 port even when the DD_DOGSTATSD_PORT is set (when addr is not empty) · Issue #317 · DataDog/datadog-go · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[BUG] Statsd defaults to 8125 port even when the DD_DOGSTATSD_PORT is set (when addr is not empty) #317
Open
@MrBlaise

Description

@MrBlaise

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0