Skip to content

Commit 78c9c00

Browse files
authored
docs(nestjs): Update NestJS setup + event emitter (#11830)
1 parent e81dc3d commit 78c9c00

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: NestJS Event Emitter
3+
description: "Learn about instrumenting NestJS event-based services."
4+
---
5+
6+
<Note>
7+
The @nestjs/event-emitter module is auto-instrumented in `@sentry/nestjs` 8.39.0 and up.
8+
</Note>
9+
10+
The NestJS SDK wraps the `@OnEvent` decorator automatically to:
11+
12+
- Create performance traces for event handler executions.
13+
- Automatically capture any unhandled exceptions that occur in event handlers.
14+
- Maintain visibility into asynchronous event-driven flows.
15+
16+
When an event handler is executed, a new span is created to track its performance, and any errors are automatically reported to Sentry while preserving the original error behavior.
17+
18+
This instrumentation works transparently with existing NestJS event handlers without requiring any code changes to your application.

platform-includes/getting-started-config/javascript.nestjs.mdx

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
```javascript {tabTitle:CommonJS} {filename: instrument.js} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}}
2-
const Sentry = require("@sentry/nestjs");
3-
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
1+
```javascript {tabTitle:ESM} {filename: instrument.mjs} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}}
2+
import * as Sentry from "@sentry/nestjs";
3+
import { nodeProfilingIntegration } from '@sentry/profiling-node';
44

5-
// Ensure to call this before requiring any other modules!
5+
// Ensure to call this before importing any other modules!
66
Sentry.init({
77
dsn: "___PUBLIC_DSN___",
88
integrations: [
@@ -20,11 +20,11 @@ Sentry.init({
2020
});
2121
```
2222

23-
```javascript {tabTitle:ESM} {filename: instrument.mjs} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}}
24-
import * as Sentry from "@sentry/nestjs";
25-
import { nodeProfilingIntegration } from '@sentry/profiling-node';
23+
```javascript {tabTitle:CommonJS} {filename: instrument.js} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}}
24+
const Sentry = require("@sentry/nestjs");
25+
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
2626

27-
// Ensure to call this before importing any other modules!
27+
// Ensure to call this before requiring any other modules!
2828
Sentry.init({
2929
dsn: "___PUBLIC_DSN___",
3030
integrations: [
@@ -41,3 +41,4 @@ Sentry.init({
4141
profilesSampleRate: 1.0,
4242
});
4343
```
44+

platform-includes/getting-started-use/javascript.nestjs.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class YourCatchAllExceptionFilter implements ExceptionFilter {
4949
}
5050
```
5151

52+
5253
{/* TODO(v9): Remove this note */}
5354
_Note that `@SentryExceptionCaptured()` was called `@WithSentry` in SDK versions `8.38.0` and prior._
5455

@@ -72,7 +73,6 @@ import { SentryGlobalFilter } from "@sentry/nestjs/setup";
7273
})
7374
export class AppModule {}
7475
```
75-
7676
{/* TODO(v9): Remove this note. */}
7777

7878
**Note:** If you have a NestJS + GraphQL application and you are using the `@sentry/nestjs` SDK version `8.38.0` or earlier, replace the `SentryGlobalFilter` with the `SentryGlobalGenericFilter`.

0 commit comments

Comments
 (0)