DataDog / dd-trace-go

Datadog Go Library including APM tracing, profiling, and security monitoring.
https://docs.datadoghq.com/tracing/
Other
674 stars 438 forks source link

Add WithStatsdClient StartOption for tracer #2766

Open brahimyacine opened 5 months ago

brahimyacine commented 5 months ago

I need to pass a custom statsdClient (to have freedom of configuration in order to reduce the memory footprint) to the tracer, but I realise that this is not possible, and I'll have to make do with the one created at this level with the default values. By doing a little research in the repo, I discovered that the option i am looking for does exist but only for test purposes and it's not exported. Is there a reason for this?

func withStatsdClient(s globalinternal.StatsdClient) StartOption {
    return func(c *config) {
        c.statsdClient = s
    }
}
felixge commented 4 months ago

Thanks for reporting this and sorry for the delay.

Could you share a bit more on the memory footprint issues you're facing and how you'd like to configure your statsd client to mitigate them?

Generally speaking, we're not opposed to the idea of allowing you to inject your own statsd client. But it does create some challenges:

  1. If we use an interface type for accepting the client, we can't add new methods to this interface in the future without breaking existing users.
  2. If we use a concrete type for the client, we'll have to provide one injection method for every major version of the statsd library (currently at v5).

So I'd like to learn more about your use case before considering any of these options.