honeycombio / libhoney-go

Go library for sending data to Honeycomb
Apache License 2.0
58 stars 40 forks source link

Making statsd dependency optional #123

Closed jsha closed 3 years ago

jsha commented 3 years ago

Hi! We're looking at instrumenting github.com/letsencrypt/boulder/ with Honeycomb. We try to rigorously minimize our dependencies, and I noticed that libhoney-go depends on statsd, but as I understand it our planned deployment won't need to use statsd. Is it possible to make the statsd dependency optional?

Relatedly, looking at the code, it says:

// default is a mute statsd; intended to be overridden
var sd, _ = statsd.New(statsd.Mute(true), statsd.Prefix("libhoney"))

But I don't actually see a mechanism to override it. Perhaps the statsd dependency can be removed entirely?

MikeGoldsmith commented 3 years ago

Hey @jsha - thanks for creating the issue.

I don't believe it's possible to create optional dependencies without creating sub-modules that share common functionality and then add the extra dependencies. That is not planned at the moment.

Regarding creating a new statsd instance, you can provide an alternative statsd instance when creating the honeycomb transmission like this:

sd, _ = statsd.New(...)
t := &transmission.Honeycomb{
    ...
    Metrics:              sd,
    ...
}