@@ -24,7 +24,7 @@ yarn add @sentry/nestjs
24
24
25
25
## Usage
26
26
27
- ``` js
27
+ ``` typescript
28
28
// CJS Syntax
29
29
const Sentry = require (' @sentry/nestjs' );
30
30
// ESM Syntax
@@ -38,12 +38,12 @@ Sentry.init({
38
38
39
39
Note that it is necessary to initialize Sentry ** before you import any package that may be instrumented by us** .
40
40
41
- ## Span Decorator
41
+ ## SentryTraced
42
42
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
44
44
applications.
45
45
46
- ``` js
46
+ ``` typescript
47
47
import { Injectable } from ' @nestjs/common' ;
48
48
import { SentryTraced } from ' @sentry/nestjs' ;
49
49
@@ -56,6 +56,35 @@ export class ExampleService {
56
56
}
57
57
```
58
58
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
+
59
88
## Links
60
89
61
90
- [ Official SDK Docs] ( https://docs.sentry.io/platforms/javascript/guides/nestjs/ )
0 commit comments