Clean up profile and replay artifacts on pre-envelope drops
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Bereich
- backend-api-design, devtools
Rechercherichtung
The issue is in SentryClient's capture flow, specifically around envelope construction and sidecar file cleanup. Look at SentryClient, SentryEnvelopeItem.fromProfilingTrace, and SentryEnvelopeItem.fromReplay. The tests to add will involve temporary files and mocking EventProcessor and beforeSend callbacks. 'Done' means profile trace files and replay videos/folders are deleted on early drops, and discard reasons are correctly accounted for.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Problem
SentryClient currently relies on lazy envelope-item serialization to clean up file-backed transaction profiles and replay recordings. If capture terminates after those sidecars exist but before envelope construction, serialization never takes ownership and the files are not promptly deleted.
This affects both EventProcessor and beforeSend* drop paths. PR #6142 adds new fail-closed exits when an EventProcessor throws, but the same ownership gap already exists for intentional processor drops and beforeSend* drops.
Affected paths
Profiled transactions
A profiled transaction can return before buildEnvelope(..., profilingTraceData) when:
- an EventProcessor returns
null; - an EventProcessor throws and the SDK fails closed;
beforeSendTransactionreturnsnull; orbeforeSendTransactionthrows.
The profile trace is normally deleted by the lazy serializer created in SentryEnvelopeItem.fromProfilingTrace. These early returns prevent that cleanup, allowing sensitive profile data and disk usage to accumulate in long-running Android apps or JVM services.
Session replays
A replay can return before replay envelope construction when:
- an EventProcessor returns
null; - an EventProcessor throws and the SDK fails closed;
beforeSendReplayreturnsnull; orbeforeSendReplaythrows.
Replay cleanup currently occurs in the serializer created by SentryEnvelopeItem.fromReplay. Bypassing it can retain the replay video or, for a backfilled replay, the entire replay folder.
Expected behavior
Introduce explicit ownership for file-backed sidecars so every terminal pre-envelope drop either:
- transfers the sidecar to an envelope item that owns serialization and cleanup; or
- disposes of the sidecar immediately at the capture boundary.
The implementation should:
- delete abandoned profile trace files;
- delete normal replay videos and the correct backfilled replay folder;
- record one dropped profile with the same discard reason as its transaction (
event_processor,before_send, orcallback_error); - avoid double deletion and double accounting; and
- preserve existing replay-folder semantics and transaction/span discard quantities.
Tests
Add real temporary-file regression coverage for:
- profiled transactions dropped by processor null and processor exception;
- profiled transactions dropped by
beforeSendTransactionnull and exception; - normal replay videos dropped by processor and
beforeSendReplaypaths; - backfilled replay folders dropped by processor and
beforeSendReplaypaths; and DataCategory.Profileaccounting under each corresponding discard reason.
Context
This was identified while reviewing #6142. The fail-closed processor behavior is correct; the issue is that cleanup is coupled to envelope serialization even though several valid terminal paths return before an envelope is built.
- Vorherrschende Sprache
- Kotlin
- Sterne
- 1.4k
- Forks
- 478
- Ø Merge
- 2 T. 20 Std.
- Gemergte PRs (30 T.)
- 71
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus getsentry/sentry-java
-
Improvement Java Platform: Android Platform: Java
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
getsentry/sentry-java#6145 · 1 Kommentar · 1 zugewiesene Person ·
-
Bug Java Platform: Android Platform: Java
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
getsentry/sentry-java#6138 · 1 Kommentar ·
-
Feature Java Platform: Java Spans
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
getsentry/sentry-java#5984 · 1 Kommentar ·
-
Android Task Traces
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
getsentry/sentry-java#5376 · 1 Kommentar ·
-
Android Docs Errors
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
getsentry/sentry-java#5375 · 1 Kommentar ·
Alle Issues in getsentry/sentry-java
Ähnliche Issues
-
[Bug] 统计页面无法重置token和汇率 Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
AAswordman/Operit#1265 · 3 Kommentare ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
acristescu/OnlineGo#216 ·
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
libre-tube/LibreTube#8803 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
status: waiting-for-triage type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
spring-projects/spring-security#19781 ·