grafana / faro-web-sdk

The Grafana Faro Web SDK, part of the Grafana Faro project, is a highly configurable web SDK for real user monitoring (RUM) that instruments browser frontend applications to capture observability signals. Frontend telemetry can then be correlated with backend and infrastructure data for full-stack observability.
https://grafana.com/oss/faro/
Apache License 2.0
739 stars 64 forks source link

Using Task Scheduling API #562

Open AMontagu opened 5 months ago

AMontagu commented 5 months ago

Description

Web browsers implement an task scheduling api: https://developer.mozilla.org/en-US/docs/Web/API/Prioritized_Task_Scheduling_API

It may be interesting to use it to create/send log as they are not critical to the application. Maybe there is already a similar system in faro but I didn't find one.

This is really not urgent but may be an interesting improvement for heavy loading application.

Important to note that an other solution that may be in the process and replace this need is the usage of web worker so the log are sended in another thread but it may be way more complicated to implement.

Proposed solution

Using the postTask with "background" priority for all logging.

yulafezmesi commented 5 months ago

would be nice if you guys doing this. i had to disable log dispatcher because of locking main thread.

kesavkolla commented 4 months ago

Another way to offload from main thread is to use sync API. https://developer.mozilla.org/en-US/docs/Web/API/Background_Synchronization_API

Would be nice to push data to service worker and let the worker send to backend.