Skip to content

feat(instrumentation-console): Add console intrumentation#3445

Open
hectorhdzg wants to merge 4 commits intoopen-telemetry:mainfrom
hectorhdzg:hectorhdzg/consoleinstr
Open

feat(instrumentation-console): Add console intrumentation#3445
hectorhdzg wants to merge 4 commits intoopen-telemetry:mainfrom
hectorhdzg:hectorhdzg/consoleinstr

Conversation

@hectorhdzg
Copy link
Copy Markdown
Member

Adding console instrumentation, following similar configurations and functionality in other Log instrumentations in this project like Bunyan, Winston and Pino

#3444

@hectorhdzg hectorhdzg requested review from a team as code owners March 18, 2026 17:21
@github-actions github-actions bot requested a review from JacksonWeber March 18, 2026 17:22
@hectorhdzg hectorhdzg changed the title Add console intrumentation [feat] Add console intrumentation Mar 18, 2026
@hectorhdzg hectorhdzg changed the title [feat] Add console intrumentation feat(instrumentation-console) Add console intrumentation Mar 18, 2026
@hectorhdzg hectorhdzg changed the title feat(instrumentation-console) Add console intrumentation feat(instrumentation-console): Add console intrumentation Mar 18, 2026
});

it('emits LogRecord for console.trace', () => {
console.trace('trace message');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're ensuring that console.trace() contains the message field here, but trace should also print a stack trace. We should ensure that the stack is also captured with this instrumentation.

Copy link
Copy Markdown
Contributor

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, but overall LGTM.

@pichlermarc
Copy link
Copy Markdown
Member

Might be worth syncing with the browser SIG, they also currently have a PR open, but they'll likely integrate it into their single instrumentation package:
open-telemetry/opentelemetry-browser#98

@hectorhdzg
Copy link
Copy Markdown
Member Author

@pichlermarc this is specific to Node.js console not browser, we should ensure there are no name conflicts and customer confusion, I can rename this package to @opentelemetry/instrumentation-console-nodejs or something like that, what you think?

this._originals = new Map();
}
for (const method of Object.keys(CONSOLE_METHODS)) {
const original = (console as any)[method];
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not using require/import in the middle, that would work if people import manually the console from their code, that is usually not the case and people rely on global console.

@trentm
Copy link
Copy Markdown
Contributor

trentm commented Mar 25, 2026

can rename this package to @opentelemetry/instrumentation-console-nodejs or something like that, what you think?

+1. FWIW, we've used "-node" suffix in a couple cases:

% ls ~/src/opentelemetry-js-contrib/packages | rg node
auto-instrumentations-node
instrumentation-runtime-node

So perhaps instrumentation-console-node.

@pichlermarc
Copy link
Copy Markdown
Member

can rename this package to @opentelemetry/instrumentation-console-nodejs or something like that, what you think?

+1. FWIW, we've used "-node" suffix in a couple cases:

% ls ~/src/opentelemetry-js-contrib/packages | rg node
auto-instrumentations-node
instrumentation-runtime-node

So perhaps instrumentation-console-node.

-node suffix sounds good to me. 👍

@hectorhdzg hectorhdzg force-pushed the hectorhdzg/consoleinstr branch from 759b2a3 to f25d731 Compare March 31, 2026 00:13
@github-actions github-actions bot requested a review from JacksonWeber March 31, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants