Skip to content

Commit

Permalink
feat(crons): Add Node SDK cron monitoring docs (#6842)
Browse files Browse the repository at this point in the history
Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed May 8, 2023
1 parent 64db518 commit e68267c
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 4 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 @@ -14,6 +14,7 @@ To set up Sentry Crons, use the links below for supported SDKs or the Sentry CLI
- [Laravel](/platforms/php/guides/laravel/crons/)
- [Python](/platforms/python/crons/)
- [Celery](/platforms/python/guides/celery/crons/)
- [Node](/platforms/node/crons/)

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

Expand Down
7 changes: 7 additions & 0 deletions src/platform-includes/crons/connect-errors/node.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```javascript
Sentry.configureScope(function (scope) {
scope.setContext("monitor", {
slug: "<monitor-slug>",
});
});
```
2 changes: 2 additions & 0 deletions src/platform-includes/crons/requirements/node.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 Node SDK (min v7.51.1) for your recurring job.
- [Create and configure](https://sentry.io/crons/create/) your first Monitor.
55 changes: 55 additions & 0 deletions src/platform-includes/crons/setup/node.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
## 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).

```javascript
// 🟡 Notify Sentry your job is running:
const checkInId = Sentry.captureCheckIn({
monitorSlug: "<monitor-slug>",
status: "in_progress",
});

// Execute your scheduled task here...

// 🟢 Notify Sentry your job has completed successfully:
Sentry.captureCheckIn({
checkInId,
monitorSlug: "<monitor-slug>",
status: "ok",
});
```

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

```javascript
// 🔴 Notify Sentry your job has failed:
Sentry.captureCheckIn({
checkInId,
monitorSlug: "<monitor-slug>",
status: "error",
});
```

## 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.

```javascript
// Execute your scheduled task...

// 🟢 Notify Sentry your job completed successfully:
Sentry.captureCheckIn({
monitorSlug: "<monitor-slug>",
status: "ok",
});
```

If your job execution fails, you can:

```javascript
// 🔴 Notify Sentry your job has failed:
Sentry.captureCheckIn({
monitorSlug: "<monitor-slug>",
status: "error",
});
```
2 changes: 1 addition & 1 deletion src/platform-includes/crons/setup/php.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $event->setCheckIn(new CheckIn(
SentrySdk::getCurrentHub()->captureEvent($event);
```

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

```php
// 🔴 Notify Sentry your job has failed:
Expand Down
3 changes: 3 additions & 0 deletions src/platform-includes/crons/troubleshooting/node.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 Node 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 @@ -4,14 +4,15 @@ sidebar_order: 5000
supported:
- python
- php
- node
description: "Learn how to enable Cron Monitoring in your app"
---

<Include name="beta-alert-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"]}>
<PlatformSection supported={["python", "php", "node"]}>

## Requirements

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

</PlatformSection>

<PlatformSection notSupported={["python", "php"]}>
<PlatformSection notSupported={["python", "php", "node"]}>

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion src/platforms/common/crons/troubleshooting-crons.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ supported:
description: "Learn how to troubleshoot your Cron Monitoring setup."
---

<PlatformSection supported={["python", "php"]}>
<PlatformSection supported={["python", "php", "node"]}>

<PlatformContent includePath="crons/troubleshooting" />

Expand Down

1 comment on commit e68267c

@vercel
Copy link

@vercel vercel bot commented on e68267c May 8, 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
sentry-docs-git-master.sentry.dev
docs.sentry.io

Please sign in to comment.