Skip to content

Inconsistent resultset when using the UsageMeteringAPI #3526

@paniko0

Description

@paniko0

Describe the bug

Using the UsageMeteringAPI, when fetching all events of the month, one of the product families return inconsistent results: error_tracking.

Label the issue properly.

  • Add severity/ label.
  • Add documentation label if this issue is related to documentation changes.

To Reproduce
Steps to reproduce the behavior:

package main

import (
    "context"
    "fmt"
    "os"

    "github.com/DataDog/datadog-api-client-go/v2/api/datadog"
    "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    now := time.Now().UTC()
    startDate = time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, time.UTC)
    endDate = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC)

    body := *datadogV2.NewUserCreateRequest(*datadogV2.NewUserCreateData(*datadogV2.NewUserCreateAttributes("jane.doe@example.com"), datadogV2.UsersType("users")))

    configuration := datadog.NewConfiguration()
    configuration.RetryConfiguration.EnableRetry = true
	configuration.RetryConfiguration.MaxRetries = 3
	configuration.RetryConfiguration.BackOffMultiplier = 2
	configuration.RetryConfiguration.BackOffBase = 2 // seconds

    apiClient := datadog.NewAPIClient(configuration)
    usageMeteringAPI := datadogV2.NewUsageMeteringApi(apiClient)

    response, httpResponse, err := usageMeteringAPI.GetHourlyUsage(
			datadogClient.GetContext(ctx),
			start,
			"all",
			*datadogV2.NewGetHourlyUsageOptionalParameters().WithFilterTimestampEnd(end),
	)

    fmt.Fprintf(os.Stdout, "len %s", len(response.Data))
}

Run the script twice.

Expected behavior

The number of usages are the same. However, the number of error tracking usages are different depending on the run.

Environment and Versions (please complete the following information):
A clear and precise description of your setup:

  • datadog-api-client-go/v2 v2.47.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugBug related issuestaleStale - Bot reminder

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions