Monitoring mobile performance, energy consumption, network throughput, and application crash frequencies at scale requires high-efficiency kernel-level telemetry. In Android, telemetry collection is managed by statsd, an optimized native C++ daemon introduced in Android 9. Unlike verbose user-space logcat streams that tax the CPU and battery, statsd ingests strongly typed binary events—called atoms—logged directly from kernel drivers, native HAL daemons, and system services into circular memory buffers. When profiling performance regressions, tracking battery drain causes, or diagnosing subtle background wakefulness, inspecting the StatsD telemetry pipeline provides precise empirical data. Using Android Debug Bridge (ADB), engineers can query dumpsys statsd to inspect registered metric configs, active subscriptions, and pulled atom collectors.
Understanding Android StatsD Telemetry Architecture
The statsd architecture operates through three primary mechanisms:
- Atoms: Compact binary data records generated when a system event occurs. Pushed atoms log point-in-time state transitions (such as screen on/off, application crash, or BLE scan start), whereas Pulled atoms query cumulative hardware counters on demand (such as CPU time per UID, Wi-Fi byte counts, or memory page fault totals).
- Metric Configurations (StatsConfig): Declarative protobuf rules that instruct
statsdhow to aggregate raw atoms into statistical metrics (EventMetric, CountMetric, DurationMetric, GaugeMetric, or ValueMetric). - Socket Logging Pipeline: Daemons communicate with
statsdvia non-blocking Unix domain sockets (/dev/socket/statsdw), minimizing latency overhead on real-time execution threads.
Interrogating the StatsD Daemon via ADB
Connect your Android device with USB debugging enabled. To view the internal runtime state of the telemetry daemon, execute:
adb shell dumpsys statsd
The command outputs the operational parameters of the daemon:
Statsd Daemon Status:
Current time: 1711200000000
Active Configs: 4
Total log events processed: 284590
Dropped log events: 0
Memory usage: 4.2 MB
Auditing Active Configurations and Subscribers
Android system components (such as BatteryStats, DevicePolicyManager, and Play Services) register independent metric collection configurations. To inspect registered configuration keys and IDs:
adb shell dumpsys statsd | grep -A 8 "Active Configs"
Each configuration entry displays the owner UID, unique configuration ID, and allocated buffer memory limit. Verify that Dropped log events: 0 is reported; a non-zero count indicates high logging volume that is overwhelming the daemon’s ring buffer.
Querying Real-Time Pulled Atoms Using cmd stats
In addition to dumpsys, Android provides the cmd stats interface to pull atomic hardware statistics directly on demand:
# Inspect available pulled atoms
adb shell cmd stats print-stats
# Pull battery level and thermal state metrics
adb shell cmd stats pull-source 10008 # ATOM_CPU_TIME_PER_UID
adb shell cmd stats pull-source 10043 # ATOM_BATTERY_LEVEL
The output returns the exact hardware register readings committed to the telemetry stream.
Debugging Battery Drain and WakeLock Durations
One of the most valuable use cases for statsd inspection is isolating rogue background applications that hold kernel wake locks. Query the duration metric summaries registered under the power manager config:
adb shell dumpsys statsd | grep -A 10 "WAKELOCK_STATE_CHANGED"
The log details the calling package UID, whether the wake lock was partial or full, and the total duration in milliseconds. Comparing these metrics against application execution logs identifies battery drain culprits with sub-millisecond precision.
Clearing and Resetting Telemetry Memory
When running controlled benchmarks, clear all accumulated historical atom metrics to establish a clean baseline:
# Clear all active metric data
adb shell cmd stats clear-puller-cache
# Print memory footprint after reset
adb shell dumpsys statsd | grep "Memory usage"
Utilizing dumpsys statsd equips Android developers and system engineers with enterprise-grade telemetry visibility, enabling data-driven optimization of device thermals, memory usage, and battery life.