The [Fuchsia tracing system](https://fuchsia.dev/docs/concepts/kernel/tracing-system) allows you to collect and
visualize diagnostic information from Fuchsia components.

Fuchsia's tracing system offers a comprehensive way to collect, aggregate, and
visualize diagnostic tracing information from the Fuchsia user space processes
and the Zircon kernel. Traces, like logs, represent events from a Fuchsia
system, but are fine grained, higher frequency and are meant for machine
consumption to compute other insights and visualizations.

Tracing and profiling are a powerful pair of tools to gain insights into the
performance of a system. In comparison to profiling which samples data every
so often, tracing captures every event in a short duration and can include extra
information with the trace event.

Generally, [profiling](https://fuchsia.dev/docs/development/profiling/profiling-cpu-usage) is more useful if you don't know where
the problem is, and aren't sure where to put trace spans, or you aren't able to
add tracing events.

Tracing involves three high-level steps:

- Instrument: Instrument your code so that you can measure the runtime of specific functions by surrounding these pieces of code with trace events and add labels to emit during a trace.
- Record: Configure and start a tracing tool (`ffx trace`) to generate a trace.
- Analyze: Visualize the report with a UI such as Perfetto to identify issues and potential ways to optimize your code.

## General

- [Use trace events](https://fuchsia.dev/docs/development/tracing/trace_events): This document explains the various types of tracing events that Fuchsia supports and how to use them in your components.
- [Analyze traces with PerfettoSQL and fx perf-analyze](https://fuchsia.dev/docs/development/tracing/analyze-traces-with-sql): Query trace data with SQL, perform automated triage, and calculate performance metrics using `fx perf-analyze` and Perfetto Trace Processor.

Fuchsia recommends that you use the [Perfetto UI](https://ui.perfetto.dev/) to view the
traces that you collect from Fuchsia components. For more information on using
Perfetto, see the [Perfetto documentation](https://perfetto.dev/docs/).

## Tutorial

If you're new to tracing, see [Tutorial on Fuchsia tracing](https://fuchsia.dev/docs/development/tracing/tutorial/README).

This tutorial provides a high level overview of tracing and the steps necessary
to add tracing to your Fuchsia components.

## Advanced guides

These guides are for advanced users who already understand the basics
of tracing in Fuchsia:

- [Tracing booting Fuchsia](https://fuchsia.dev/docs/development/tracing/advanced/recording-a-boot-trace)
- [Kernel tracing](https://fuchsia.dev/docs/development/tracing/advanced/recording-a-kernel-trace)
- [Asynchronous tracing](https://fuchsia.dev/docs/development/tracing/advanced/tracing-asynchronously)

[](https://issues.fuchsia.dev/issues/new?component=1439230&template=1881640&description=Issue+on:+https://fuchsia.dev/docs/development/tracing/README.md "Report a bug or suggest improvements on this page") [](https://cs.opensource.google/fuchsia/fuchsia/+/main:docs/development/tracing/README.md "View the source code of this page") [](https://ci.android.com/edit?repo=fuchsia/fuchsia/main&file=docs/development/tracing/README.md&cloneRepo=fuchsia/fuchsia:refs/heads/main&fullPath=fuchsia/docs/development/tracing/README.md "Edit the source code of this page")