firebase-android-sdk icon indicating copy to clipboard operation
firebase-android-sdk copied to clipboard

Cancel/Discard Started Performance Custom Traces 🚀

Open PiotrBandurski opened this issue 1 year ago • 8 comments

What feature would you like to see?

Possibility to discard/cancel custom Firebase Performance trace. Currently we can only start and stop trace which always will track time. eg.

val myTrace = Firebase.performance.newTrace("test_trace")
myTrace.start()

// code that you want to trace

myTrace.stop()

But if for some reason I want to discard started trace (example scenario: I want to trace how long app fetches data from api but some error occurs and I don't want to track partially downloaded data). I cannot do it and I have to live with started trace which takes memory on device.

How would you use it?

I think adding method Trace#cancel() which under the hood will unsubscribe from all observations would be best solution.

PiotrBandurski avatar Apr 06 '23 14:04 PiotrBandurski

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar Apr 06 '23 14:04 google-oss-bot

Cmon guys, don't act like tinder girls, please don't ghost me.

PiotrBandurski avatar Jun 30 '23 06:06 PiotrBandurski

Hi @PiotrBandurski, sorry for the unintended radio silence here. We really appreciate you filing the feature request and following up on this. However, we can't promise any timeline for this feature, our engineers will take a look into it once they have the time. if you have additional information you'd like to share, let us know.

And for others who find this useful, adding an emoji thumbs up on the author's post can help our engineers prioritize adding this to the roadmap. Thanks!

argzdev avatar Jun 30 '23 09:06 argzdev

Agreed, this functionality would support our use-cases as well.

We have several traces that become invalid through the course of the app depending on user actions. Today, we simply don't call stop on them, but would much rather have an explicit API to discard these. On iOS, I see the private API for cancel, although I'm not sure if that has the same effect as discard or invalidate would.

jotai-coder avatar Aug 30 '23 17:08 jotai-coder

In past I even created pr for this issue but it seems that it expried and was rejected. Here code for new pr. https://github.com/PiotrBandurski/firebase-android-sdk/commit/1653da17550cf97a2062529eaf7dd2ea405fa2b4

PiotrBandurski avatar Nov 04 '23 08:11 PiotrBandurski

Any update on this? Current we can just not call the stop() method then set the Trace to null. But it looks ugly and I'm not too sure if it has any side effects that can affect the trace.

redmanit avatar Nov 27 '23 02:11 redmanit

Any update on this? Current we can just not call the stop() method then set the Trace to null. But it looks ugly and I'm not too sure if it has any side effects that can affect the trace.

When you call stop the SDK records the trace, setting it to null will do nothing because it is too little too late. At least this appears to be the case for iOS: https://github.com/firebase/firebase-ios-sdk/blob/main/FirebasePerformance/Sources/Timer/FIRTrace.m#L170

SwiftNativeDeveloper avatar Jan 16 '24 21:01 SwiftNativeDeveloper

Any updates on it? I even created a pull request for it. @argzdev

PiotrBandurski avatar Jul 04 '24 10:07 PiotrBandurski