The standard ClientInterface has been updated with a new variadic parameter for metric functions. To support existing code or to specifically use the new functionality (like specifying a Cardinality override when creating a metric), use the ClientInterfaceEx interface.
Access this interface by calling statsd.NewEx(...). Note that ClientInterfaceEx is a temporary measure and will be merged into the main ClientInterface in the next major release.
package main
import (
"log"
"github.com/DataDog/datadog-go/v5/statsd"
)
func main() {
// Use NewEx to get the ClientInterfaceEx which supports the extra parameter
statsd, err := statsd.NewEx("127.0.0.1:8125", WithCardinality(CardinalityHigh))
if err != nil {
log.Fatal(err)
}
// The metric functions now accept an additional Cardinality parameter
statsd.Gauge("gauge", 32, []string{"environment:dev"}, CardinalityLow)
}