Skip to content

Compose tracing: allow tracing by phases #171

@JustinBis

Description

@JustinBis

Is your feature request related to a problem? Please describe.

The only composition tracing I see currently is HoneycombInstrumentedComposable, and the implementation seems to only trace the composition phase. It would be nice to have the option to separately trace the composition and rendering phases to help determine what is slow in complex views. Ideally this could be nicely visualized in a flame graph of what is taking longest to compose / render.

Related, I think using SideEffect to measure the end time will actually give the wrong result since it commits after the composition (which may include work "above" the traced composable in the tree) but you likely want to end the time exactly when the traced Composable returns.

Describe the solution you'd like

Something more like Sentry's SentryTraced would be a good start. Their implementation also has issues (their use of private composition locals means the spans can't be extended with sub-spans, and they get cached such that a trace can only be run once).

Describe alternatives you've considered

Alternative: forking this and writing my own. Which is what we've done with Sentry as well.

Additional context

See Jetpack Compose documentation on phases: https://developer.android.com/develop/ui/compose/phases

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions