ending automatic transactions in a graceful way
See original GitHub issueOur transaction end detection logic for all transactions type except page-load
is a bit eager now and might fail to capture spans that happen in the frames that happen after the nextTick.
During the route-change events, there are multiple ways users would be invoking external API calls, can be sync, concurrent/parallel or even lazy load some components based on the API calls. Right now our framework integrations rely on the internal lifecycle events of the respective frameworks and tries to end the transaction as soon as the component is mounted to the DOM.
With this approach, we might be able to only capture only the API calls that are requested during the component mounting and might fail to capture calls that are done after the component is mounted to the DOM.
Solution
- Instead of closing the transaction as soon as the children components are mounted or when the route change navigation is done, We could actively wait and listen for few frames (for now we can listen for 5 successive ticks/animation frames) and decide if we want to close the transaction.
- If there are no calls within those 5 ticks, we close the transaction immediately and send it to the APM server.
- If there are any spans, assume a call happens on the 3rd frame, then we schedule another 5 frames and end the transaction accordingly.
- In order to reduce the noise in the transaction, our transaction would always get time shifted to the last active transaction. Ex - if there are 2 spans that happens in the 2nd tick after the transaction start, we end the transaction with the end time of the longest span and send it to the server.
- With our filtering logic, transaction without any spans will not be reported to the server.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Had a quick look, it seems like a bug and I will create a new issue to track it. Thanks a lot @anotheri for providing lot of details 😃
Had a discussion with @jahtalab and we have agreed for wait for couple of frames and adjust the transaction end timings to previous time if no interesting events occur within the waited frames.