Skip to content

Commit 8974643

Browse files
authored
feat: Document eventLoopBlockIntegration integration (#14302)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR resolves https://linear.app/getsentry/issue/FE-521 This PR documents the `eventLoopBlockIntegration` we added in in the new `@sentry/node-native` package. ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [x] Urgent deadline (GA date, etc.): This has already been released, so we should merge asap. - [ ] Other deadline: <!-- ENTER DATE HERE --> - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
1 parent ec4387d commit 8974643

17 files changed

+72
-17
lines changed

docs/platforms/javascript/common/configuration/application-not-responding.mdx renamed to docs/platforms/javascript/common/configuration/event-loop-block.mdx

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Application Not Responding (ANR)
2+
title: Event Loop Block Detection
33
sidebar_order: 70
4-
description: "Learn how to turn off or specify ANRs for Node.js"
4+
description: "Monitor for blocked event loops in Node.js applications"
55
supported:
66
- javascript.node
77
- javascript.aws-lambda
@@ -25,26 +25,51 @@ supported:
2525
- javascript.tanstackstart-react
2626
keywords:
2727
[
28+
"event loop block",
2829
"anr",
2930
"Application Not Responding",
3031
"Event Loop Blocked",
3132
"Event Loop Stalls",
3233
]
3334
---
3435

35-
Application Not Responding (ANR) errors, or Event Loop Stall errors, are triggered when the Node.js main thread event loop of an application is blocked for more than five seconds. The Node SDK reports ANR errors as Sentry events and can optionally attach a stack trace of the blocking code to the ANR event.
36+
Event Loop Block detection monitors when the Node.js main thread event loop is blocked for more than a specified threshold. The Node SDK reports these events to Sentry with automatically captured stack traces to help identify blocking code.
3637

3738
<Include name="feature-stage-beta.mdx" />
3839

3940
<Alert>
4041

41-
ANR detection is not supported for [Node.js clusters](https://nodejs.org/api/cluster.html).
42+
Event loop block detection is not supported for [Node.js clusters](https://nodejs.org/api/cluster.html).
43+
44+
</Alert>
45+
46+
## Event Loop Block Integration (Recommended)
47+
48+
For the best performance and comprehensive monitoring, we recommend using the [`eventLoopBlockIntegration`](./integrations/event-loop-block) from the `@sentry/node-native` package. Stack traces are automatically captured when blocking is detected. This integration can monitor all threads in your Node.js application and provides better performance compared to the deprecated ANR integration.
49+
50+
```javascript
51+
import * as Sentry from "@sentry/node";
52+
import { eventLoopBlockIntegration } from "@sentry/node-native";
53+
54+
Sentry.init({
55+
dsn: "___PUBLIC_DSN___",
56+
integrations: [eventLoopBlockIntegration({ threshold: 1000 })],
57+
});
58+
```
59+
60+
For detailed usage instructions and configuration options, see the [`eventLoopBlockIntegration`](./integrations/event-loop-block) documentation.
61+
62+
## Deprecated Application Not Responding (ANR) Integration
63+
64+
<Alert type="warning">
65+
66+
**Deprecated**: The `anrIntegration` is deprecated. Please use the [`eventLoopBlockIntegration`](./integrations/event-loop-block) instead for better performance and more comprehensive monitoring.
4267

4368
</Alert>
4469

4570
_(Available in version 7.91.0 and above)_
4671

47-
To enable ANR detection, add the `Anr` integration from the `@sentry/node` package.
72+
The legacy ANR integration is still available but deprecated. If you're currently using it, we recommend migrating to the new `eventLoopBlockIntegration`.
4873

4974
<Alert>
5075

@@ -61,9 +86,9 @@ Sentry.init({
6186

6287
![Example of an ANR error event](./img/anr-node-example.png)
6388

64-
## Configuration options
89+
### Legacy ANR Configuration Options
6590

66-
You can pass a configuration object to the `Anr` integration to customize the ANR detection behavior.
91+
The deprecated ANR integration supports the following configuration options:
6792

6893
```ts
6994
interface Options {
@@ -90,9 +115,9 @@ interface Options {
90115
}
91116
```
92117

93-
## ANR Implementation and Overhead
118+
### Legacy ANR Implementation and Overhead
94119

95-
ANR detection with the Node SDK uses a worker thread to monitor the event loop
120+
ANR detection with the legacy Node SDK uses a worker thread to monitor the event loop
96121
in the main app thread. The main app thread sends a heartbeat message to the ANR
97122
worker thread every 50ms. If the ANR worker does not receive a heartbeat message
98123
for 5 seconds, it triggers an ANR event. If the `captureStackTrace` option is

docs/platforms/javascript/common/configuration/integrations/anr.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ supported:
2424
- javascript.tanstackstart-react
2525
---
2626

27+
<Alert type="warning">
28+
29+
**Deprecated**: This integration is deprecated. Please use the [`eventLoopBlockIntegration`](./event-loop-block) instead for better performance and more comprehensive monitoring.
30+
31+
</Alert>
32+
2733
<Alert>
2834

2935
This integration only works in the Node.js runtime.
@@ -32,7 +38,7 @@ This integration only works in the Node.js runtime.
3238

3339
_Import name: `Sentry.anrIntegration`_
3440

35-
The `anrIntegration` captures Application Not Responding (ANR)/Event Loop Stall errors and reports them as Sentry events. For more details, see the documentation on [ANR](../../application-not-responding).
41+
The `anrIntegration` captures Application Not Responding (ANR)/Event Loop Stall errors and reports them as Sentry events. For more details, see the documentation on [Event Loop Block Detection](../../event-loop-block).
3642

3743
```JavaScript
3844
Sentry.init({

docs/platforms/javascript/guides/electron/configuration/application-not-responding.mdx renamed to docs/platforms/javascript/guides/electron/configuration/event-loop-block.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Application Not Responding (ANR)
2+
title: Event Loop Block Detection
33
sidebar_order: 70
4-
description: "Learn how to turn off or specify ANRs for Electron Main Thread"
4+
description: "Monitor for blocked event loops in Electron applications"
55
keywords:
66
[
77
"anr",
@@ -11,7 +11,7 @@ keywords:
1111
]
1212
---
1313

14-
Application Not Responding (ANR) errors, or Event Loop Stall errors, are
14+
Event Loop Block errors, or Application Not Responding (ANR) errors are
1515
triggered when the Electron main or renderer processes event loop is blocked for more than
1616
five seconds. The Electron SDK reports ANR errors as Sentry events and can
1717
optionally attach a stack trace of the blocking code to the ANR event.
@@ -79,7 +79,7 @@ interface Options {
7979
}
8080
```
8181

82-
## ANR Implementation and Overhead
82+
## Application Not Responding (ANR) Implementation and Overhead
8383

8484
ANR detection in the Electron main process uses a worker thread to monitor the event loop
8585
in the main app thread. The main app thread sends a heartbeat message to the ANR

platform-includes/configuration/integrations/javascript.astro.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Depending on whether an integration enhances the functionality of a particular r
7474
| [`prismaIntegration`](./prisma) || || |
7575
| [`vercelAiIntegration`](./vercelai) || || |
7676
| [`anrIntegration`](./anr) | || | |
77+
| [`eventLoopBlockIntegration`](./event-loop-block) | || | |
7778
| [`extraErrorDataIntegration`](./extraerrordata) | | | ||
7879
| [`fsIntegration`](./fs) | | || |
7980
| [`knexIntegration`](./knex) | | || |

platform-includes/configuration/integrations/javascript.aws-lambda.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
| [`amqplibIntegration`](./amqplib) | | || |
2222
| [`anrIntegration`](./anr) | || | |
2323
| [`captureConsoleIntegration`](./captureconsole) | | | ||
24+
| [`eventLoopBlockIntegration`](./event-loop-block) | || | |
2425
| [`dataloaderIntegration`](./dataloader) | | || |
2526
| [`extraErrorDataIntegration`](./extraerrordata) | | | ||
2627
| [`fsIntegration`](./fs) | | || |

platform-includes/configuration/integrations/javascript.connect.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
| [`vercelAiIntegration`](./vercelai) || || |
3434
| [`anrIntegration`](./anr) | || | |
3535
| [`captureConsoleIntegration`](./captureconsole) | | | ||
36+
| [`eventLoopBlockIntegration`](./event-loop-block) | || | |
3637
| [`dataloaderIntegration`](./dataloader) | | || |
3738
| [`extraErrorDataIntegration`](./extraerrordata) | | | ||
3839
| [`fsIntegration`](./fs) | | || |

platform-includes/configuration/integrations/javascript.fastify.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
| [`vercelAiIntegration`](./vercelai) || || |
3434
| [`anrIntegration`](./anr) | || | |
3535
| [`captureConsoleIntegration`](./captureconsole) | | | ||
36+
| [`eventLoopBlockIntegration`](./event-loop-block) | || | |
3637
| [`dataloaderIntegration`](./dataloader) | | || |
3738
| [`extraErrorDataIntegration`](./extraerrordata) | | | ||
3839
| [`fsIntegration`](./fs) | | || |

platform-includes/configuration/integrations/javascript.gcp-functions.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
| [`amqplibIntegration`](./amqplib) | | || |
2222
| [`anrIntegration`](./anr) | || | |
2323
| [`captureConsoleIntegration`](./captureconsole) | | | ||
24+
| [`eventLoopBlockIntegration`](./event-loop-block) | || | |
2425
| [`dataloaderIntegration`](./dataloader) | | || |
2526
| [`extraErrorDataIntegration`](./extraerrordata) | | | ||
2627
| [`fsIntegration`](./fs) | | || |

platform-includes/configuration/integrations/javascript.hapi.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
| [`vercelAiIntegration`](./vercelai) || || |
3434
| [`anrIntegration`](./anr) | || | |
3535
| [`captureConsoleIntegration`](./captureconsole) | | | ||
36+
| [`eventLoopBlockIntegration`](./event-loop-block) | || | |
3637
| [`dataloaderIntegration`](./dataloader) | | || |
3738
| [`extraErrorDataIntegration`](./extraerrordata) | | | ||
3839
| [`fsIntegration`](./fs) | | || |

platform-includes/configuration/integrations/javascript.nestjs.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
| [`vercelAiIntegration`](./vercelai) || || |
3434
| [`anrIntegration`](./anr) | || | |
3535
| [`captureConsoleIntegration`](./captureconsole) | | | ||
36+
| [`eventLoopBlockIntegration`](./event-loop-block) | || | |
3637
| [`dataloaderIntegration`](./dataloader) | | || |
3738
| [`extraErrorDataIntegration`](./extraerrordata) | | | ||
3839
| [`fsIntegration`](./fs) | | || |

0 commit comments

Comments
 (0)