Skip to content

Commit cc0dc3b

Browse files
authored
fix(node-core): Reduce bundle size by removing apm-js-collab and requiring pino >= 9.10 (#18631)
We discussed this in Bikeshedding, apm-js runtime hooks gets bundled in frameworks still using CJS like Next.js, even if the user was not using Pino integration at all. Attempts to tree-shake it failed as Next.js is still using CJS. We can drop support for older versions of Pino, given that `pino@9.10` already exposes a tracing channel that we use, and that the injected channel was a backup for `pino<9.10` This will reduce bundle sizes and ensure frameworks incapable of esm tree-shaking don't pick it up as a dependency. I will remove `@apm-js-collab/tracing-hooks` as a dep from `node-core` since nothing else uses it. closes #18199
1 parent 7cd2abb commit cc0dc3b

File tree

9 files changed

+11
-93
lines changed

9 files changed

+11
-93
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
### Important Changes
8+
9+
- fix(node-core): Reduce bundle size by removing apm-js-collab and requiring pino >= 9.10 ([#18631](https://github.com/getsentry/sentry-javascript/pull/18631))
10+
11+
In order to keep receiving pino logs, you need to update your pino version to >= 9.10, the reason for the support bump is to reduce the bundle size of the node-core SDK in frameworks that cannot tree-shake the apm-js-collab dependency.
12+
713
## 10.39.0
814

915
### Important Changes

dev-packages/node-integration-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"node-schedule": "^2.1.1",
7373
"openai": "5.18.1",
7474
"pg": "8.16.0",
75-
"pino": "9.9.4",
75+
"pino": "9.10.0",
7676
"pino-next": "npm:pino@^9.12.0",
7777
"postgres": "^3.4.7",
7878
"prisma": "6.15.0",

packages/core/src/utils/worldwide.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ export type InternalGlobal = {
5454
*/
5555
_sentryModuleMetadata?: Record<string, any>;
5656
_sentryEsmLoaderHookRegistered?: boolean;
57-
_sentryInjectLoaderHookRegister?: () => void;
58-
_sentryInjectLoaderHookRegistered?: boolean;
5957
} & Carrier;
6058

6159
/** Get's the global object for the current JavaScript runtime */

packages/node-core/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,11 @@
9999
}
100100
},
101101
"dependencies": {
102-
"@apm-js-collab/tracing-hooks": "^0.3.1",
103102
"@sentry/core": "10.39.0",
104103
"@sentry/opentelemetry": "10.39.0",
105104
"import-in-the-middle": "^2.0.6"
106105
},
107106
"devDependencies": {
108-
"@apm-js-collab/code-transformer": "^0.8.2",
109107
"@opentelemetry/api": "^1.9.0",
110108
"@opentelemetry/context-async-hooks": "^2.5.0",
111109
"@opentelemetry/core": "^2.5.0",

packages/node-core/src/integrations/pino.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
severityLevelFromString,
1010
withScope,
1111
} from '@sentry/core';
12-
import { addInstrumentationConfig } from '../sdk/injectLoader';
1312

1413
const SENTRY_TRACK_SYMBOL = Symbol('sentry-track-pino-logger');
1514

@@ -128,18 +127,6 @@ const _pinoIntegration = defineIntegration((userOptions: DeepPartial<PinoOptions
128127
setup: client => {
129128
const enableLogs = !!client.getOptions().enableLogs;
130129

131-
addInstrumentationConfig({
132-
channelName: 'pino-log',
133-
// From Pino v9.10.0 a tracing channel is available directly from Pino:
134-
// https://github.com/pinojs/pino/pull/2281
135-
module: { name: 'pino', versionRange: '>=8.0.0 < 9.10.0', filePath: 'lib/tools.js' },
136-
functionQuery: {
137-
functionName: 'asJson',
138-
kind: 'Sync',
139-
},
140-
});
141-
142-
const injectedChannel = diagnosticsChannel.tracingChannel('orchestrion:pino:pino-log');
143130
const integratedChannel = diagnosticsChannel.tracingChannel('pino_asJson');
144131

145132
function onPinoStart(self: Pino, args: PinoHookArgs, result: PinoResult): void {
@@ -192,11 +179,6 @@ const _pinoIntegration = defineIntegration((userOptions: DeepPartial<PinoOptions
192179
}
193180
}
194181

195-
injectedChannel.end.subscribe(data => {
196-
const { self, arguments: args, result } = data as { self: Pino; arguments: PinoHookArgs; result: string };
197-
onPinoStart(self, args, JSON.parse(result));
198-
});
199-
200182
integratedChannel.end.subscribe(data => {
201183
const {
202184
instance,

packages/node-core/src/light/sdk.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
functionToStringIntegration,
1010
getCurrentScope,
1111
getIntegrationsToSetup,
12-
GLOBAL_OBJ,
1312
linkedErrorsIntegration,
1413
propagationContextFromHeaders,
1514
requestDataIntegration,
@@ -121,8 +120,6 @@ function _init(
121120

122121
client.init();
123122

124-
GLOBAL_OBJ._sentryInjectLoaderHookRegister?.();
125-
126123
debug.log(`SDK initialized from ${isCjs() ? 'CommonJS' : 'ESM'} (light mode)`);
127124

128125
client.startClientReportTracking();

packages/node-core/src/sdk/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
functionToStringIntegration,
1010
getCurrentScope,
1111
getIntegrationsToSetup,
12-
GLOBAL_OBJ,
1312
hasSpansEnabled,
1413
inboundFiltersIntegration,
1514
linkedErrorsIntegration,
@@ -135,8 +134,6 @@ function _init(
135134

136135
client.init();
137136

138-
GLOBAL_OBJ._sentryInjectLoaderHookRegister?.();
139-
140137
debug.log(`SDK initialized from ${isCjs() ? 'CommonJS' : 'ESM'}`);
141138

142139
client.startClientReportTracking();

packages/node-core/src/sdk/injectLoader.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

yarn.lock

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -378,20 +378,6 @@
378378
dependencies:
379379
json-schema-to-ts "^3.1.1"
380380

381-
"@apm-js-collab/code-transformer@^0.8.0", "@apm-js-collab/code-transformer@^0.8.2":
382-
version "0.8.2"
383-
resolved "https://registry.yarnpkg.com/@apm-js-collab/code-transformer/-/code-transformer-0.8.2.tgz#a3160f16d1c4df9cb81303527287ad18d00994d1"
384-
integrity sha512-YRjJjNq5KFSjDUoqu5pFUWrrsvGOxl6c3bu+uMFc9HNNptZ2rNU/TI2nLw4jnhQNtka972Ee2m3uqbvDQtPeCA==
385-
386-
"@apm-js-collab/tracing-hooks@^0.3.1":
387-
version "0.3.1"
388-
resolved "https://registry.yarnpkg.com/@apm-js-collab/tracing-hooks/-/tracing-hooks-0.3.1.tgz#414d3a93c3a15d8be543a3fac561f7c602b6a588"
389-
integrity sha512-Vu1CbmPURlN5fTboVuKMoJjbO5qcq9fA5YXpskx3dXe/zTBvjODFoerw+69rVBlRLrJpwPqSDqEuJDEKIrTldw==
390-
dependencies:
391-
"@apm-js-collab/code-transformer" "^0.8.0"
392-
debug "^4.4.1"
393-
module-details-from-path "^1.0.4"
394-
395381
"@apollo/cache-control-types@^1.0.3":
396382
version "1.0.3"
397383
resolved "https://registry.yarnpkg.com/@apollo/cache-control-types/-/cache-control-types-1.0.3.tgz#5da62cf64c3b4419dabfef4536b57a40c8ff0b47"
@@ -24778,10 +24764,10 @@ pino-std-serializers@^7.0.0:
2477824764
resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-7.0.0.tgz#7c625038b13718dbbd84ab446bd673dc52259e3b"
2477924765
integrity sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==
2478024766

24781-
pino@9.9.4:
24782-
version "9.9.4"
24783-
resolved "https://registry.yarnpkg.com/pino/-/pino-9.9.4.tgz#21ed2c27cc177f797e3249c99d340f0bcd6b248e"
24784-
integrity sha512-d1XorUQ7sSKqVcYdXuEYs2h1LKxejSorMEJ76XoZ0pPDf8VzJMe7GlPXpMBZeQ9gE4ZPIp5uGD+5Nw7scxiigg==
24767+
pino@9.10.0:
24768+
version "9.10.0"
24769+
resolved "https://registry.yarnpkg.com/pino/-/pino-9.10.0.tgz#b78555637605ef6f4287e51a89b2087d66da4859"
24770+
integrity sha512-VOFxoNnxICtxaN8S3E73pR66c5MTFC+rwRcNRyHV/bV/c90dXvJqMfjkeRFsGBDXmlUN3LccJQPqGIufnaJePA==
2478524771
dependencies:
2478624772
atomic-sleep "^1.0.0"
2478724773
fast-redact "^3.1.1"

0 commit comments

Comments
 (0)