Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the accuracy of duration calculations in cron jobs monitoring #2471

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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+

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
Loading