sentry-javascript
sentry-javascript copied to clipboard
Instrument the Promise object to create spans
Let's explore instrumenting the promise object, so we can "auto-instrument" async/await calls.
some thoughts gathered:
you perhaps could use a millisecond boundary to omit instantly resolving promises
Promise is an interesting way of generically capture long running js tasks
if you instrument the promise how do you figure out what’s being called?
On the subject of monkey patching Promise...
How about optionally recording stack traces as they pass through promises to work around "zero-cost async stack traces"?
The number of times I've got almost useless stack traces due to this!
@timfish It's great you bring this up - since we've been looking at async stacktraces with https://github.com/getsentry/sentry-javascript/discussions/5334.
If you got some bandwidth, feel free to explore and investigate here, any improvements we can make would be amazing.
It's worth noting that while we can instrument global.Promise, we cannot instrument the internal [[Promise]] that's used for async function.