-
Notifications
You must be signed in to change notification settings - Fork 142
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
✨ [RUMF-922] stack trace on handled calls #889
Conversation
11d3d24
to
01d9fba
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #889 +/- ##
==========================================
- Coverage 89.13% 89.09% -0.04%
==========================================
Files 81 81
Lines 3809 3825 +16
Branches 850 851 +1
==========================================
+ Hits 3395 3408 +13
- Misses 414 417 +3 ☔ View full report in Codecov by Sentry. |
01d9fba
to
972ce8e
Compare
packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.spec.ts
Outdated
Show resolved
Hide resolved
90ceb76
to
59b0aa4
Compare
59b0aa4
to
c7ec309
Compare
it('should get handling stack trace without instrumental function calls', () => { | ||
userCallOne() | ||
|
||
const formattedStackTrace = toStackTraceString(stackTrace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of coupling handling stack tests with the implementation of toStackTraceString
, what about directly returning a stack trace string from createHandlingStackTrace
?
it would also avoid callers to do this conversion later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about it. I tried to be consistent with the way we handle the "normal" stack trace.
browser-sdk/packages/core/src/domain/automaticErrorCollection.ts
Lines 57 to 65 in 1f8b7c6
function buildErrorFromParams(params: unknown[], handlingStack: StackTrace) { | |
const firstErrorParam = find(params, (param: unknown): param is Error => param instanceof Error) | |
return { | |
message: ['console error:', ...params].map((param) => formatConsoleParameters(param)).join(' '), | |
stack: firstErrorParam ? toStackTraceString(computeStackTrace(firstErrorParam)) : undefined, | |
handlingStack: toStackTraceString(handlingStack), | |
} | |
} |
Also, by looking at error.ts, it seems that the idea was to keep stack traces as
StackTrace
type and to be able to make transformation on them.browser-sdk/packages/core/src/tools/error.ts
Lines 39 to 43 in 1f8b7c6
export function formatUnknownError( | |
stackTrace: StackTrace | undefined, | |
errorObject: any, | |
nonErrorPrefix: string, | |
handlingStack?: StackTrace |
Maybe I should change the test to only test the stack trace as StackTrace
type and not as string. It would also make sens because the toStackTraceString
has already been tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StackTrace
is a tracekit type, it seems ok to me to keep it for tracekit API output but I'd be in favor of avoiding to use it internally if we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay done
packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.spec.ts
Outdated
Show resolved
Hide resolved
6105755
to
e2bb68c
Compare
e2bb68c
to
a9f74a3
Compare
packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.spec.ts
Outdated
Show resolved
Hide resolved
…llection.spec.ts Co-authored-by: Bastien Caudan <bastien.caudan@datadoghq.com>
Co-authored-by: Bastien Caudan <bastien.caudan@datadoghq.com>
Motivation
Some errors are reported without a proper Error object. In these cases, there is no stack trace reported, making them a lot less actionable by the user. In order to enrich these errors, RUM need to generate a stack trace internally.
Changes
Testing
Unit, Locally
I have gone over the contributing documentation.