kmell96
kmell96

Reputation: 1465

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

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?

Upvotes: 5

Views: 2066

Answers (1)

Dmitry Kuznetsov
Dmitry Kuznetsov

Reputation: 126

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.

Upvotes: 3

Related Questions