docs/reference/traced.md
traced - The Perfetto Tracing Service
traced is the central daemon in Perfetto's
service-based architecture. It acts as the
grand central station for all tracing activity on the system, mediating
interactions between entities that want to record data (Producers) and entities
that want to control and read traces (Consumers).
In a typical system-wide tracing setup (like on Android or Linux), traced runs
as a long-lived background daemon, often started at system boot.
Perfetto's architecture is designed for security and robustness, with traced
at its core. The model consists of three main components:
perfetto command-line tool is a common example of a consumer.traced): The central daemon that manages tracing sessions,
buffers, and the registry of data sources.traced. A key example of a
producer is traced_probes, which
provides a wide range of system-level data sources.This decoupled architecture allows for multiple, independent producers and consumers to interact with the tracing system simultaneously without interfering with each other.
traced itself does not generate trace data. Its primary role is to manage the
logistics of one or more tracing sessions:
traced. The service then parses this config and forwards
relevant sub-configurations to the appropriate Producers to start their data
sources.Entities interact with traced primarily through two channels:
traced.traced periodically scans these memory regions and copies valid,
completed packets into its central trace buffers.traced supports the following command-line options:
--background: Exits immediately and continues running in the background.
--version: Prints the version number and exits.
--set-socket-permissions <prod_group>:<prod_mode>:<cons_group>:<cons_mode>: Sets the group ownership
and permission mode for the producer and consumer sockets. This is important
for controlling which users and processes can connect to traced.
--enable-relay-endpoint: Exposes the RelayPort service used by
multi-machine tracing
on every producer socket named by PERFETTO_PRODUCER_SOCK_NAME (or the
default producer socket). This is the standard switch for multi-machine
setups; see
Multi-machine recording
for the host-side setup.
Security note: when the producer socket list mixes a local AF_UNIX socket with a remote-capable one, this flag exposes
RelayPorton the local socket too. Deployments that combine local and remote producer sockets should use--enable-relay-endpoint-onbelow to keep the relay port off the local socket.
--enable-relay-endpoint-on <socket>: Like --enable-relay-endpoint,
but exposes the RelayPort service only on the named producer socket.
<socket> must be one of the entries in PERFETTO_PRODUCER_SOCK_NAME
(or the default producer socket): the flag selects which existing
producer sockets get RelayPort; it does not introduce new endpoints.
May be repeated.
On Android, traced also includes a built-in producer with several key
responsibilities:
perfetto.metatrace data source, which
enables tracing of the traced service itself. This is useful for debugging
Perfetto and capturing internal statistics, such as clock snapshots and
details about connected producers.heapprofd and traced_perf) on-demand. When a trace configuration
requests a data source provided by one of these daemons, the built-in
producer ensures the corresponding service is started. It also stops the
service after a delay once it's no longer needed.The service-based architecture is designed with security in mind. Producers are untrusted and isolated from each other and from the central service. The use of UNIX socket permissions allows administrators to control who can connect to the tracing service as a producer or a consumer.