Skip to content

fix: remove debug logs and use the diag logger for init timings #1861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions nodejs/packages/layer/src/init.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ const WRAPPER_INIT_START_TIME = Date.now();
const { default: wrapper } = await import('./wrapper.js');
await wrapper.init();
await wrapper.wrap();
console.log('OpenTelemetry wrapper init completed in', Date.now() - WRAPPER_INIT_START_TIME, 'ms');

wrapper.logDebug('OpenTelemetry wrapper init completed in', Date.now() - WRAPPER_INIT_START_TIME, 'ms');

const LOADER_INIT_START_TIME = Date.now();
await import('./loader.mjs');
console.log('OpenTelemetry loader init completed in', Date.now() - LOADER_INIT_START_TIME, 'ms');
wrapper.logDebug('OpenTelemetry loader init completed in', Date.now() - LOADER_INIT_START_TIME, 'ms');
4 changes: 3 additions & 1 deletion nodejs/packages/layer/src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,9 @@ export async function init() {
initialized = true;
}

console.log('Registering OpenTelemetry');
export function logDebug(message: string, ...args: unknown[]) {
diag.debug(message, ...args);
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this needs to be a separate function rather than calling debug directly from the callers?

Copy link
Contributor

Choose a reason for hiding this comment

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

When everything is bundled, any OTEL module (including diag) is not directly available to the outside of wrapper. It can be solved by configuring webpack to bundle diag out individually, but it will just complicate the things. So, I think, it is better to have init.mjs handling the things over wrapper instead of having directt dependency.

Copy link
Member Author

Choose a reason for hiding this comment

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

@serkan-ozal exactly!

}

let initialized = false;
let instrumentations: Instrumentation[];
Expand Down