Firebase Performance failed to start trace because it's already been started and stopped

Viewed 1162

I'm trying to create a very simple Firebase Performance trace with the following code:

let trace = Performance.startTrace(name: "setup")
setup()
trace?.stop()

All I want this trace to do is track how long the setup() function takes to run. It seems to work the first time, but after that, I get this message printed to console: [Firebase/Performance] Failed to start trace setup because it has already been started and stopped.

Is this warning something to be concerned about? And if so, what am I doing wrong that's causing this warning?

1 Answers

Your code seems to be okay.

I'd recommend you to have a look at extra trace?.start() calls. E.g. I had the same issue with the following code:

let trace = Performance.startTrace(name: "setup")
trace?.start()
setup()
trace?.stop()

Function startTrace(name:) starts the trace for you and you don't have to do it again.

Related