Skip to content

api.GetUsageTopAvgMetrics does not parse response properly #3560

@jgulick48

Description

@jgulick48

Describe the bug
A clear and concise description of what the bug is.

When calling api.GetUsageTopAvgMetrics the returned struct does not parse the Metadata data properly. The Metadata is in the raw response and under UnparsedObject but in the returned struct all the Metadata fields are null.

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:

  1. Follow the code example for Go located on https://docs.datadoghq.com/api/latest/usage-metering/?code-lang=go
  2. Execute the code in a debug and inspect the returned resp object.
  3. Under Metadata all fields will be null and under Unparsed Object, the relevant data will be there.

Expected behavior
Metadata object should be parsed properly.

Screenshots
Code used in my local testing.

func (c *client) GetMetricsUsagePage(ctx context.Context, nextPage string) (UsageTopAvgMetricsResponse, error) { ddctx := c.getAuthContext(ctx) api := datadogV1.NewUsageMeteringApi(c.ddClient) options := datadogV1.NewGetUsageTopAvgMetricsOptionalParameters().WithDay(time.Now().AddDate(0, 0, -2)).WithLimit(5000) if nextPage != "" { options = options.WithNextRecordId(nextPage) } apiResp, r, err := api.GetUsageTopAvgMetrics(ddctx, *options) if err != nil { return UsageTopAvgMetricsResponse{}, err } if metadata, ok := apiResp.Metadata.GetPaginationOk(); ok { lo.G(ctx).Infof("Next Page is: %s", metadata.NextRecordId) } defer r.Body.Close() resp := UsageTopAvgMetricsResponse{} if err := json.NewDecoder(r.Body).Decode(&resp); err != nil { return UsageTopAvgMetricsResponse{}, err } waitForRateLimit(ddctx, r) return resp, nil

Image

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

github.com/DataDog/datadog-api-client-go/v2 v2.52.0
go version go1.25.5 darwin/arm64

Additional context
Add any other context about the problem here.

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