Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bf70c17
feat: Tidy existing loader hook
timfish Sep 8, 2025
9ee96ab
Oh linty
timfish Sep 8, 2025
9a57643
fix detection
timfish Sep 8, 2025
9fb250e
Use `NODE_MAJOR` and `NODE_MINOR`
timfish Sep 9, 2025
94a22de
Merge branch 'develop' into timfish/feat/tidy-loader-hooks
timfish Sep 10, 2025
594286c
feat: `pino` integration
timfish Sep 10, 2025
1699704
Merge remote-tracking branch 'upstream/develop' into timfish/feat/pin…
timfish Sep 10, 2025
630a8c7
Update deps
timfish Sep 12, 2025
fd32e77
Merge remote-tracking branch 'upstream/develop' into timfish/feat/pin…
timfish Sep 12, 2025
c2f81e1
Oh lint!
timfish Sep 12, 2025
850c19d
Correct yarn.lock
timfish Sep 12, 2025
144b7db
Merge branch 'develop' into timfish/feat/pino-integration
timfish Sep 12, 2025
7610cda
Tests
timfish Sep 15, 2025
e598c6a
Merge branch 'timfish/feat/pino-integration' of github.com:getsentry/…
timfish Sep 15, 2025
2647b20
More test fixes
timfish Sep 15, 2025
e0f6a40
Merge branch 'develop' into timfish/feat/pino-integration
timfish Sep 15, 2025
6089389
Fix size limit
timfish Sep 15, 2025
687a619
Merge branch 'timfish/feat/pino-integration' of github.com:getsentry/…
timfish Sep 15, 2025
6b8f76e
Merge branch 'develop' into timfish/feat/pino-integration
timfish Sep 15, 2025
421ad50
Make hook tree-shakable
timfish Sep 18, 2025
b12150c
Pino added tracing channel
timfish Sep 18, 2025
d61b2e6
Merge branch 'develop' into timfish/feat/pino-integration
timfish Sep 18, 2025
40bf557
Merge branch 'timfish/feat/pino-integration' of github.com:getsentry/…
timfish Sep 18, 2025
30a6688
Better bundling?
timfish Sep 18, 2025
412cc67
Fixes
timfish Sep 18, 2025
2e14fbe
Fix Pino >= 9.10.0
timfish Sep 18, 2025
1115467
Lint
timfish Sep 18, 2025
ab7bce3
Merge branch 'develop' into timfish/feat/pino-integration
timfish Sep 19, 2025
8b5a821
Fix yarn.lock
timfish Sep 19, 2025
0715f38
Update deps
timfish Sep 19, 2025
7a207f4
Merge branch 'develop' into timfish/feat/pino-integration
timfish Sep 19, 2025
1a72eab
Just copy attributes
timfish Sep 19, 2025
ac49a64
PR review
timfish Sep 21, 2025
4f50a93
Merge remote-tracking branch 'upstream/develop' into timfish/feat/pin…
timfish Oct 2, 2025
c1f6870
update deps
timfish Oct 2, 2025
1a4b10e
remove yarn.lock dupes
timfish Oct 2, 2025
11f77b5
Test on latest Pino with integrated channel
timfish Oct 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const DEPENDENTS: Dependent[] = [
'NODE_VERSION',
'childProcessIntegration',
'systemErrorIntegration',
'pinoIntegration',
],
},
{
Expand Down
2 changes: 2 additions & 0 deletions dev-packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
"node-schedule": "^2.1.1",
"openai": "5.18.1",
"pg": "8.16.0",
"pino": "9.9.4",
"pino-next": "npm:pino@^9.12.0",
"postgres": "^3.4.7",
"prisma": "6.15.0",
"proxy": "^2.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Sentry from '@sentry/node';

Sentry.init({
dsn: process.env.SENTRY_DSN,
release: '1.0',
enableLogs: true,
integrations: [Sentry.pinoIntegration({ error: { levels: ['error', 'fatal'] } })],
});
18 changes: 18 additions & 0 deletions dev-packages/node-integration-tests/suites/pino/scenario-next.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as Sentry from '@sentry/node';
import pino from 'pino-next';

const logger = pino({});

Sentry.withIsolationScope(() => {
Sentry.startSpan({ name: 'startup' }, () => {
logger.info({ user: 'user-id', something: { more: 3, complex: 'nope' } }, 'hello world');
});
});

setTimeout(() => {
Sentry.withIsolationScope(() => {
Sentry.startSpan({ name: 'later' }, () => {
logger.error(new Error('oh no'));
});
});
}, 1000);
18 changes: 18 additions & 0 deletions dev-packages/node-integration-tests/suites/pino/scenario.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as Sentry from '@sentry/node';
import pino from 'pino';

const logger = pino({});

Sentry.withIsolationScope(() => {
Sentry.startSpan({ name: 'startup' }, () => {
logger.info({ user: 'user-id', something: { more: 3, complex: 'nope' } }, 'hello world');
});
});

setTimeout(() => {
Sentry.withIsolationScope(() => {
Sentry.startSpan({ name: 'later' }, () => {
logger.error(new Error('oh no'));
});
});
}, 1000);
172 changes: 172 additions & 0 deletions dev-packages/node-integration-tests/suites/pino/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import { join } from 'path';
import { expect, test } from 'vitest';
import { conditionalTest } from '../../utils';
import { createRunner } from '../../utils/runner';

conditionalTest({ min: 20 })('Pino integration', () => {
test('has different trace ids for logs from different spans', async () => {
const instrumentPath = join(__dirname, 'instrument.mjs');

await createRunner(__dirname, 'scenario.mjs')
.withMockSentryServer()
.withInstrument(instrumentPath)
.ignore('event')
.expect({
log: log => {
const traceId1 = log.items?.[0]?.trace_id;
const traceId2 = log.items?.[1]?.trace_id;
expect(traceId1).not.toBe(traceId2);
},
})
.start()
.completed();
});

test('captures event and logs', async () => {
const instrumentPath = join(__dirname, 'instrument.mjs');

await createRunner(__dirname, 'scenario.mjs')
.withMockSentryServer()
.withInstrument(instrumentPath)
.expect({
event: {
exception: {
values: [
{
type: 'Error',
value: 'oh no',
mechanism: {
type: 'pino',
handled: true,
},
stacktrace: {
frames: expect.arrayContaining([
expect.objectContaining({
function: '?',
in_app: true,
module: 'scenario',
context_line: " logger.error(new Error('oh no'));",
}),
]),
},
},
],
},
},
})
.expect({
log: {
items: [
{
timestamp: expect.any(Number),
level: 'info',
body: 'hello world',
trace_id: expect.any(String),
severity_number: 9,
attributes: expect.objectContaining({
'sentry.origin': { value: 'auto.logging.pino', type: 'string' },
'sentry.pino.level': { value: 30, type: 'integer' },
user: { value: 'user-id', type: 'string' },
something: {
type: 'string',
value: '{"more":3,"complex":"nope"}',
},
'sentry.release': { value: '1.0', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
}),
},
{
timestamp: expect.any(Number),
level: 'error',
body: 'oh no',
trace_id: expect.any(String),
severity_number: 17,
attributes: expect.objectContaining({
'sentry.origin': { value: 'auto.logging.pino', type: 'string' },
'sentry.pino.level': { value: 50, type: 'integer' },
err: { value: '{}', type: 'string' },
'sentry.release': { value: '1.0', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
}),
},
],
},
})
.start()
.completed();
});

test('captures with Pino integrated channel', async () => {
const instrumentPath = join(__dirname, 'instrument.mjs');

await createRunner(__dirname, 'scenario-next.mjs')
.withMockSentryServer()
.withInstrument(instrumentPath)
.expect({
event: {
exception: {
values: [
{
type: 'Error',
value: 'oh no',
mechanism: {
type: 'pino',
handled: true,
},
stacktrace: {
frames: expect.arrayContaining([
expect.objectContaining({
function: '?',
in_app: true,
module: 'scenario-next',
context_line: " logger.error(new Error('oh no'));",
}),
]),
},
},
],
},
},
})
.expect({
log: {
items: [
{
timestamp: expect.any(Number),
level: 'info',
body: 'hello world',
trace_id: expect.any(String),
severity_number: 9,
attributes: expect.objectContaining({
'sentry.origin': { value: 'auto.logging.pino', type: 'string' },
'sentry.pino.level': { value: 30, type: 'integer' },
user: { value: 'user-id', type: 'string' },
something: {
type: 'string',
value: '{"more":3,"complex":"nope"}',
},
'sentry.release': { value: '1.0', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
}),
},
{
timestamp: expect.any(Number),
level: 'error',
body: 'oh no',
trace_id: expect.any(String),
severity_number: 17,
attributes: expect.objectContaining({
'sentry.origin': { value: 'auto.logging.pino', type: 'string' },
'sentry.pino.level': { value: 50, type: 'integer' },
err: { value: '{}', type: 'string' },
'sentry.release': { value: '1.0', type: 'string' },
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
}),
},
],
},
})
.start()
.completed();
});
});
1 change: 1 addition & 0 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export {
onUnhandledRejectionIntegration,
openAIIntegration,
parameterize,
pinoIntegration,
postgresIntegration,
postgresJsIntegration,
prismaIntegration,
Expand Down
1 change: 1 addition & 0 deletions packages/aws-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export {
mysql2Integration,
redisIntegration,
tediousIntegration,
pinoIntegration,
postgresIntegration,
postgresJsIntegration,
prismaIntegration,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/utils/worldwide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export type InternalGlobal = {
*/
_sentryModuleMetadata?: Record<string, any>;
_sentryEsmLoaderHookRegistered?: boolean;
_sentryInjectLoaderHookRegister?: () => void;
_sentryInjectLoaderHookRegistered?: boolean;
} & Carrier;

/** Get's the global object for the current JavaScript runtime */
Expand Down
1 change: 1 addition & 0 deletions packages/google-cloud-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export {
mysql2Integration,
redisIntegration,
tediousIntegration,
pinoIntegration,
postgresIntegration,
postgresJsIntegration,
prismaIntegration,
Expand Down
2 changes: 2 additions & 0 deletions packages/node-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@
"dependencies": {
"@sentry/core": "10.17.0",
"@sentry/opentelemetry": "10.17.0",
"@apm-js-collab/tracing-hooks": "^0.3.1",
"import-in-the-middle": "^1.14.2"
},
"devDependencies": {
"@apm-js-collab/code-transformer": "^0.8.2",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/context-async-hooks": "^2.1.0",
"@opentelemetry/core": "^2.1.0",
Expand Down
1 change: 1 addition & 0 deletions packages/node-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export { spotlightIntegration } from './integrations/spotlight';
export { systemErrorIntegration } from './integrations/systemError';
export { childProcessIntegration } from './integrations/childProcess';
export { createSentryWinstonTransport } from './integrations/winston';
export { pinoIntegration } from './integrations/pino';

export { SentryContextManager } from './otel/contextManager';
export { setupOpenTelemetryLogger } from './otel/logger';
Expand Down
Loading
Loading