Skip to content

Commit

Permalink
feat(crons): Add ruby docs (#8166)
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Oct 10, 2023
1 parent 6dd3a43 commit 1ee6b8f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/docs/product/crons/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

<Alert level="note" title="Don't see your platform?">

Expand Down
2 changes: 2 additions & 0 deletions src/platform-includes/crons/requirements/ruby.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Use our <PlatformLink to="/">getting started</PlatformLink> 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.
73 changes: 73 additions & 0 deletions src/platform-includes/crons/setup/ruby.mdx
Original file line number Diff line number Diff line change
@@ -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('<monitor-slug>', :in_progress)
# Execute your scheduled task here...
Sentry.capture_check_in('<monitor-slug>', :ok, check_in_id: check_in_id)
```

If your job execution fails, you can notify Sentry about the failure:

```ruby
Sentry.capture_check_in('<monitor-slug>', :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('<monitor-slug>', :ok)
```

If your job execution fails, you can notify Sentry about the failure:

```ruby
Sentry.capture_check_in('<monitor-slug>', :error)
```
3 changes: 3 additions & 0 deletions src/platform-includes/crons/troubleshooting/ruby.mdx
Original file line number Diff line number Diff line change
@@ -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).
5 changes: 3 additions & 2 deletions src/platforms/common/crons/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ supported:
- javascript.sveltekit
- javascript.remix
- go
- ruby
description: "Learn how to enable Cron Monitoring in your app"
---

<Include name="feature-stage-beta-crons.mdx" />

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.

<PlatformSection supported={["python", "php", "node", "javascript.nextjs", "javascript.sveltekit", "javascript.remix", "go", "java"]}>
<PlatformSection supported={["python", "php", "node", "javascript.nextjs", "javascript.sveltekit", "javascript.remix", "go", "java", "ruby"]}>

## Requirements

Expand All @@ -37,7 +38,7 @@ To link any exceptions captured during your job's lifecycle, use <PlatformLink t

</PlatformSection>

<PlatformSection notSupported={["python", "php", "node", "javascript.nextjs", "javascript.sveltekit", "javascript.remix", "go", "java"]}>
<PlatformSection notSupported={["python", "php", "node", "javascript.nextjs", "javascript.sveltekit", "javascript.remix", "go", "java", "ruby"]}>

## Requirements

Expand Down
4 changes: 3 additions & 1 deletion src/platforms/common/crons/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ supported:
- javascript.nextjs
- javascript.sveltekit
- javascript.remix
- ruby
description: "Learn how to troubleshoot your Cron Monitoring setup."
---

Expand All @@ -20,7 +21,8 @@ description: "Learn how to troubleshoot your Cron Monitoring setup."
"java",
"javascript.nextjs",
"javascript.sveltekit",
"javascript.remix"
"javascript.remix",
"ruby"
]}
>

Expand Down

1 comment on commit 1ee6b8f

@vercel
Copy link

@vercel vercel bot commented on 1ee6b8f Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs.sentry.dev
docs.sentry.io
sentry-docs-git-master.sentry.dev

Please sign in to comment.