-
Notifications
You must be signed in to change notification settings - Fork 100
feat(web-sdk): Properly allow users to override stack frame parsing settings #1316
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
base: main
Are you sure you want to change the base?
Conversation
should i write tests for the error instrumentation and passing in the parameters to the browser config? |
packages/web-sdk/src/instrumentations/errors/instrumentation.ts
Outdated
Show resolved
Hide resolved
packages/web-sdk/src/instrumentations/errors/instrumentation.ts
Outdated
Show resolved
Hide resolved
Hi @elee1766 thanks a lot for the PR. Cheers, |
ok ive done this. i think this is a lot cleaner |
Hey @elee1766 thanks a lot for all the changes. We need to leverage this functionality. Though ist's not respected by the auto instrumentations yet. Example export function registerOnunhandledrejection(api: API): void {
window.addEventListener('unhandledrejection', (evt: ExtendedPromiseRejectionEvent) => {
//...
} else {
[value, type, stackFrames] = getErrorDetails(error, api.getStacktraceParser());
}
//...
});
} Let me know if you need more information or any support. Cheers Edit: |
yeah so i didnt use it because that function wasnt respected by auto instrumentation (and also wasnt exposed, i think?) i can do this |
Yes that's 100% correct.
|
so you said
digging deeper - it seems that this parseStackTrace is the initial setting for the Exceptions apis value for stacktraceparser, and the exceptions api then stores its own stacktraceparser i think in the function object scope or whatever for modification. maybe it is correct to allow passing this parameter in from the web configuration? its a bit confusing that the property here that supposedly would be passed to other things only modifies the exceptions api, and then wont necessarily match because of changeStackTraceParser. changeStacktraceParser is sort of weird to be honest existing in the first place. its not even exposed right now. does it make more sense to just.. remove changeStacktraceParser? |
Yes that's a bit weird. When changing the parser it is applied to API calls only but not to the auto instrumentation.
Yes this should be the goal. Provide a property in the config to defined a custom parser.
That's correct. It's imho a bug.
You mean having a function AND a config option at the same time right?
That's what I meant with "bug in the Config type" cheers |
Maybe this helps a bit (just in case if didn't already find it).
|
ok. this makes sense to me. I think that dynamically changing the stacktrace parser might have been used to make testing simpler or something. I will make these changes then and see how it looks. I like the idea of having a single source of truth configuration variable for the stack trace parser. |
Great and many thanks 🙏 |
hi @codecapitano sorry for the delay. let me know how this looks. |
@elee1766 many thanks ad also sorry from my side for the delay. Cheers |
export function getErrorDetails(evt: ErrorEvent): [string | undefined, string | undefined, ExceptionStackFrame[]] { | ||
export function getErrorDetails( | ||
evt: ErrorEvent, | ||
stacktraceParser: StacktraceParser = newStackTraceParser() |
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.
Let's use parseStacktrace
from the config? under the hood it's the same parsing logic.
We can update parseStacktrace
to take the optional options object.
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.
Another option could be to receive the parser from api.getStacktraceParser
Looks like we currently have three functions doing teh same thing.
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.
in actual usage the parser is received here by api.getStacktraceParser
export function getDetailsFromErrorArgs(args: [any?, ...any[]]): ErrorDetails { | ||
export function getDetailsFromErrorArgs( | ||
args: [any?, ...any[]], | ||
stacktraceParser: StacktraceParser = newStackTraceParser() |
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.
Same here, why not use parseStacktrace
?
@codecapitano are you asking why not just use the function instead of the um, stacktracer parser interface? yeah i dont know really. I'm happy to get rid of the stack trace parser interface and unify everything to just use the parseStackTrace function type. i only did it like this because StacktraceParser interface existed so i thought there was some reason you guys wanted it to exist so i kept using it. not sure if there is some reason its there |
Yes it's a bit unfortunate but it's a great opportunity to clean things up here and make things a bit easier to maintain. |
ok so what i did here was remove getStacktraceParser. i think i prefer this so that people can do fully custom implementation instead of having them pass options. |
hi @codecapitano bumping here |
Why
Certain extensions and libraries may throw exceptions with very long line lengths. These lines can cause the stack trace parser to lock up the browser thread, which is undesirable.
It would be desirable for sites that require the use of these extensions or libraries to be able to override stack trace parsing settings, such that they may sacrifice their stack trace quality for site performance.
What
I did this because it currently lives under the error instrumentation package, but that doesn't make sense, as it is not only use by the error instrumentation package, but also the stack trace parser that is passed in the makeCoreConfig that ultimately gets used by the core config. it seems more correct for it therefore to live in utils.
i've added the ability to pass in ones own stack trace parser to the browser config. this will be respected and this function is what will passed as parseStacktrace in the faro config.
create function
newStackTraceParser
which creates a StacktraceParser using new type StackframeParserOptions, which includes a single optional field for maximumLineLengthmake ErrorInstrumentation use the stacktraceParser from the faro global config so all this stuff is configured from one place
Links
#844
Checklist