Skip to content

Commit

Permalink
Use milliseconds in v2 calls to datadog
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com>
  • Loading branch information
alexef committed May 11, 2023
1 parent 5eed95b commit 861c38c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions metricproviders/datadog/datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ func (p *Provider) createRequest(query string, apiVersion string, now int64, int
Data: datadogQuery{
QueryType: "timeseries_request",
Attributes: datadogQueryAttributes{
From: now - interval,
To: now,
From: (now - interval) * 1000,
To: now * 1000,
Queries: []map[string]string{{
"data_source": "metrics",
"query": query,
Expand Down
8 changes: 4 additions & 4 deletions metricproviders/datadog/datadogV2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ func TestRunSuiteV2(t *testing.T) {
t.Errorf("\nquery expected avg:kubernetes.cpu.user.total{*} but got %s", actualQuery)
}

if actualFrom != unixNow()-test.expectedIntervalSeconds {
t.Errorf("\nfrom %d expected be equal to %d", actualFrom, unixNow()-test.expectedIntervalSeconds)
if actualFrom != (unixNow()-test.expectedIntervalSeconds)*1000 {
t.Errorf("\nfrom %d expected be equal to %d", actualFrom, (unixNow()-test.expectedIntervalSeconds)*1000)
} else if err != nil {
t.Errorf("\nfailed to parse from: %v", err)
}

if actualTo != unixNow() {
t.Errorf("\nto %d was expected be equal to %d", actualTo, unixNow())
if actualTo != unixNow()*1000 {
t.Errorf("\nto %d was expected be equal to %d", actualTo, unixNow()*1000)
} else if err != nil {
t.Errorf("\nfailed to parse to: %v", err)
}
Expand Down

0 comments on commit 861c38c

Please sign in to comment.