Skip to content

Commit 952d25b

Browse files
committed
chore: reduce maximum datadog lookup to two hours, since we are discarding redis slowlogs older than an hour anyways.
1 parent 3f45234 commit 952d25b

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/slowlog_check.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ def status_or_error(resp)
2929
return resp
3030
end
3131

32-
# TODO: Rather than hard code a day lookback,
33-
# look back at an increasing increment until hitting some max value
34-
def last_datadog_metrics_submitted_by_me_in_the_last_day
32+
def last_datadog_metrics_submitted_by_me_in_the_last_2_hours
3533
resp = @ddog.get_points(
3634
"#{@metricname}.95percentile{replication_group:#{replication_group}}",
37-
Time.now - 86400,
35+
Time.now - 7200,
3836
Time.now
3937
)
4038

@@ -49,7 +47,7 @@ def minute_precision(time)
4947
end
5048

5149
def last_datadog_metric
52-
series = last_datadog_metrics_submitted_by_me_in_the_last_day[1].fetch("series")
50+
series = last_datadog_metrics_submitted_by_me_in_the_last_2_hours[1].fetch("series")
5351
if series == [] # First invocation
5452
return minute_precision(Time.now - 3600)
5553
else

spec/slowlog_check_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def redis_slowlog(index, time, microseconds, command='eval')
4949
# ddog mock
5050
allow(ddog).to receive(:get_points).with(
5151
'rspec.redis.slowlog.micros.95percentile{replication_group:replicationgroup}',
52-
Time.now - 86400,
52+
Time.now - 7200,
5353
Time.now
5454
) {
5555
[

0 commit comments

Comments
 (0)