feat(telemetry): implement Android-native telemetry collection and TUS upload pipeline#1098
feat(telemetry): implement Android-native telemetry collection and TUS upload pipeline#1098DELTA-45-G wants to merge 10 commits into
Conversation
…nd Java using Pigeon files Signed-off-by: DELTA-45-G <sagarbirwa80@gmail.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@SachinPremkumar Phase 1 implemented and verified. Testing passed—everything is working fine
|
…a alignment - Implemented AndroidMetricCollector with background I/O using ExecutorService. - Aligned JSON output schema to match Desktop Registration Client envelope format. - Added system metric collection (uptime, memory, battery). - Implemented automatic 5MB log rotation to ensure resource efficiency. - Verified end-to-end logging structure against TUSD ingestion requirements. Signed-off-by: DELTA-45-G <sagarbirwa80@gmail.com>
|
Hi @SachinPremkumar and @Pragya279 , We are happy to report that Phase 2 (Native Telemetry Collection) is successfully implemented and verified. Key updates: Schema Alignment: The Android telemetry collection now produces JSON logs identical to the Desktop Registration Client (Outer Envelope + Inner Message structure). This ensures seamless integration with our existing backend ingestion (Vector/Kafka) pipeline without any modifications. Production Ready: We have implemented system-level metric tracking (Memory, Battery, Uptime) using thread-safe, non-blocking background I/O and automatic log rotation (5MB limit). Verification:
We are now proceeding with Phase 3 (HostApiModule integration) to wire these native collectors to the Flutter UI events. Regards, |
…on bridge - Uncommented collectAndLogSystemMetrics() to enable native system metric capture on app start - Pigeon bridge confirmed active: Flutter → TelemetryApiImpl → AndroidMetricCollector → metrics.log - Verified 4 system metrics written with correct desktop-aligned schema: system.uptime, android.memory.used, android.memory.available, android.battery.level Signed-off-by: DELTA-45-G <sagarbirwa80@gmail.com>
… pipeline - Added TelemetryUploadWorker using WorkManager for periodic upload - Reads metrics.log from internal storage every 15 minutes - Uses TUS resumable protocol with TusPreferencesURLStore for crash-safe resumable uploads - Deletes local metrics.log only after confirmed upload success - Returns Result.retry() on failure — WorkManager handles backoff - Scheduled with CONNECTED network constraint - Matches desktop TelemetryUploadService behavior exactly Verified end-to-end pipeline: Android device → TUS upload → TUSD server → Vector sidecar → Kafka topic All 5 metrics confirmed in Kafka topic registration-client-telemetry: system.uptime, android.memory.used, android.memory.available, android.battery.level, phase3.bridge.test Part of issue mosip#719 Signed-off-by: DELTA-45-G <sagarbirwa80@gmail.com>
Signed-off-by: Yakshith K D <yakshithkd97@gmail.com>
Signed-off-by: Yakshith K D <yakshithkd97@gmail.com>
Signed-off-by: DELTA-45-G <sagarbirwa80@gmail.com>
Signed-off-by: DELTA-45-G <sagarbirwa80@gmail.com>
Added atomic file renaming (metrics.log to metrics.log.processing) inside AndroidMetricCollector to allow concurrent writes during TUS uploads. Added safe retry logic for offline network failures. Signed-off-by: DELTA-45-G <sagarbirwa80@gmail.com>
4bf359c to
a60373f
Compare
|
Atomic Handoff Verified & Resolved Hi @SachinPremkumar and @yakshithkd23, The data loss issue during concurrent writes has been resolved using the Atomic Handoff strategy. @yakshithkd23 i changed some code lines Verification:
Proof of Concurrent Execution: Ready for the next review! |
yakshithkd23
left a comment
There was a problem hiding this comment.
Atomic Handoff implementation verified. The code now safely handles concurrent writes as discussed. Ready to merge.
Created TelemetryService singleton for standardized event logging Added registration lifecycle event tracking: login.success, login.failure, registration.started (new_registration_flow, Onboarding) All events flow via Pigeon → AndroidMetricCollector → metrics.log TelemetryService never crashes app — all errors silently caught Events verified in metrics.log with desktop-aligned schema Updates issue mosip#719 Signed-off-by: DELTA-45-G <sagarbirwa80@gmail.com>
|
Phase 5 (Part 1) Complete — Auth & Onboarding Triggers Verified Hi @SachinPremkumar, @Pragya279 We have successfully implemented and verified the core pipeline for Phase 5 (Flutter UI Event Triggers), focusing on the Authentication and Onboarding flows. What was implemented:
All events successfully flow via: Verified End-to-End Pipeline: Blockers for Remaining Phase 5 Goals:
Regards, |











Description
This PR introduces a robust, decoupled telemetry system for the Android Registration Client, mirroring the desktop architecture. It establishes a secure, efficient bridge between Flutter and the Android native layer to collect performance metrics and user behavior data based on issue #719 and ensures reliable background transmission to the our created TUSD ingestion server .
Implementation Phases
This implementation follows a structured approach to maintain performance and modularity:
[Phase 1] Pigeon Bridge: Defined a strict TelemetryApi contract for type-safe asynchronous communication between the Flutter UI and Android native layer.
[Phase 2] Native Collection: Implemented AndroidMetricCollector to handle file I/O operations on a dedicated background thread, ensuring thread-safe JSON-line logging with automatic 5MB log rotation.
[Phase 3] Host Integration: Integrated the TelemetryHandler into HostApiModule.java to register the telemetry service within the Flutter Engine.
[Phase 4] Background Upload: Leveraged WorkManager via a new TelemetryUploadWorker to perform periodic, resumable uploads of the metrics.log file using the TUS protocol, ensuring network-efficient background data transmission.
[Phase 5] Flutter Service Layer: Created TelemetryService to standardize event structure and provide a clean API for UI components to trigger telemetry logging.
Key Technical Highlights
Performance: All file I/O and network transmission occur off the main UI thread to prevent frame drops.
Reliability: Implemented resumable uploads using the TUS protocol; local log files are cleared only upon successful transmission confirmation.
Maintenance: Utilized the Pigeon generated-code pattern to minimize boilerplate and enforce type safety across layers.
Observability: Integrated with existing Android WorkManager infrastructure, reusing existing scheduler patterns to minimize resource footprint.
Verification & Testing
Verified local metrics writing via logcat and file system inspection.
Validated end-to-end flow using the existing TUSD ingestion backend.
Verified background job execution consistency via WorkManager.
Associated Issue
#719
Thanks
Team TuluTech