-
Notifications
You must be signed in to change notification settings - Fork 65
Description
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
documentationlabel if this issue is related to documentation changes.
To Reproduce
Steps to reproduce the behavior:
- Follow the code example for Go located on https://docs.datadoghq.com/api/latest/usage-metering/?code-lang=go
- Execute the code in a debug and inspect the returned resp object.
- 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
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.