Skip to content

Commit

Permalink
Disabled DataDog queries for future dates. (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-kc authored Mar 30, 2024
1 parent 172348d commit 0080906
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions datadog/cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ func (d *DatadogCostSource) GetCustomCosts(req *pb.CustomCostRequest) []*pb.Cust
}

for _, target := range targets {
// DataDog gets mad if we ask them to tell the future
if target.Start().After(time.Now().UTC()) {
log.Debugf("skipping future window %v", target)
continue
}

log.Debugf("fetching DD costs for window %v", target)
result := d.getDDCostsForWindow(target, listPricing)
results = append(results, result)
Expand Down
18 changes: 18 additions & 0 deletions datadog/tests/datadog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ func TestDDCostRetrievalListCost(t *testing.T) {
}
}

func TestFuturism(t *testing.T) {
// query for the future
windowStart := time.Now().UTC().Truncate(time.Hour).Add(time.Hour)
windowEnd := windowStart.Add(time.Hour)

response := getResponse(t, windowStart, windowEnd, time.Hour)

// when we query for data in the future, we expect to get back no data AND no errors
if len(response) > 0 {
t.Fatalf("got non-empty response")
}
for _, resp := range response {
if len(resp.Errors) > 0 {
t.Fatalf("got errors in response: %v", resp.Errors)
}
}
}

func TestDDCostRetrievalBilledCost(t *testing.T) {
// query for qty 2 of 1 hour windows
windowStart := time.Date(2024, 3, 16, 0, 0, 0, 0, time.UTC)
Expand Down

0 comments on commit 0080906

Please sign in to comment.