From 1ee6b8ff63844efa2ba8e314639435e352e575db Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Tue, 10 Oct 2023 17:25:21 +0200 Subject: [PATCH] feat(crons): Add ruby docs (#8166) --- .../product/crons/getting-started/index.mdx | 1 + .../crons/requirements/ruby.mdx | 2 + src/platform-includes/crons/setup/ruby.mdx | 73 +++++++++++++++++++ .../crons/troubleshooting/ruby.mdx | 3 + src/platforms/common/crons/index.mdx | 5 +- .../common/crons/troubleshooting.mdx | 4 +- 6 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 src/platform-includes/crons/requirements/ruby.mdx create mode 100644 src/platform-includes/crons/setup/ruby.mdx create mode 100644 src/platform-includes/crons/troubleshooting/ruby.mdx diff --git a/src/docs/product/crons/getting-started/index.mdx b/src/docs/product/crons/getting-started/index.mdx index b79c7dd1a2f64..3641fbf8f6cec 100644 --- a/src/docs/product/crons/getting-started/index.mdx +++ b/src/docs/product/crons/getting-started/index.mdx @@ -21,6 +21,7 @@ To set up Sentry Crons, use the links below for supported SDKs or the Sentry CLI - [Go](/platforms/go/crons/) - [Java](/platforms/java/crons/) - [Spring Boot](/platforms/java/guides/spring-boot/crons/) +- [Ruby](/platforms/ruby/crons/) diff --git a/src/platform-includes/crons/requirements/ruby.mdx b/src/platform-includes/crons/requirements/ruby.mdx new file mode 100644 index 0000000000000..7064e94d4c4ac --- /dev/null +++ b/src/platform-includes/crons/requirements/ruby.mdx @@ -0,0 +1,2 @@ +- Use our getting started guide to install and configure the Sentry Ruby SDK (min v5.12.0) for your recurring job. +- [Create and configure](https://sentry.io/crons/create/) your first Monitor. diff --git a/src/platform-includes/crons/setup/ruby.mdx b/src/platform-includes/crons/setup/ruby.mdx new file mode 100644 index 0000000000000..215674b751638 --- /dev/null +++ b/src/platform-includes/crons/setup/ruby.mdx @@ -0,0 +1,73 @@ +## Job Monitoring + +Standard job frameworks such as `ActiveJob` and `Sidekiq` with a `perform` method can use the `Sentry::Cron::MonitorCheckIns` mixin module to automatically capture check-ins. + +```rb {tabTitle: ActiveJob} +class ExampleJob < ApplicationJob + include Sentry::Cron::MonitorCheckIns + + sentry_monitor_check_ins + + def perform(*args) + # do stuff + end +end +``` + +```rb {tabTitle: Sidekiq} +class SidekiqJob + include Sidekiq::Job + include Sentry::Cron::MonitorCheckIns + + sentry_monitor_check_ins + + def perform(*args) + # do stuff + end +end +``` + +You can pass in optional attributes to `sentry_monitor_check_ins` as follows. + +```rb +# slug defaults to the job class name +sentry_monitor_check_ins slug: 'custom_slug' + +# define the monitor config with an interval +sentry_monitor_check_ins monitor_config: Sentry::Cron::MonitorConfig.from_interval(1, :minute) + +# define the monitor config with a crontab +sentry_monitor_check_ins monitor_config: Sentry::Cron::MonitorConfig.from_crontab('5 * * * *') +``` + +## Manual Setup + +### Check-Ins (Recommended) + +Check-in monitoring allows you to track a job's progress by completing two check-ins: one at the start of your job and another at the end of your job. This two-step process allows Sentry to notify you if your job didn't start when expected (missed) or if it exceeded its maximum runtime (failed). + +```ruby +check_in_id = Sentry.capture_check_in('', :in_progress) +# Execute your scheduled task here... +Sentry.capture_check_in('', :ok, check_in_id: check_in_id) +``` + +If your job execution fails, you can notify Sentry about the failure: + +```ruby +Sentry.capture_check_in('', :error, check_in_id: check_in_id) +``` + +### Heartbeat + +Heartbeat monitoring notifies Sentry of a job's status through one check-in. This setup will only notify you if your job didn't start when expected (missed). If you need to track a job to see if it exceeded its maximum runtime (failed), use check-ins instead. + +```ruby +Sentry.capture_check_in('', :ok) +``` + +If your job execution fails, you can notify Sentry about the failure: + +```ruby +Sentry.capture_check_in('', :error) +``` diff --git a/src/platform-includes/crons/troubleshooting/ruby.mdx b/src/platform-includes/crons/troubleshooting/ruby.mdx new file mode 100644 index 0000000000000..2dda2fc0c314c --- /dev/null +++ b/src/platform-includes/crons/troubleshooting/ruby.mdx @@ -0,0 +1,3 @@ +### How Do I Send an Attachment With a Check-in (Such as a Log Output)? + +Attachments aren't supported by our Ruby SDK yet. For now, you can use the [check-in attachments API](/product/crons/getting-started/http/#check-in-attachment-optional). diff --git a/src/platforms/common/crons/index.mdx b/src/platforms/common/crons/index.mdx index babd39cfa21c2..c656f1369f3b6 100644 --- a/src/platforms/common/crons/index.mdx +++ b/src/platforms/common/crons/index.mdx @@ -10,6 +10,7 @@ supported: - javascript.sveltekit - javascript.remix - go + - ruby description: "Learn how to enable Cron Monitoring in your app" --- @@ -17,7 +18,7 @@ description: "Learn how to enable Cron Monitoring in your app" Sentry Crons allows you to monitor the uptime and performance of any scheduled, recurring job. Once implemented, it'll allow you to get alerts and metrics to help you solve errors, detect timeouts, and prevent disruptions to your service. - + ## Requirements @@ -37,7 +38,7 @@ To link any exceptions captured during your job's lifecycle, use - + ## Requirements diff --git a/src/platforms/common/crons/troubleshooting.mdx b/src/platforms/common/crons/troubleshooting.mdx index a350a0cc314ba..480fefd5b64fd 100644 --- a/src/platforms/common/crons/troubleshooting.mdx +++ b/src/platforms/common/crons/troubleshooting.mdx @@ -9,6 +9,7 @@ supported: - javascript.nextjs - javascript.sveltekit - javascript.remix + - ruby description: "Learn how to troubleshoot your Cron Monitoring setup." --- @@ -20,7 +21,8 @@ description: "Learn how to troubleshoot your Cron Monitoring setup." "java", "javascript.nextjs", "javascript.sveltekit", - "javascript.remix" + "javascript.remix", + "ruby" ]} >