Skip to content

Commit

Permalink
Merge branch 'main' into upd-aws-detector
Browse files Browse the repository at this point in the history
  • Loading branch information
garysassano authored Feb 8, 2025
2 parents 213a78b + ce62d8c commit 71b122f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ features for unmaintained components. At least one sponsor is needed to lift the
adding the requested feature. Sponsors are expected to provide reviews for that feature and be responsive on the issue.

Components marked as unmaintained still receive semantic conventions updates and bugfixes where possible.
[@open-telemetry/javascript-triagers](https://github.com/orgs/open-telemetry/teams/javascript-triagers) may add the
[@open-telemetry/javascript-contrib-triagers](https://github.com/orgs/open-telemetry/teams/javascript-contrib-triagers) may add the
`type:semconv-update` or `bug` label to mark them as exempt from being auto-closed within two weeks.

A component which is unmaintained may be deprecated if there is a problem that is not fixed in a timely manner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ export class PinoInstrumentation extends InstrumentationBase<PinoInstrumentation
const origStream = logger[moduleExports.symbols.streamSym];
logger[moduleExports.symbols.streamSym] = moduleExports.multistream(
[
{ level: logger.level, stream: origStream },
{ level: logger.level, stream: otelStream },
// Use level `0` to never not log a record given to the stream.
{ level: 0, stream: origStream },
{ level: 0, stream: otelStream },
],
{ levels: logger.levels.values }
);
Expand Down
43 changes: 43 additions & 0 deletions plugins/node/opentelemetry-instrumentation-pino/test/pino.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,49 @@ describe('PinoInstrumentation', () => {
});
});

it('emits log records to a lower level after level change', () => {
const logRecords = memExporter.getFinishedLogRecords();

logger.debug('first msg at debug');
logger.trace('first msg at trace'); // Should *not* see this.

logger.level = 'trace';
logger.debug('second msg at debug');
logger.trace('second msg at trace'); // *Should* see this.

assert.strictEqual(logRecords.length, 3);
assert.strictEqual(logRecords[0].severityNumber, SeverityNumber.DEBUG);
assert.strictEqual(logRecords[0].severityText, 'debug');
assert.strictEqual(logRecords[0].body, 'first msg at debug');
assert.strictEqual(logRecords[1].severityNumber, SeverityNumber.DEBUG);
assert.strictEqual(logRecords[1].severityText, 'debug');
assert.strictEqual(logRecords[1].body, 'second msg at debug');
assert.strictEqual(logRecords[2].severityNumber, SeverityNumber.TRACE);
assert.strictEqual(logRecords[2].severityText, 'trace');
assert.strictEqual(logRecords[2].body, 'second msg at trace');
});

it('emits log records from child logger at lower level', () => {
const logRecords = memExporter.getFinishedLogRecords();

const child = logger.child({ childField: 42 }, { level: 'trace' });

logger.debug('logger at debug level');
logger.trace('logger at trace level'); // Should *not* see this one.
child.debug('child at debug level');
child.trace('child at trace level'); // *Should* see this one.
assert.strictEqual(logRecords.length, 3);
assert.strictEqual(logRecords[0].severityNumber, SeverityNumber.DEBUG);
assert.strictEqual(logRecords[0].severityText, 'debug');
assert.strictEqual(logRecords[0].body, 'logger at debug level');
assert.strictEqual(logRecords[1].severityNumber, SeverityNumber.DEBUG);
assert.strictEqual(logRecords[1].severityText, 'debug');
assert.strictEqual(logRecords[1].body, 'child at debug level');
assert.strictEqual(logRecords[2].severityNumber, SeverityNumber.TRACE);
assert.strictEqual(logRecords[2].severityText, 'trace');
assert.strictEqual(logRecords[2].body, 'child at trace level');
});

it('does not emit to the Logs SDK if disableLogSending=true', () => {
instrumentation.setConfig({ disableLogSending: true });

Expand Down

0 comments on commit 71b122f

Please sign in to comment.