Closed abhinav closed 2 months ago
Today, statsd client that use DD_AGENT_HOST for their address cannot be cloned:
// export DD_AGENT_HOST=localhost:8125 client, err := statsd.New("") if err != nil { log.Fatal(err) } cloned, err := statsd.CloneWithExtraOptions(client, /* ... */) fmt.Println(err) // can't clone client with no addrOption
This is because we resolve the address in createWriter, but do not record the resolved address in the client.
func New(addr string, options ...Option) (*Client, error) { // ... ... := createWriter(addr, /* ... */) // resolves addr internally // ... client.addrOption = addr // addr is old, unresolved value }
This commit fixes this issue by replacing the address with the resolved value so that that's what we record on the client, allowing it to be cloned.
Testing: Includes a regression test for the bug.
Resolves #313
Today, statsd client that use DD_AGENT_HOST for their address cannot be cloned:
This is because we resolve the address in createWriter, but do not record the resolved address in the client.
This commit fixes this issue by replacing the address with the resolved value so that that's what we record on the client, allowing it to be cloned.
Testing: Includes a regression test for the bug.
Resolves #313