Skip to content

Commit

Permalink
Improve the accuracy of duration calculations in cron jobs monitoring (
Browse files Browse the repository at this point in the history
…#2471)

* Update monitor_check_ins.rb
* Update CHANGELOG.md

---------

Co-authored-by: Peter Solnica <peter@solnica.online>
  • Loading branch information
krzysztofjablonski and solnic authored Dec 19, 2024
1 parent d21c500 commit bb9ce72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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+

Expand Down
6 changes: 3 additions & 3 deletions sentry-ruby/lib/sentry/cron/monitor_check_ins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit bb9ce72

Please sign in to comment.