Skip to content

Commit 88bf3ea

Browse files
committed
Add child tests
1 parent 5d5a1ff commit 88bf3ea

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

dev-packages/node-integration-tests/suites/pino/scenario-track.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ Sentry.withIsolationScope(() => {
1717
setTimeout(() => {
1818
Sentry.withIsolationScope(() => {
1919
Sentry.startSpan({ name: 'later' }, () => {
20-
logger.error(new Error('oh no'));
20+
// This child should be captured as we marked the parent logger to be tracked
21+
const child = logger.child({ module: 'authentication' });
22+
child.error(new Error('oh no'));
23+
24+
// This child should be ignored
25+
const child2 = logger.child({ module: 'authentication.v2' });
26+
Sentry.pinoIntegration.ignoreLogger(child2);
27+
child2.error(new Error('oh no v2'));
28+
29+
// This should also be ignored as the parent is ignored
30+
const child3 = child2.child({ module: 'authentication.v3' });
31+
child3.error(new Error('oh no v3'));
2132
});
2233
});
2334
}, 1000);

dev-packages/node-integration-tests/suites/pino/scenario.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import pino from 'pino';
44
const logger = pino({ name: 'myapp' });
55

66
const ignoredLogger = pino({ name: 'ignored' });
7-
Sentry.pinoIntegration.untrackLogger(ignoredLogger);
7+
Sentry.pinoIntegration.ignoreLogger(ignoredLogger);
88

99
ignoredLogger.info('this will not be tracked');
1010

dev-packages/node-integration-tests/suites/pino/test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ conditionalTest({ min: 20 })('Pino integration', () => {
195195
type: 'string',
196196
value: '{"more":3,"complex":"nope"}',
197197
},
198+
msg: { value: 'hello world', type: 'string' },
198199
'sentry.origin': { value: 'auto.logging.pino', type: 'string' },
199200
'sentry.release': { value: '1.0', type: 'string' },
200201
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
@@ -208,6 +209,8 @@ conditionalTest({ min: 20 })('Pino integration', () => {
208209
severity_number: 17,
209210
attributes: {
210211
name: { value: 'myapp', type: 'string' },
212+
module: { value: 'authentication', type: 'string' },
213+
msg: { value: 'oh no', type: 'string' },
211214
'pino.logger.level': { value: 50, type: 'integer' },
212215
'sentry.origin': { value: 'auto.logging.pino', type: 'string' },
213216
'sentry.release': { value: '1.0', type: 'string' },

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ interface PinoIntegrationFunction {
203203
*
204204
* @param logger A Pino logger instance.
205205
*/
206-
untrackLogger(logger: unknown): void;
206+
ignoreLogger(logger: unknown): void;
207207
}
208208

209209
/**
210210
* Integration for Pino logging library.
211211
* Captures Pino logs as Sentry logs and optionally captures some log levels as events.
212212
*
213-
* By default, all Pino loggers will be captured. To ignore a specific logger, use `pinoIntegration.untrackLogger(logger)`.
213+
* By default, all Pino loggers will be captured. To ignore a specific logger, use `pinoIntegration.ignoreLogger(logger)`.
214214
*
215215
* If you disable automatic instrumentation with `autoInstrument: false`, you can mark specific loggers to be tracked with `pinoIntegration.trackLogger(logger)`.
216216
*
@@ -222,7 +222,7 @@ export const pinoIntegration = Object.assign(_pinoIntegration, {
222222
(logger as Pino)[SENTRY_TRACK_SYMBOL] = 'track';
223223
}
224224
},
225-
untrackLogger(logger: unknown): void {
225+
ignoreLogger(logger: unknown): void {
226226
if (logger && typeof logger === 'object' && 'levels' in logger) {
227227
(logger as Pino)[SENTRY_TRACK_SYMBOL] = 'ignore';
228228
}

0 commit comments

Comments
 (0)