sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Track composable functions with @SentryTraceable annotation

Open romtsn opened this issue 3 years ago • 2 comments

Description

Create transactions/spans for @Composable functions annotated with @SentryTraceable, so we can enrich events that pop up within that composable lifetime. The code to measure that could roughly look like this:

    DisposableEffect(Unit) {
        Log.e("SENTRY", "ENTERED COMPOSITION")
        onDispose {
            Log.e("SENTRY", "LEFT COMPOSITION")
        }
    }

Would require bytecode manipulation through SAGP.

romtsn avatar May 30 '22 22:05 romtsn

@romtsn The Java SDK already has such annotations https://github.com/getsentry/sentry-java/blob/main/sentry-spring/src/main/java/io/sentry/spring/tracing/SentryTransaction.java In case the target and retention match, we could e.g. move it to the core package.

marandaneto avatar May 31 '22 15:05 marandaneto

Also, we'd probably need this to correctly measure the App Startup/Screen TTID, because onResume currently doesn't give you the correct value when the composable is actually rendered. Not sure how to detect it automatically yet, but we'd need to find a way where to place this code snippet

romtsn avatar Jun 20 '22 09:06 romtsn