Skip to content

Unexpected double count when using Count with datadog-go/v5 statsd client #337

Description

@masumluf

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions