-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(node): Ensure orchestrion runtime is injected when integration is passed #23471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ vi.mock('@sentry/server-utils/orchestrion', async importOriginal => { | |
| return { ...actual, detectOrchestrionSetup }; | ||
| }); | ||
|
|
||
| import { expressIntegration } from '../../src'; | ||
| import { init } from '../../src/sdk'; | ||
| import { cleanupOtel, resetGlobals } from '../helpers/mockSdkInit'; | ||
|
|
||
|
|
@@ -23,8 +24,9 @@ declare var global: any; | |
| const PUBLIC_DSN = 'https://username@domain/123'; | ||
|
|
||
| // Channel-based (orchestrion diagnostics-channel) instrumentation is the default in v11: `init()` | ||
| // installs the injection hooks unconditionally when span recording is enabled, and skips them when | ||
| // tracing is off (there would be no channel subscribers to feed). | ||
| // installs the injection hooks when span recording is enabled, or when a channel-based integration | ||
| // (e.g. `expressIntegration()`) is configured — those can capture errors even with tracing off. With | ||
| // tracing off and no such integration there are no channel subscribers, so the hooks are skipped. | ||
| describe('diagnostics-channel injection default', () => { | ||
| beforeEach(() => { | ||
| global.__SENTRY__ = {}; | ||
|
|
@@ -50,4 +52,33 @@ describe('diagnostics-channel injection default', () => { | |
| expect(registerDiagnosticsChannelInjection).not.toHaveBeenCalled(); | ||
| expect(detectOrchestrionSetup).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('registers the injection hooks when a channel-based integration is configured, even with tracing disabled', () => { | ||
| init({ dsn: PUBLIC_DSN, enableOpenTelemetrySetup: false, integrations: [expressIntegration()] }); | ||
|
|
||
| expect(registerDiagnosticsChannelInjection).toHaveBeenCalledTimes(1); | ||
| expect(detectOrchestrionSetup).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it('registers the injection hooks when a channel-based integration is added via an `integrations` function', () => { | ||
| init({ | ||
| dsn: PUBLIC_DSN, | ||
| enableOpenTelemetrySetup: false, | ||
| integrations: defaults => [...defaults, expressIntegration()], | ||
| }); | ||
|
|
||
| expect(registerDiagnosticsChannelInjection).toHaveBeenCalledTimes(1); | ||
| expect(detectOrchestrionSetup).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it('does not register the injection hooks when only non-channel integrations are configured and tracing is disabled', () => { | ||
| init({ | ||
| dsn: PUBLIC_DSN, | ||
| enableOpenTelemetrySetup: false, | ||
| integrations: [{ name: 'CustomNonChannelIntegration', setup: () => undefined }], | ||
| }); | ||
|
|
||
| expect(registerDiagnosticsChannelInjection).not.toHaveBeenCalled(); | ||
| expect(detectOrchestrionSetup).not.toHaveBeenCalled(); | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing integration or E2E testMedium Severity This is a Triggered by project rule: PR Review Guidelines for Cursor Bot Reviewed by Cursor Bugbot for commit 0af2bbc. Configure here. |
||
| }); | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-orchestrion names gate injection
Low Severity
hasUserConfiguredChannelIntegrationtreats everyAUTO_PERFORMANCE_INTEGRATION_NAMESentry as orchestrion-backed, butPrismaandFastifyare not. Passing only those with tracing off still callsregisterDiagnosticsChannelInjection, installing module hooks that those integrations never use.Additional Locations (1)
packages/node/src/integrations/tracing/index.ts#L93-L120Reviewed by Cursor Bugbot for commit 0af2bbc. Configure here.