Skip to content

Commit bb9ce72

Browse files
Improve the accuracy of duration calculations in cron jobs monitoring (#2471)
* Update monitor_check_ins.rb * Update CHANGELOG.md --------- Co-authored-by: Peter Solnica <peter@solnica.online>
1 parent d21c500 commit bb9ce72

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Add support for string errors in error reporter ([#2464](https://github.com/getsentry/sentry-ruby/pull/2464))
1717
- Reset `trace_id` and add root transaction for sidekiq-cron [#2446](https://github.com/getsentry/sentry-ruby/pull/2446)
1818
- Add support for Excon HTTP client instrumentation ([#2383](https://github.com/getsentry/sentry-ruby/pull/2383))
19+
- Improve the accuracy of duration calculations in cron jobs monitoring ([#2471](https://github.com/getsentry/sentry-ruby/pull/2471))
1920

2021
Note: MemoryStore and FileStore require Rails 8.0+
2122

sentry-ruby/lib/sentry/cron/monitor_check_ins.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ def perform(*args, **opts)
1414
:in_progress,
1515
monitor_config: monitor_config)
1616

17-
start = Sentry.utc_now.to_i
17+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
1818

1919
begin
2020
# need to do this on ruby <= 2.6 sadly
2121
ret = method(:perform).super_method.arity == 0 ? super() : super
22-
duration = Sentry.utc_now.to_i - start
22+
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
2323

2424
Sentry.capture_check_in(slug,
2525
:ok,
@@ -29,7 +29,7 @@ def perform(*args, **opts)
2929

3030
ret
3131
rescue Exception
32-
duration = Sentry.utc_now.to_i - start
32+
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
3333

3434
Sentry.capture_check_in(slug,
3535
:error,

0 commit comments

Comments
 (0)