Convert error reporting and tracing integrations to plugins#471
Convert error reporting and tracing integrations to plugins#471alexeyr-ci merged 10 commits intomasterfrom
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThe changes in this pull request primarily involve updates to the ESLint configuration, enhancements to error reporting and tracing functionalities, and modifications to the integration of Sentry and Honeybadger within the application. Key updates include the introduction of new rules in ESLint, the addition of helper methods for server rendering, and the restructuring of error reporting mechanisms. Furthermore, the Changes
Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
518aa0e to
49fc2b6
Compare
49fc2b6 to
76557be
Compare
| "@honeybadger-io/js": "^4.3.1", | ||
| "@sentry/node": "^6.2.3", | ||
| "@sentry/tracing": "^6.2.3", | ||
| "@sentry/node": "^7.120.0", |
There was a problem hiding this comment.
This version has both the new and the old tracing APIs, so both sentry6.ts and sentry.ts can be typed without additional tricks.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
b46f7f5 to
5138288
Compare
| const sentryTracing = requireOptional('@sentry/tracing'); | ||
| // This is the options necessary to start a unit of work (transaction/span/etc.). | ||
| // Integrations should augment it using their name as the property. | ||
| export interface UnitOfWorkOptions {} |
There was a problem hiding this comment.
Maybe StartTraceOptions would be clearer?
There was a problem hiding this comment.
Make it clear about the types that's exist in the public interface. Explain how UnitOfWorkOptions should be created and passed to trace function. Also, explain that the TracingContext is passed to the callback function being executed when calling trace function.
9be5fd7 to
63aff64
Compare
| export = errorReporter; | ||
| export function error(err: Error, tracingContext?: TracingContext) { | ||
| log.error(`ErrorReporter notification: ${err}`); | ||
| errorNotifiers.forEach((notifier) => { |
There was a problem hiding this comment.
Would it be better to use EventEmitter to notify listeners? It could simplify handling asynchronous operations. If you decide not to use it, consider executing the notifiers asynchronously like this:
errorNotifiers.forEach((notifier) => {
setTimeout(() => notifier(err, tracingContext), 0);
});This approach ensures that a failure in one notifier doesn’t impact the caller of error or message. Additionally, it avoids slowing down the caller when there are many listeners. What do you think?
There was a problem hiding this comment.
It looks like a good idea (maybe with a single setTimeout instead of corresponding to the number of notifiers). Need to check if it works properly with the Sentry 7 integration, though.
There was a problem hiding this comment.
Fixed the possibility of notifiers failing, good catch!
Unfortunately, EventEmitter, setTimeout, and setImmediate all don't propagate AsyncLocalStorage in the way Sentry 7-8 need. I tried to work around it but didn't manage to. If I find a way later, it shouldn't be a breaking change.
| } | ||
|
|
||
| export function init({ tracing = false } = {}) { | ||
| addMessageNotifier((msg) => { |
There was a problem hiding this comment.
You don't need to receive and pass the CaptureContext here, or is it missed?
There was a problem hiding this comment.
No, the CaptureContext is needed for Sentry 6 to call setSpan for the captureMessage/captureException call. In Sentry 7-8, the active span is set automatically using AsyncLocalStorage.
| captureMessage(msg); | ||
| }); | ||
|
|
||
| addErrorNotifier((msg) => { |
There was a problem hiding this comment.
You don't need to receive and pass the CaptureContext here, or is it missed?
| import * as Sentry from '@sentry/node'; | ||
| import sentryTestkit from 'sentry-testkit'; | ||
| import { trace } from '../../src/shared/tracing'; | ||
| import * as tracingIntegration from '../../src/integrations/sentry'; |
There was a problem hiding this comment.
is it possible to add tests for sentry6 as well?
There was a problem hiding this comment.
Not really, because we can only have one Sentry version in devDependencies. Now if we move it to a separate package, then we could.
There was a problem hiding this comment.
Actually, let me see if I can make integrations into separate packages in the same repo...
| }, testTransactionContext); | ||
| }).rejects.toThrow(); | ||
| expect(finishMock.mock.calls).toHaveLength(1); | ||
| expect(Sentry.getActiveSpan()).not.toBe(savedSpan); |
There was a problem hiding this comment.
Won't an error be reported automatically to Sentry if an error happens?
There was a problem hiding this comment.
No, because toThrow catches it.
| @@ -0,0 +1,7 @@ | |||
| export { addErrorNotifier, addMessageNotifier, addNotifier } from '../shared/errorReporter'; | |||
There was a problem hiding this comment.
Please leave comment that tells this API can be used to develop new error reporting plugins for node renderer
There was a problem hiding this comment.
Added with @file but it doesn't seem to show up anywhere useful...
9e4a3f4 to
b004b29
Compare
Reworks error reporting and tracing integrations to:
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation
Chores