dd-sdk-reactnative icon indicating copy to clipboard operation
dd-sdk-reactnative copied to clipboard

End spans on crash and mark with error.crash.count: 1

Open stevoland opened this issue 2 years ago • 2 comments

Hi, this is a native request but I hope you don't mind me putting it here rather than cross-posting ios/android.

We're using the DdTrace API to collect spans to represent user journeys and generate latency/availability metrics. Currently there's a gap in the case of a native crash, the span isn't ended so the availability metric isn't accurate.

On a crash we would like open spans to be ended and marked with an attribute such as error.crash.count: 1.

Perhaps this could be achieved by either:

a) The native crash handler adding the attribute, ending the open spans and writing them to disk b) Probably safer: writing open spans to disk on span start. If there's a crash report from the previous run read the started spans, add the attribute and end them (although the end timestamp would be inaccurate)

Thanks for your time!

stevoland avatar Jan 12 '24 13:01 stevoland

Hi @stevoland, thanks for reaching out!

This is indeed not supported at the moment in the SDK. I've added tasks in our backlog to look at possible implementations on both platforms.

In the meantime, you can probably solve this on your end for RN crashes by implementing a custom error handler for JS crashes like we do in our SDK, closing all open spans before letting the app crash.

Let me know if that solved (even partially) your problem!

louiszawadzki avatar Jan 16 '24 09:01 louiszawadzki

Thanks @louiszawadzki, appreciated.

We have indeed implemented a handler for JS side as you suggest. Seems to work well but fyi, found that we needed to add a short timeout before calling the previous handler to allow the spans to be written to disk. 10ms seems sufficient in my limited testing.

stevoland avatar Jan 16 '24 12:01 stevoland