Skip to content

Commit a4e321e

Browse files
committed
ref(node): DRY list of orchestrion integrations to single location
Move the list of orchestrion integrations, keyed by their public-facing OTel names, into server-utils. This allows us to easily provide them in a user-visible way from the Node SDK, and also avoid forgetting to add them in multiple places as we add new ones to the set.
1 parent be62850 commit a4e321e

2 files changed

Lines changed: 24 additions & 20 deletions

File tree

packages/node/src/sdk/experimentalUseDiagnosticsChannelInjection.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
import {
2-
mysqlChannelIntegration,
3-
lruMemoizerChannelIntegration,
4-
detectOrchestrionSetup,
5-
postgresChannelIntegration,
6-
} from '@sentry/server-utils/orchestrion';
1+
import { channelIntegrations, detectOrchestrionSetup } from '@sentry/server-utils/orchestrion';
72
import { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';
83
import type { DiagnosticsChannelInjection } from './diagnosticsChannelInjection';
94
import { setDiagnosticsChannelInjectionLoader } from './diagnosticsChannelInjection';
105

11-
export function diagnosticsChannelInjectionIntegrations() {
12-
return {
13-
postgresIntegration: postgresChannelIntegration,
14-
mysqlIntegration: mysqlChannelIntegration,
15-
lruMemoizerIntegration: lruMemoizerChannelIntegration,
16-
};
6+
export function diagnosticsChannelInjectionIntegrations(): typeof channelIntegrations {
7+
return channelIntegrations;
178
}
189

1910
/**
@@ -50,11 +41,7 @@ export function diagnosticsChannelInjectionIntegrations() {
5041
*/
5142
export function experimentalUseDiagnosticsChannelInjection(): void {
5243
setDiagnosticsChannelInjectionLoader((): DiagnosticsChannelInjection => {
53-
const integrations = [
54-
mysqlChannelIntegration(),
55-
lruMemoizerChannelIntegration(),
56-
postgresChannelIntegration(),
57-
] as const;
44+
const integrations = Object.values(channelIntegrations).map(createIntegration => createIntegration());
5845
const replacedOtelIntegrationNames = integrations.map(i => i.name);
5946

6047
return {
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1+
import { lruMemoizerChannelIntegration } from '../integrations/tracing-channel/lru-memoizer';
2+
import { mysqlChannelIntegration } from '../integrations/tracing-channel/mysql';
3+
import { postgresChannelIntegration } from '../integrations/tracing-channel/postgres';
4+
15
export { detectOrchestrionSetup } from './detect';
2-
export { mysqlChannelIntegration } from '../integrations/tracing-channel/mysql';
3-
export { lruMemoizerChannelIntegration } from '../integrations/tracing-channel/lru-memoizer';
4-
export { postgresChannelIntegration } from '../integrations/tracing-channel/postgres';
6+
export { lruMemoizerChannelIntegration, mysqlChannelIntegration, postgresChannelIntegration };
7+
8+
/**
9+
* The canonical set of orchestrion diagnostics-channel integrations, keyed by their public
10+
* (OTel-parity) factory name.
11+
*
12+
* Single source of truth: add a new channel integration here and every consumer — the `@sentry/node`
13+
* opt-in helper (`experimentalUseDiagnosticsChannelInjection`) and its public
14+
* `diagnosticsChannelInjectionIntegrations()` map — picks it up automatically, so there's no separate
15+
* list to keep in sync.
16+
*/
17+
export const channelIntegrations = {
18+
postgresIntegration: postgresChannelIntegration,
19+
mysqlIntegration: mysqlChannelIntegration,
20+
lruMemoizerIntegration: lruMemoizerChannelIntegration,
21+
} as const;

0 commit comments

Comments
 (0)