Skip to content

Commit efc79f8

Browse files
committed
Extract common exports shared between main and light entry points
Avoids drift between the two entry points by keeping shared exports in a single file. Entry-point-specific and deprecated exports remain in their respective index files.
1 parent b1ef70d commit efc79f8

File tree

4 files changed

+157
-274
lines changed

4 files changed

+157
-274
lines changed

dev-packages/node-core-integration-tests/suites/light-mode/propagation/test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ conditionalTest({ min: 22 })('light mode propagation', () => {
1111
test('getTraceData returns consistent span ID within a request', async () => {
1212
const runner = createRunner(__dirname, 'server.js').start();
1313

14-
const response = await runner.makeRequest<{ spanId1: string; spanId2: string }>(
15-
'get',
16-
'/test-propagation',
17-
);
14+
const response = await runner.makeRequest<{ spanId1: string; spanId2: string }>('get', '/test-propagation');
1815

1916
expect(response?.spanId1).toBeDefined();
2017
expect(response?.spanId2).toBeDefined();
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/**
2+
* Common exports shared between the main entry point (index.ts) and the light entry point (light/index.ts).
3+
*
4+
* Add exports here that should be available in both entry points. Entry-point-specific exports
5+
* (e.g., OTel-dependent ones for index.ts, or light-specific ones for light/index.ts) should
6+
* remain in their respective index files.
7+
*
8+
* Deprecated exports should NOT go in this file — they belong in the entry point that still
9+
* needs to ship them for backwards compatibility.
10+
*/
11+
import * as logger from './logs/exports';
12+
13+
// Node-core integrations (not OTel-dependent)
14+
export { nodeContextIntegration } from './integrations/context';
15+
export { contextLinesIntegration } from './integrations/contextlines';
16+
export { localVariablesIntegration } from './integrations/local-variables';
17+
export { modulesIntegration } from './integrations/modules';
18+
export { onUncaughtExceptionIntegration } from './integrations/onuncaughtexception';
19+
export { onUnhandledRejectionIntegration } from './integrations/onunhandledrejection';
20+
export { spotlightIntegration } from './integrations/spotlight';
21+
export { systemErrorIntegration } from './integrations/systemError';
22+
export { childProcessIntegration } from './integrations/childProcess';
23+
export { createSentryWinstonTransport } from './integrations/winston';
24+
export { pinoIntegration } from './integrations/pino';
25+
26+
// SDK utilities
27+
export { getSentryRelease, defaultStackParser } from './sdk/api';
28+
export { createGetModuleFromFilename } from './utils/module';
29+
export { addOriginToSpan } from './utils/addOriginToSpan';
30+
export { getRequestUrl } from './utils/getRequestUrl';
31+
export { initializeEsmLoader } from './sdk/esmLoader';
32+
export { isCjs } from './utils/detection';
33+
export { createMissingInstrumentationContext } from './utils/createMissingInstrumentationContext';
34+
export { envToBool } from './utils/envToBool';
35+
export { makeNodeTransport, type NodeTransportOptions } from './transports';
36+
export type { HTTPModuleRequestIncomingMessage } from './transports/http-module';
37+
export { cron } from './cron';
38+
export { NODE_VERSION } from './nodeVersion';
39+
40+
export type { NodeOptions } from './types';
41+
42+
// Re-export from @sentry/core
43+
export {
44+
addBreadcrumb,
45+
isInitialized,
46+
isEnabled,
47+
getGlobalScope,
48+
lastEventId,
49+
close,
50+
createTransport,
51+
flush,
52+
SDK_VERSION,
53+
getSpanStatusFromHttpCode,
54+
setHttpStatus,
55+
captureCheckIn,
56+
withMonitor,
57+
requestDataIntegration,
58+
functionToStringIntegration,
59+
eventFiltersIntegration,
60+
linkedErrorsIntegration,
61+
addEventProcessor,
62+
setContext,
63+
setExtra,
64+
setExtras,
65+
setTag,
66+
setTags,
67+
setUser,
68+
SEMANTIC_ATTRIBUTE_SENTRY_OP,
69+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
70+
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
71+
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
72+
setCurrentClient,
73+
Scope,
74+
setMeasurement,
75+
getSpanDescendants,
76+
parameterize,
77+
getClient,
78+
getCurrentScope,
79+
getIsolationScope,
80+
getTraceData,
81+
getTraceMetaTags,
82+
continueTrace,
83+
withScope,
84+
withIsolationScope,
85+
captureException,
86+
captureEvent,
87+
captureMessage,
88+
captureFeedback,
89+
captureConsoleIntegration,
90+
dedupeIntegration,
91+
extraErrorDataIntegration,
92+
rewriteFramesIntegration,
93+
startSession,
94+
captureSession,
95+
endSession,
96+
addIntegration,
97+
startSpan,
98+
startSpanManual,
99+
startInactiveSpan,
100+
startNewTrace,
101+
suppressTracing,
102+
getActiveSpan,
103+
withActiveSpan,
104+
getRootSpan,
105+
spanToJSON,
106+
spanToTraceHeader,
107+
spanToBaggageHeader,
108+
trpcMiddleware,
109+
updateSpanName,
110+
supabaseIntegration,
111+
instrumentSupabaseClient,
112+
zodErrorsIntegration,
113+
profiler,
114+
consoleLoggingIntegration,
115+
createConsolaReporter,
116+
consoleIntegration,
117+
wrapMcpServerWithSentry,
118+
featureFlagsIntegration,
119+
metrics,
120+
} from '@sentry/core';
121+
122+
export type {
123+
Breadcrumb,
124+
BreadcrumbHint,
125+
PolymorphicRequest,
126+
RequestEventData,
127+
SdkInfo,
128+
Event,
129+
EventHint,
130+
ErrorEvent,
131+
Exception,
132+
Session,
133+
SeverityLevel,
134+
StackFrame,
135+
Stacktrace,
136+
Thread,
137+
User,
138+
Span,
139+
FeatureFlagsIntegration,
140+
} from '@sentry/core';
141+
142+
export { logger };

packages/node-core/src/index.ts

Lines changed: 12 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as logger from './logs/exports';
2-
1+
// OTel-specific exports (not available in light mode)
32
export { httpIntegration } from './integrations/http';
43
export { httpServerSpansIntegration } from './integrations/http/httpServerSpansIntegration';
54
export { httpServerIntegration } from './integrations/http/httpServerIntegration';
@@ -14,151 +13,30 @@ export {
1413
type SentryNodeFetchInstrumentationOptions,
1514
} from './integrations/node-fetch/SentryNodeFetchInstrumentation';
1615

17-
export { nodeContextIntegration } from './integrations/context';
18-
export { contextLinesIntegration } from './integrations/contextlines';
19-
export { localVariablesIntegration } from './integrations/local-variables';
20-
export { modulesIntegration } from './integrations/modules';
21-
export { onUncaughtExceptionIntegration } from './integrations/onuncaughtexception';
22-
export { onUnhandledRejectionIntegration } from './integrations/onunhandledrejection';
23-
// eslint-disable-next-line deprecation/deprecation
24-
export { anrIntegration, disableAnrDetectionForCallback } from './integrations/anr';
25-
26-
export { spotlightIntegration } from './integrations/spotlight';
27-
export { systemErrorIntegration } from './integrations/systemError';
28-
export { childProcessIntegration } from './integrations/childProcess';
29-
export { processSessionIntegration } from './integrations/processSession';
30-
export { createSentryWinstonTransport } from './integrations/winston';
31-
export { pinoIntegration } from './integrations/pino';
32-
3316
export { SentryContextManager } from './otel/contextManager';
3417
export { setupOpenTelemetryLogger } from './otel/logger';
3518
export { generateInstrumentOnce, instrumentWhenWrapped, INSTRUMENTED } from './otel/instrument';
3619

3720
export { init, getDefaultIntegrations, initWithoutDefaultIntegrations, validateOpenTelemetrySetup } from './sdk';
3821
export { setIsolationScope } from './sdk/scope';
39-
export { getSentryRelease, defaultStackParser } from './sdk/api';
40-
export { createGetModuleFromFilename } from './utils/module';
41-
export { addOriginToSpan } from './utils/addOriginToSpan';
42-
export { getRequestUrl } from './utils/getRequestUrl';
43-
export { initializeEsmLoader } from './sdk/esmLoader';
44-
export { isCjs } from './utils/detection';
45-
export { ensureIsWrapped } from './utils/ensureIsWrapped';
46-
export { createMissingInstrumentationContext } from './utils/createMissingInstrumentationContext';
47-
export { envToBool } from './utils/envToBool';
48-
export { makeNodeTransport, type NodeTransportOptions } from './transports';
49-
export type { HTTPModuleRequestIncomingMessage } from './transports/http-module';
5022
export { NodeClient } from './sdk/client';
51-
export { cron } from './cron';
52-
export { NODE_VERSION } from './nodeVersion';
23+
export { ensureIsWrapped } from './utils/ensureIsWrapped';
24+
export { processSessionIntegration } from './integrations/processSession';
5325

54-
export type { NodeOptions, OpenTelemetryServerRuntimeOptions } from './types';
26+
export type { OpenTelemetryServerRuntimeOptions } from './types';
5527

5628
export {
5729
// This needs exporting so the NodeClient can be used without calling init
5830
setOpenTelemetryContextAsyncContextStrategy as setNodeAsyncContextStrategy,
5931
} from '@sentry/opentelemetry';
6032

61-
export {
62-
addBreadcrumb,
63-
isInitialized,
64-
isEnabled,
65-
getGlobalScope,
66-
lastEventId,
67-
close,
68-
createTransport,
69-
flush,
70-
SDK_VERSION,
71-
getSpanStatusFromHttpCode,
72-
setHttpStatus,
73-
captureCheckIn,
74-
withMonitor,
75-
requestDataIntegration,
76-
functionToStringIntegration,
77-
// eslint-disable-next-line deprecation/deprecation
78-
inboundFiltersIntegration,
79-
eventFiltersIntegration,
80-
linkedErrorsIntegration,
81-
addEventProcessor,
82-
setContext,
83-
setExtra,
84-
setExtras,
85-
setTag,
86-
setTags,
87-
setUser,
88-
SEMANTIC_ATTRIBUTE_SENTRY_OP,
89-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
90-
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
91-
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
92-
setCurrentClient,
93-
Scope,
94-
setMeasurement,
95-
getSpanDescendants,
96-
parameterize,
97-
getClient,
98-
getCurrentScope,
99-
getIsolationScope,
100-
getTraceData,
101-
getTraceMetaTags,
102-
continueTrace,
103-
withScope,
104-
withIsolationScope,
105-
captureException,
106-
captureEvent,
107-
captureMessage,
108-
captureFeedback,
109-
captureConsoleIntegration,
110-
dedupeIntegration,
111-
extraErrorDataIntegration,
112-
rewriteFramesIntegration,
113-
startSession,
114-
captureSession,
115-
endSession,
116-
addIntegration,
117-
startSpan,
118-
startSpanManual,
119-
startInactiveSpan,
120-
startNewTrace,
121-
suppressTracing,
122-
getActiveSpan,
123-
withActiveSpan,
124-
getRootSpan,
125-
spanToJSON,
126-
spanToTraceHeader,
127-
spanToBaggageHeader,
128-
trpcMiddleware,
129-
updateSpanName,
130-
supabaseIntegration,
131-
instrumentSupabaseClient,
132-
zodErrorsIntegration,
133-
profiler,
134-
consoleLoggingIntegration,
135-
createConsolaReporter,
136-
consoleIntegration,
137-
wrapMcpServerWithSentry,
138-
featureFlagsIntegration,
139-
metrics,
140-
} from '@sentry/core';
33+
// Deprecated exports (do not add to common-exports.ts)
34+
// eslint-disable-next-line deprecation/deprecation
35+
export { anrIntegration, disableAnrDetectionForCallback } from './integrations/anr';
36+
// eslint-disable-next-line deprecation/deprecation
37+
export { inboundFiltersIntegration } from '@sentry/core';
14138

142-
export type {
143-
Breadcrumb,
144-
BreadcrumbHint,
145-
PolymorphicRequest,
146-
RequestEventData,
147-
SdkInfo,
148-
Event,
149-
EventHint,
150-
ErrorEvent,
151-
Exception,
152-
Session,
153-
SeverityLevel,
154-
StackFrame,
155-
Stacktrace,
156-
Thread,
157-
User,
158-
Span,
159-
FeatureFlagsIntegration,
160-
ExclusiveEventHintOrCaptureContext,
161-
CaptureContext,
162-
} from '@sentry/core';
39+
export type { ExclusiveEventHintOrCaptureContext, CaptureContext } from '@sentry/core';
16340

164-
export { logger };
41+
// Common exports shared with the light entry point
42+
export * from './common-exports';

0 commit comments

Comments
 (0)