Skip to content
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

Improved logging mechanism for operations on ended spans, making it easier to trace issues in both Node.js and Browser environments #5113 #5184

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Victorsesan
Copy link

No description provided.

…ded spans, making it easier to trace issues in both Node.js and Browser environments

Reviewer: pichlermarc
Refs: open-telemetry#5113
…ded spans, making it easier to trace issues in both Node.js and Browser environments

Reviewer: pichlermarc
Refs: open-telemetry#5113
@Victorsesan Victorsesan requested a review from a team as a code owner November 20, 2024 13:37
@Victorsesan
Copy link
Author

👋@pichlermarc this good?

);
// Adding a debug log to capture the stack trace
diag.debug(`Stack trace for ended span operation: ${new Error().stack}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Using just the stack trace string leads to dev tools not being able to apply custom formatting it does to error object - most notably the ability to jump to source code, which becomes inconsistent

// Test 1
console.log(`stack test - inline - ${new Error().stack}`);

// Test 2
console.log('stack test - arg2', new Error().stack);

// Test 3
console.log('stack test - error obj', new Error());

In chrome, the experience is okay as chrome auto-linkifys links
image

... as long as you don't expect to use sourcemaps - you just get lead into the built file instead of the source
image
image

(realistically at otel bundle size, yeah I'll take sourcemaps thanks)

while firefox doesn't touch non-error objects
image

But it's also an issue when debugging node over --inspect, chrome tries it's best to find some links but only the Error object version is correct:

node --inspect-brk .\logger_test.js

image

(at this point it's also worth considering if it's better to change issue requirements to just change into .warn(message, Error) as diag api allows 2nd+ argument to be unknown)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[sdk-trace-base] add debug-level log with stack trace when modifying neded span
3 participants