Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions statsd/datadog_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ func (b *datadogBackend) Set(ctx context.Context, name string, value string, tag
func (b *datadogBackend) Timing(ctx context.Context, name string, value time.Duration, tags []string, rate float64) error {
return b.client.Timing(name, value, tags, rate)
}

func (b *datadogBackend) Flush() error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the method here would not be accessible because only the interface is exported.

Adding the method on the interface would be a breaking change.

Not saying it can't be done, but it's a more complicated change than adding it here.

As an alternative could be to add a method to take in a Client such that one could flush the client directly?

func NewDatadogBackend(endpoint, namespace string, tags []string) (Backend, error) {
	client, err := statsd.New(endpoint)
	if err != nil {
		return nil, err
	}
	client.Tags = tags
	return NewDatadogBackendFromClient(client, namespace)
}

func NewDatadogBackendFromClient(client *statsd.Client, namespace string) (Backend, error) {
	client.Namespace = namespace
	client.Tags = append(defaultTagsFromEnv(), client.Tags...)
	return &datadogBackend{
		client: client,
	}, nil
}

return b.client.Flush()
}