Skip to content

Commit

Permalink
[APM Datadog] return 429 specific error (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianlop authored Dec 15, 2021
1 parent 6d4de1f commit 16b121b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## UNRELEASED

BUG FIXES:
* plugins/apm/datadog: Log the correct rate limit error message [[GH-552](https://github.com/hashicorp/nomad-autoscaler/pull/552)]
* plugins/target/nomad: Reload status handlers on SIGHUP [[GH-554](https://github.com/hashicorp/nomad-autoscaler/pull/554)]
* policy: Fixed an issue that could cause a panic if the policy content is not read in time [[GH-551](https://github.com/hashicorp/nomad-autoscaler/pull/551)]

Expand Down
11 changes: 5 additions & 6 deletions plugins/builtin/apm/datadog/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,14 @@ func (a *APMPlugin) QueryMultiple(q string, r sdk.TimeRange) ([]sdk.TimestampedM
Query(q).
Execute()
if err != nil {
if res.StatusCode == http.StatusTooManyRequests {
return nil,
fmt.Errorf("metric queries are ratelimited in current time period by datadog, resets in %s sec",
res.Header.Get(ratelimitResetHdr))
}
return nil, fmt.Errorf("error querying metrics from datadog: %v", err)
}

if res.StatusCode == http.StatusTooManyRequests {
return nil,
fmt.Errorf("metric queries are ratelimited in current time period by datadog, resets in %s sec",
res.Header.Get(ratelimitResetHdr))
}

series := queryResult.GetSeries()
if len(series) == 0 {
a.logger.Warn("empty time series response from datadog, try a wider query window")
Expand Down

0 comments on commit 16b121b

Please sign in to comment.