Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Trace Cancellation

I want to measure the time of a task in my app using firebase performance traces; however, I don't want to include time when the user backgrounds the app. I can't find a way to cancel the task if the task is no longer needed.

For example

  1. I start the task
  2. The user backgrounds the app
  3. The user returns to the app
  4. The task continues and completes

How do I ensure that the time the app was backgrounded doesn't affect my metrics? I would assume throwing out those samples would work but there is no cancel method.

like image 890
Zachary Sweigart Avatar asked Sep 01 '25 00:09

Zachary Sweigart


1 Answers

If you don't want a trace to be reported, simply don't call stop() on it. A Trace doesn't actively do anything at all until you do call stop().

like image 133
Doug Stevenson Avatar answered Sep 03 '25 00:09

Doug Stevenson