diff --git a/CHANGELOG.md b/CHANGELOG.md index 49d11bda1..4e7bc0aed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Add support for string errors in error reporter ([#2464](https://github.com/getsentry/sentry-ruby/pull/2464)) - Reset trace_id and add root transaction for sidekiq-cron [#2446](https://github.com/getsentry/sentry-ruby/pull/2446) - Add support for Excon HTTP client instrumentation ([#2383](https://github.com/getsentry/sentry-ruby/pull/2383)) +- Improve the accuracy of duration calculations in cron jobs monitoring ([#2471](https://github.com/getsentry/sentry-ruby/pull/2471)) Note: MemoryStore and FileStore require Rails 8.0+ diff --git a/sentry-ruby/lib/sentry/cron/monitor_check_ins.rb b/sentry-ruby/lib/sentry/cron/monitor_check_ins.rb index 835ae84ad..314733cfb 100644 --- a/sentry-ruby/lib/sentry/cron/monitor_check_ins.rb +++ b/sentry-ruby/lib/sentry/cron/monitor_check_ins.rb @@ -14,12 +14,12 @@ def perform(*args, **opts) :in_progress, monitor_config: monitor_config) - start = Sentry.utc_now.to_i + start = Process.clock_gettime(Process::CLOCK_MONOTONIC) begin # need to do this on ruby <= 2.6 sadly ret = method(:perform).super_method.arity == 0 ? super() : super - duration = Sentry.utc_now.to_i - start + duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start Sentry.capture_check_in(slug, :ok, @@ -29,7 +29,7 @@ def perform(*args, **opts) ret rescue Exception - duration = Sentry.utc_now.to_i - start + duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start Sentry.capture_check_in(slug, :error,