Skip to content

Commit 2846404

Browse files
committed
fixup! fix(server-utils): Ensure orchestrion instrumentation lazy registers on Node (#22518)
1 parent 2dfd3bf commit 2846404

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

packages/server-utils/src/orchestrion/detect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import { debug, GLOBAL_OBJ } from '@sentry/core';
1010
* will ever publish to those channels.
1111
*/
1212
export function isOrchestrionInjected(): boolean {
13-
return !!GLOBAL_OBJ.__SENTRY_ORCHESTRION__;
13+
const marker = GLOBAL_OBJ.__SENTRY_ORCHESTRION__;
14+
return !!(marker?.runtime || marker?.bundler || marker?.integrations);
1415
}
1516

1617
/**
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { GLOBAL_OBJ } from '@sentry/core';
2+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
3+
import { isOrchestrionInjected } from '../../src/orchestrion/detect';
4+
5+
describe('isOrchestrionInjected', () => {
6+
beforeEach(() => {
7+
delete GLOBAL_OBJ.__SENTRY_ORCHESTRION__;
8+
});
9+
10+
afterEach(() => {
11+
delete GLOBAL_OBJ.__SENTRY_ORCHESTRION__;
12+
});
13+
14+
it('is false when no marker exists', () => {
15+
expect(isOrchestrionInjected()).toBe(false);
16+
});
17+
18+
it.each([
19+
['runtime', { runtime: [] }],
20+
['bundler array', { bundler: ['mysql'] }],
21+
['bundler true', { bundler: true }],
22+
['integrations', { integrations: new Map() }],
23+
] as const)('is true when %s injection is present', (_label, marker) => {
24+
// Cast through `unknown`: rows are `as const` (readonly) and `bundler: true`
25+
// is a valid runtime shape the marker type doesn't spell out.
26+
GLOBAL_OBJ.__SENTRY_ORCHESTRION__ = marker as unknown as typeof GLOBAL_OBJ.__SENTRY_ORCHESTRION__;
27+
expect(isOrchestrionInjected()).toBe(true);
28+
});
29+
30+
// The bridge is installed before hook registration succeeds, so a marker
31+
// carrying only `onInject` means nothing will publish channels. Opt-in paths
32+
// (knex, dataloader, Nest) must still fall back to OTel in that case.
33+
it('is false when only the on-inject bridge is installed', () => {
34+
GLOBAL_OBJ.__SENTRY_ORCHESTRION__ = { onInject: () => {} };
35+
expect(isOrchestrionInjected()).toBe(false);
36+
});
37+
});

0 commit comments

Comments
 (0)