From 3dd715043d630ed67670f400514674c69dea1f6a Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Thu, 23 May 2019 11:49:35 -0700 Subject: [PATCH] Allow initializing the datadog statsd sink from an existing client The client initialization for the datadog statsd sink allows for more complex initialization options than the ones that are exposed. For example, you can use buffered writer for performance reasons. --- datadog/dogstatsd.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/datadog/dogstatsd.go b/datadog/dogstatsd.go index fe021d0..802fd98 100644 --- a/datadog/dogstatsd.go +++ b/datadog/dogstatsd.go @@ -22,12 +22,17 @@ func NewDogStatsdSink(addr string, hostName string) (*DogStatsdSink, error) { if err != nil { return nil, err } + return NewDogStatsdSinkFromClient(client, hostName), nil +} + +// NewDogStatsdSinkFromClient is used to create a new DogStatsdSink with an existing datadog-statsd client +func NewDogStatsdSinkFromClient(client *statsd.Client, hostName string) *DogStatsdSink { sink := &DogStatsdSink{ client: client, hostName: hostName, propagateHostname: false, } - return sink, nil + return sink } // SetTags sets common tags on the Dogstatsd Client that will be sent