How do I run a Performance Trace multiple times in Parallel?
Solution 1
As the error message says, there can only be a single trace with a unique name active at any time. So you'll either have to wait for the first my_trace
to finish before starting the second (running them sequentially instead of in parallel), or you'll have to generate a unique name for each trace.
Given how the API is structured it should be possible to allow multiple traces of the same name to run in parallel. If you think Firebase should consider allowing that, I recommend you file a feature request.
Solution 2
You can record it manually by storing the start time yourself and then just recording the duration. This should work.
Reference: https://firebase.google.com/docs/reference/js/firebase.performance.Trace#record
![creativecreatorormaybenot](https://i.stack.imgur.com/EIh1y.png?s=256&g=1)
creativecreatorormaybenot
Updated on December 14, 2022Comments
-
creativecreatorormaybenot over 1 year
I have a Firebase Performance Monitoring trace called
my_trace
.Now, I start this trace when I load an image:
void loadImage() { final Trace trace = performance.newTrace("my_trace"); trace.start(); // ... (loading that happens asynchronously) trace.stop(); }
This works fine when I try to load a single image, however, in my application I need to load many images in parallel.
This means that the following error is reported when I load my images:Trace 'my_trace' has already started, should not start again!
How do I correctly start a trace multiple times in parallel as I want to record the performance of every single loading process?
Note: I cannot use
HTTPMetric
as the loading trace also contains image conversion and not just downloading. -
creativecreatorormaybenot over 4 yearsThis is simply not true for me.
-
Sepehr over 3 yearsUnfortunately, it's not available on the Android platform :(