I’m using github.com/DataDog/datadog-go/v5/statsd to send Count metrics to Datadog. However, I’m seeing twice the count I expect.
Code to Reproduce
main.go
package main
import (
"log"
"time"
"github.com/DataDog/datadog-go/v5/statsd"
)
func main() {
statsd, err := statsd.New("127.0.0.1:8125")
if err != nil {
log.Fatal(err)
}
for i := 1; i <= 10; i++ {
statsd.Count("example_metric.count", 1, []string{"environment:dev"}, 1)
log.Printf("Sent metric %d", i)
time.Sleep(1 * time.Second)
}
}
Expected Behavior
I expect to see a count of 10 in Datadog after sending 10 metrics.
Actual Behavior
Instead, I see a count of 20.
The logs show the loop only runs 10 times.
But in Datadog, the count doubles.