traced_probes - System & OS Probes
traced_probes is a specialized daemon that acts as a privileged Producer in the Perfetto architecture. While any application can act as a producer to contribute its own trace data, traced_probes is specifically responsible for collecting system-level and kernel-level data that typically requires elevated privileges.
tracedtraced_probes is a client of the traced service. It connects to traced's producer socket and registers a set of data sources. traced then sends requests to traced_probes to start or stop these data sources as part of a tracing session.
This separation of concerns is a key part of Perfetto's design. traced is the central manager, while traced_probes is a specialized data provider. This decoupled architecture allows for multiple, independent producers and consumers to interact with the tracing system simultaneously without interfering with each other.
traced_probes often needs to run with elevated privileges (e.g., root or system user on Android) to access kernel interfaces like debugfs or /proc. Separating these high-privilege probes into their own daemon is a key part of Perfetto's security model. It ensures that only a minimal amount of code runs with high privileges, adhering to the principle of least privilege.
The data sources provided by traced_probes are configured within the main trace configuration protobuf that is sent to traced. For example, to enable ftrace, you would include an FtraceConfig within the DataSourceConfig for the linux.ftrace data source.
traced_probes provides a wide range of data sources, collecting system-level and kernel-level data. The configuration for these data sources is specified in the data_sources section of the overall trace configuration. Each data source has its own configuration message within a data_source_config block.
Here is an example of the general structure:
data_sources: { config { name: "linux.ftrace" ftrace_config { # ... ftrace-specific settings } } } data_sources: { config { name: "linux.process_stats" process_stats_config { # ... process_stats-specific settings } } }
Below is a detailed list of the main data sources provided by traced_probes, separated by platform.
These data sources are available on Linux-based systems, including Android.
Here is an example of a trace config enabling several Linux data sources:
# Example of a trace config enabling several Linux data sources. data_sources: { config { name: "linux.ftrace" ftrace_config { ftrace_events: "sched/sched_switch" ftrace_events: "power/cpu_idle" } } } data_sources: { config { name: "linux.process_stats" process_stats_config { scan_all_processes_on_start: true proc_stats_poll_ms: 1000 } } } data_sources: { config { name: "linux.sys_stats" sys_stats_config { meminfo_period_ms: 1000 vmstat_period_ms: 1000 } } }
linux.ftrace (Kernel Tracing)data_sources: { config { name: "linux.ftrace" ftrace_config { ftrace_events: "sched/sched_switch" ftrace_events: "power/cpu_idle" ftrace_events: "sched/sched_waking" } } }
FtraceConfig within the DataSourceConfig. Key options include:ftrace_events: List of ftrace events to enable (e.g., sched/sched_switch).atrace_categories, atrace_apps: For Android, enables userspace Atrace categories and apps.syscall_events: Specific syscalls to trace.enable_function_graph: Enables kernel function graph tracing.compact_sched: Enables compact encoding for scheduler events.symbolize_ksyms: Enables kernel symbolization.print_filter: Filters ftrace/print events based on content.linux.process_stats (Process and Thread Statistics)/proc filesystem. It provides both a snapshot of the process tree and periodic memory/CPU counters.data_sources: { config { name: "linux.process_stats" process_stats_config { scan_all_processes_on_start: true proc_stats_poll_ms: 1000 } } }
ProcessStatsConfig. Key options include:record_thread_names: Record thread names.scan_all_processes_on_start: Dump the entire process tree at the start.resolve_process_fds: Resolve file descriptor paths.scan_smaps_rollup: Read /proc/[pid]/smaps_rollup.record_process_age: Record process start time.record_process_runtime: Record user and kernel mode CPU times.record_process_dmabuf_rss: Record DMA buffer RSS.proc_stats_poll_ms: Polling interval for periodic stats.proc_stats_cache_ttl_ms: Time-to-live for cached stats.quirks: Special behaviors (e.g., DISABLE_ON_DEMAND).linux.sys_stats (System-Wide Statistics)/proc and /sys.data_sources: { config { name: "linux.sys_stats" sys_stats_config { meminfo_period_ms: 1000 vmstat_period_ms: 1000 stat_period_ms: 1000 } } }
SysStatsConfig. Allows fine-grained control over which counters to collect and their polling frequencies (e.g., meminfo_period_ms, vmstat_period_ms, stat_counters).linux.sysfs_power (Power and Battery Information)data_sources: { config { name: "linux.sysfs_power" } }
linux.inode_file_map (Inode to File Path Mapping)data_sources: { config { name: "linux.inode_file_map" inode_file_config { scan_interval_ms: 10000 scan_delay_ms: 5000 scan_batch_size: 1000 } } }
InodeFileConfig allows specifying scan_mount_points, mount_point_mapping (to remap scan roots), scan_interval_ms, scan_delay_ms, scan_batch_size, and do_not_scan.metatrace (Perfetto Self-Tracing)data_sources: { config { name: "metatrace" } }
DataSourceConfig.linux.system_info (System Information)data_sources: { config { name: "linux.system_info" } }
DataSourceConfig.These data sources are available only on Android.
Here is an example of a trace config enabling several Android data sources:
# Example of a trace config enabling several Android data sources. data_sources: { config { name: "android.power" android_power_config { battery_poll_ms: 1000 battery_counters: BATTERY_COUNTER_CHARGE collect_power_rails: true } } } data_sources: { config { name: "android.log" android_log_config { log_ids: LID_DEFAULT log_ids: LID_SYSTEM } } } data_sources: { config { name: "android.packages_list" } }
android.power (Power and Battery Information)data_sources: { config { name: "android.power" android_power_config { battery_poll_ms: 1000 battery_counters: BATTERY_COUNTER_CHARGE battery_counters: BATTERY_COUNTER_CAPACITY_PERCENT collect_power_rails: true } } }
AndroidPowerConfig allows enabling specific battery counters (battery_counters), power rails (collect_power_rails), energy estimation breakdown (collect_energy_estimation_breakdown), and entity state residency (collect_entity_state_residency).android.log (Android Logcat)data_sources: { config { name: "android.log" android_log_config { log_ids: LID_DEFAULT log_ids: LID_SYSTEM min_prio: PRIO_INFO filter_tags: "ActivityManager" } } }
AndroidLogConfig allows filtering by log IDs (log_ids) and tags (filter_tags), and setting a minimum priority (min_prio).android.system_property (Android System Properties)data_sources: { config { name: "android.system_property" android_system_property_config { poll_ms: 1000 property_name: "debug.tracing.screen_state" } } }
AndroidSystemPropertyConfig allows specifying property_names to monitor and a poll_ms interval.android.packages_list (Android Package Information)data_sources: { config { name: "android.packages_list" packages_list_config { package_name_filter: "com.android.systemui" package_name_filter: "com.google.android.apps.nexuslauncher" } } }
PackagesListConfig allows filtering by package_name_filter and can be configured to only_write_on_cpu_use_every_ms (polling mode) or dump all at start.android.game_interventions (Android Game Intervention List)data_sources: { config { name: "android.game_interventions" android_game_intervention_list_config { package_name_filter: "com.example.mygame" } } }
AndroidGameInterventionListConfig allows filtering by package_name_filter.android.cpu.uid (Per-UID CPU Time)data_sources: { config { name: "android.cpu.uid" cpu_per_uid_config { poll_ms: 1000 } } }
CpuPerUidConfig allows setting the poll_ms interval.android.kernel_wakelocks (Kernel Wakelocks)data_sources: { config { name: "android.kernel_wakelocks" kernel_wakelocks_config { poll_ms: 1000 } } }
KernelWakelocksConfig allows setting the poll_ms interval.android.polled_state (Android Initial Display State)data_sources: { config { name: "android.polled_state" android_polled_state_config { poll_ms: 500 } } }
AndroidPolledStateConfig allows setting a poll_ms interval.android.statsd (Android StatsD Atoms)data_sources: { config { name: "android.statsd" statsd_tracing_config { pull_config { pull_atom_id: 10000 # Example pull atom pull_frequency_ms: 1000 } push_atom_id: 10037 # Example push atom } } }
StatsdTracingConfig allows specifying pull_config (for pull atoms with frequency and packages) and push_atom_id (for push atoms).