Skip to content

Commit ce1e7c7

Browse files
authored
docs(nestjs): Update README to include SentryCron (#12972)
SentryCron was missing from the nest readme
1 parent d70182e commit ce1e7c7

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

packages/nestjs/README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ yarn add @sentry/nestjs
2424

2525
## Usage
2626

27-
```js
27+
```typescript
2828
// CJS Syntax
2929
const Sentry = require('@sentry/nestjs');
3030
// ESM Syntax
@@ -38,12 +38,12 @@ Sentry.init({
3838

3939
Note that it is necessary to initialize Sentry **before you import any package that may be instrumented by us**.
4040

41-
## Span Decorator
41+
## SentryTraced
4242

43-
Use the @SentryTraced() decorator to gain additional performance insights for any function within your NestJS
43+
Use the `@SentryTraced()` decorator to gain additional performance insights for any function within your NestJS
4444
applications.
4545

46-
```js
46+
```typescript
4747
import { Injectable } from '@nestjs/common';
4848
import { SentryTraced } from '@sentry/nestjs';
4949

@@ -56,6 +56,35 @@ export class ExampleService {
5656
}
5757
```
5858

59+
## SentryCron
60+
61+
Use the `@SentryCron()` decorator to augment the native NestJS `@Cron` decorator to send check-ins to Sentry before and
62+
after each cron job run.
63+
64+
```typescript
65+
import { Cron } from '@nestjs/schedule';
66+
import { SentryCron, MonitorConfig } from '@sentry/nestjs';
67+
import type { MonitorConfig } from '@sentry/types';
68+
69+
const monitorConfig: MonitorConfig = {
70+
schedule: {
71+
type: 'crontab',
72+
value: '* * * * *',
73+
},
74+
checkinMargin: 2, // In minutes. Optional.
75+
maxRuntime: 10, // In minutes. Optional.
76+
timezone: 'America/Los_Angeles', // Optional.
77+
};
78+
79+
export class MyCronService {
80+
@Cron('* * * * *')
81+
@SentryCron('my-monitor-slug', monitorConfig)
82+
handleCron() {
83+
// Your cron job logic here
84+
}
85+
}
86+
```
87+
5988
## Links
6089

6190
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/nestjs/)

0 commit comments

Comments
 (0)