Skip to content

RUM-13679: Delete Perfetto result file after batch write#3485

Closed
ambushwork wants to merge 9 commits into
feature/continuous-profilingfrom
yl/profiling/rum-13679-perfetto-file-cleanup
Closed

RUM-13679: Delete Perfetto result file after batch write#3485
ambushwork wants to merge 9 commits into
feature/continuous-profilingfrom
yl/profiling/rum-13679-perfetto-file-cleanup

Conversation

@ambushwork

Copy link
Copy Markdown
Member

Summary

  • ProfilingDataWriter.write() now deletes the Perfetto result file (*.perfetto-stack-sample) after every call — inside writeScope on the I/O thread after the batch write attempt, and as an early guard when the profiling feature scope is null. This covers all exit paths: successful write, empty-events skip, and feature-uninitialized.
  • ProfilingFeature.tryWriteProfilingEvent() CONTINUOUS branch no longer returns early when there are no pending RUM events — it always calls dataWriter.write() so the writer-owned cleanup always runs.
  • safeDelete logs WARN (with file path) when File.delete() returns false or throws, matching the pattern in AnrProfilingTriggerRegistrar.
  • Updated the "no RUM events" user-visible log message from "dropped" to "not uploaded" for accuracy.

Test Plan

  • Three new ProfilingDataWriterTest tests assert file is deleted on all paths (feature null, events present, no events)
  • Pre-existing ProfilingDataWriterTest tests updated to also assert file.exists() == false
  • ProfilingFeatureTest: updated no-events CONTINUOUS test now verifies write() is always called with empty lists + user log fires
  • Full profiling module test suite passes: ./gradlew :features:dd-sdk-android-profiling:testDebugUnitTest
  • Detekt passes: ./gradlew :features:dd-sdk-android-profiling:detekt

🤖 Generated with Claude Code

ambushwork and others added 9 commits May 29, 2026 13:53
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…DataWriter

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eletion

- safeDelete now logs WARN when File.delete() returns false (matching AnrProfilingTriggerRegistrar pattern)
- LOG_FILE_DELETE_FAILED updated to include path placeholder (%s)
- Three pre-existing tests assert file is deleted after write()
- M delete result file W write {events present} adds write interaction assertion
- M skip writing W write {can't read perfetto File} uses TempDir non-existent path and expects WARN log

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cleanup always runs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…assertion

Update LOG_CONTINUOUS_PROFILING_DROPPED_NO_RUM_EVENTS to say "not uploaded"
instead of "dropped", and add a log-message verification to the empty-events
test; also remove dead mockSdkCore.getFeature(PROFILING_FEATURE_NAME) setup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ambushwork ambushwork requested review from a team as code owners May 29, 2026 13:23
@datadog-official

datadog-official Bot commented May 29, 2026

Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 2 Pipeline jobs failed

DataDog/dd-sdk-android | analysis:detekt-common   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). 1 code smell detected: Private property `mockProfilingFeatureScope` is unused at /go/src/github.com/DataDog/dd-sdk-android/features/dd-sdk-android-profiling/src/test/kotlin/com/datadog/android/profiling/ProfilingFeatureTest.kt:100:26.

DataDog/dd-sdk-android | analysis:ktlint   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). Lint error in ProfilingDataWriterTest.kt: Unexpected blank line(s) before "}" (standard:no-blank-line-before-rbrace)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: adb1fdf | Docs | Datadog PR Page | Give us feedback!

@ambushwork ambushwork closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant