Skip to content

Commit 0372b65

Browse files
gaprljaffrepaul
andauthored
refactor(crons): add SentryCron decorator documentation (#15682)
## DESCRIBE YOUR PR Moved the SentryCron decorator details to a new include file for better organization. Updated the main guide to reference this new include, ensuring clarity and maintainability of the documentation. Co-authored-by: Paul Jaffre <jaffrepaul@gmail.com>
1 parent 37637ab commit 0372b65

File tree

3 files changed

+53
-33
lines changed

3 files changed

+53
-33
lines changed

docs/platforms/javascript/guides/nestjs/features/sentry-cron-decorator.mdx

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,4 @@ title: SentryCron Decorator
33
description: "Learn about Sentry's SentryCron decorator."
44
---
55

6-
<Alert>
7-
The `@SentryCron` decorator is available from version `@sentry/nestjs` 8.16.0 and up.
8-
</Alert>
9-
10-
The NestJS SDK includes a `@SentryCron` decorator that can be used to augment the native NestJS `@Cron` decorator to
11-
send check-ins to Sentry before and after each cron job run.
12-
13-
To get started, import `SentryCron` from `@sentry/nestjs` and use it to decorate a cron job function in your NestJS application.
14-
15-
<Alert>
16-
The `@SentryCron` decorator needs to be applied after the `@Cron` decorator, or else the instrumentation does not work.
17-
</Alert>
18-
19-
```typescript
20-
import { Cron } from '@nestjs/schedule';
21-
import { SentryCron } from '@sentry/nestjs';
22-
23-
export class MyCronService {
24-
@Cron('* * * * *')
25-
@SentryCron('my-monitor-slug', {
26-
schedule: {
27-
type: "crontab",
28-
value: "* * * * *",
29-
},
30-
checkinMargin: 2, // In minutes. Optional.
31-
maxRuntime: 10, // In minutes. Optional.
32-
timezone: "America/Los_Angeles", // Optional.
33-
})
34-
handleCron() {
35-
// Your cron job logic here
36-
}
37-
}
38-
```
6+
<Include name="nestjs-sentry-cron-decorator.mdx" />
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Alert>
2+
The `@SentryCron` decorator is available from version `@sentry/nestjs` 8.16.0 and up.
3+
</Alert>
4+
5+
The NestJS SDK includes a `@SentryCron` decorator that can be used to augment the native NestJS `@Cron` decorator to send check-ins to Sentry before and after each cron job run.
6+
7+
To get started, import `SentryCron` from `@sentry/nestjs` and use it to decorate a cron job function in your NestJS application.
8+
9+
<Alert>
10+
The `@SentryCron` decorator needs to be applied after the `@Cron` decorator, or else the instrumentation does not work.
11+
</Alert>
12+
13+
```typescript
14+
import { Cron } from '@nestjs/schedule';
15+
import { SentryCron } from '@sentry/nestjs';
16+
17+
export class MyCronService {
18+
@Cron('* * * * *')
19+
@SentryCron('my-monitor-slug', {
20+
schedule: {
21+
type: "crontab",
22+
value: "* * * * *",
23+
},
24+
checkinMargin: 2, // In minutes. Optional.
25+
maxRuntime: 10, // In minutes. Optional.
26+
timezone: "America/Los_Angeles", // Optional.
27+
})
28+
handleCron() {
29+
// Your cron job logic here
30+
}
31+
}
32+
```
33+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Automatic Crons Instrumentation (Recommended)
2+
3+
### NestJS Decorator
4+
5+
<Include name="nestjs-sentry-cron-decorator.mdx" />
6+
7+
<Include name="javascript-crons-automatic-crons-instrumentation.mdx" />
8+
9+
## Job Monitoring
10+
11+
<Include name="javascript-crons-job-monitoring.mdx" />
12+
13+
## Check-Ins
14+
15+
<Include name="javascript-crons-checkins.mdx" />
16+
17+
## Upserting Cron Monitors
18+
19+
<Include name="javascript-crons-upsert.mdx" />

0 commit comments

Comments
 (0)