Nav3 SentryTraced spans attach to another root’s navigation transaction

未关闭
#6,368 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, kotlin
领域
backend, mobile

调研方向

Read sentry-compose/.../SentryComposeTracing.kt and the Nav3 entry span and lease handling added for #6345; the payload does not name those implementation files. Trace how LocalSentrySpan.current.orBootstrapCurrentTransaction() selects a parent when multiple roots compose, then reproduce with the sample’s multi-Activity or ViewPager2 steps. Done means each route’s composition and render spans attach only to its own navigation transaction, or remain unattached when that root has no transaction; the API and preview-span policy still need design review.

由索引模型根据 Issue 内容生成。

描述

Android Bug Jetpack Compose Platform: Java Spans
Description

When multiple Nav3 roots are hosted by different Activities or Fragments, SentryTraced can attach a route's ui.compose and ui.render spans to another root's navigation transaction. This produces a trace whose transaction name and child route names disagree.

Reproduced with the Android sample app on fix/nav3-view-pager-2 (sample build from c1113ebedb; a later amend changed only tests), version 8.61.1, on an API 37 emulator. The sample's Recent transactions sheet reads the finished SentryTransaction from beforeSendTransaction, so the mismatch is in the transaction sent by the SDK.

Steps to reproduce

Multi-Activity

  1. In the Android sample, open Nav3 Activity with the default setup, then select Multi-Activity.
  2. Open Products Activity → Open Product 42.
  3. Tap Push Confirmation in 5 s, then immediately tap Go to Checkout to open Checkout Activity.
  4. After the delayed route is pushed in the background Products Activity, leave Checkout and inspect Recent transactions.

The tagged controls are nav3_tab_multi_activity, nav3_multi_activity_open_products, nav3_product_list_open_product_42, nav3_product_detail_delayed_confirmation, and nav3_product_detail_go_to_checkout.

Multi-Fragment / ViewPager2

  1. In the same sample, select Multi-Fragment → Open fragments Activity → Pager.
  2. Move from Page 0 to Page 1 and Page 2. The neighboring Fragment pages are preloaded at STARTED (offscreenPageLimit = 1).
  3. Inspect the finished Page 0 /ProductList transaction in Recent transactions.

The tagged controls are nav3_tab_multi_fragment, nav3_multi_fragment_open_fragments, nav3_multi_fragment_open_pager, and nav3_multi_fragment_page_0 through _2.

Expected

A SentryTraced route's composition and render spans are children of that route's own navigation transaction. If its root does not currently have a transaction, its spans should not be attached to another root's transaction.

Actual
  • The Checkout Activity's /Checkout transaction contains ui.compose - Nav3 /Confirmation from the background Products Activity. Captured trace.
  • A Page 0 /ProductList transaction contains ui.compose and ui.render spans for Page 1 /Checkout and Page 2 /Confirmation. Captured trace.

The sample's test.navigation.route_activation spans also attach to the wrong transaction in these runs. Those spans come from sample instrumentation; the ui.compose and ui.render spans demonstrate the SDK issue.

Likely cause

SentryTraced obtains its owner from LocalSentrySpan.current.orBootstrapCurrentTransaction() (sentry-compose/.../SentryComposeTracing.kt). The Nav3 sample does not provide a per-entry LocalSentrySpan, so the fallback reads whichever transaction is bound to the shared scope at composition time. A background Activity or preloaded Fragment can compose while another root owns that scope transaction. The Nav3 lease limits which root publishes navigation state but does not bind SentryTraced spans to their entry.

A possible fix is for each Nav3 entry to provide its own parent span to SentryTraced, with a no-op owner when the entry has no transaction. The exact API and preview-span policy need design review.

Related
  • #6345 added multi-Activity and multi-Fragment Nav3 support. This issue concerns composition-span attribution across those roots.
  • #6366 tracks idle SentryTraced transactions finishing at the deadline; that timeout behavior is separate from this attribution bug.
主要语言
Kotlin
星标
1.4k
派生
483
平均合并
2 天 54 分钟
30 天内合并 PR
207

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-java 的其他 Issue

查看 getsentry/sentry-java 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。