dd-sdk-android icon indicating copy to clipboard operation
dd-sdk-android copied to clipboard

Live Profiling PoC

Open mariusc83 opened this issue 1 year ago • 0 comments

This pull request introduces several significant changes, primarily focusing on adding support for profiling and integrating Protobuf for enhanced functionality. The changes include introducing a new MergeTraceDumper class for profiling, updating the RUM feature to handle profiling and trace uploads, and integrating Protobuf into the build system. Below is a summary of the most important changes grouped by theme:

Profiling and Trace Management

  • Added MergeTraceDumper class: Introduced a singleton class for managing and merging profiling traces. It collects snapshots at regular intervals, merges them, and saves them as .pprof files. The class is integrated into the RUM feature and the DdRumContentProvider to start and stop trace dumping. (features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/profiling/MergeTraceDumper.kt, features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/profiling/MergeTraceDumper.ktR1-R169)
  • Updated DdRumContentProvider: Integrated MergeTraceDumper to start dumping traces during application startup. (features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/DdRumContentProvider.kt, [1] [2]
  • Enhanced RumMonitor and DatadogRumMonitor: Added startProfiling and stopProfiling methods to manage profiling lifecycle. Integrated MergeTraceDumper to stop dumping traces when the first view is started. (features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/RumMonitor.kt, [1]; features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/monitor/DatadogRumMonitor.kt, [2] [3] [4]

Protobuf Integration

  • Integrated Protobuf into the build system: Added the Protobuf Gradle plugin, configured Protobuf source sets, and added dependencies for Protobuf. This enables the generation of Protobuf classes and their usage in the project. (features/dd-sdk-android-rum/build.gradle.kts, [1] [2] [3] [4]
  • Configured resource processing: Updated the build configuration to exclude duplicate resources during processing. (features/dd-sdk-android-rum/build.gradle.kts, features/dd-sdk-android-rum/build.gradle.ktsR150-R152)

RUM Feature Enhancements

  • Added MergedTracesUploader: Initialized in the RumFeature class to upload merged traces to the backend. (features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/RumFeature.kt, [1] [2] [3]
  • Enhanced RumViewScope: Added logic to send a custom "rum_app_launch" event when the app launch view is detected. (features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.kt, features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.ktR172-R180)

Other Changes

  • Made CurlInterceptor public: Changed the visibility of CurlInterceptor from internal to public for broader usage. (dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/data/upload/CurlInterceptor.kt, dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/data/upload/CurlInterceptor.ktL24-R24)
  • Removed open modifier from RumViewScope: Simplified the class definition by making it non-open since no inheritance is required. (features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.kt, features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.ktL56-R56)### What does this PR do?

A brief description of the change being made with this pull request.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • [ ] Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • [ ] Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • [ ] Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

mariusc83 avatar May 02 '25 11:05 mariusc83