google / google/perfetto

Improve UX for combined in-application and system event trace on Linux

Open
#3,437 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
6.5k
Forks
868
Avg merge
2d 1h
Merged PRs (30d)
218

Description

Hi - I'm having some problems trying to get a combined trace on Linux - I suspect I'm missing a configuration step or something from the docs.

This [example from the documentation](https://perfetto.dev/docs/getting-started/in-app-tracing#combined-in-app-and-system-tracing) shows how to combine in-application and system tracing using the SDK.

Here's what I've tried:

## Steps to reproduce

1. Compile the following example with the Perfetto SDK -

```cpp
#include

PERFETTO_DEFINE_CATEGORIES(
perfetto::Category("rendering")
.SetDescription("Events from the graphics subsystem"),

PERFETTO_TRACK_EVENT_STATIC_STORAGE();

int main(int argc, char** argv) {
perfetto::TracingInitArgs args;
args.backends |= perfetto::kSystemBackend;
perfetto::Tracing::Initialize(args);

perfetto::TrackEvent::Register();

{
TRACE_EVENT("rendering", "work");
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
TRACE_EVENT("rendering", "more_work");
return 0;
}
```

2. Run `tracebox` as specified in [Capturing a Trace](https://perfetto.dev/docs/getting-started/system-tracing#capturing-a-trace) with the following config:
```

buffers {
size_kb: 100024
fill_policy: RING_BUFFER
}

data_sources: {
config {
name: "linux.sys_stats"
sys_stats_config {
stat_period_ms: 1000
stat_counters: STAT_CPU_TIMES
stat_counters: STAT_FORK_COUNT
}
}
}
data_sources: {
config {
name: "track_event"
}
}

duration_ms: 30000
```

```
$ ./tracebox -o trace_file.perfetto-trace --txt -c config.cfg
```
3. Run the application to be traced.

4. When the `tracebox` command exits, load the trace file into the Perfetto UI

## Expected result

The track events and system events are visible in the timeline

## Actual result

Only the system events are visible

## Alternative steps

I also tried to run the `tracebox` commands separately as in [example_system_wide.cc](https://source.chromium.org/chromium/chromium/src/+/main:third_party/perfetto//examples/sdk/example_system_wide.cc)

1. Run `tracebox traced`
2. Launch the application to be traced
3. Run `tracebox perfetto -o flutter.perfetto.trace --txt -c config.cfg`
4. When the `tracebox` command exits, load the trace file into the Perfetto UI

This time the application events were visible, but no system events were present.

How can I collect a combined trace?

Many thanks.

Contributor guide

Open the contributing guide

Research direction

Start with the linked combined in-app and system tracing documentation, the Capturing a Trace guide, and examples/sdk/example_system_wide.cc. Reproduce both tracebox procedures using the supplied config and verify which event types appear in the Perfetto UI. Done means the cause of the missing event class is established and the documented procedure or behavior reliably produces a combined trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
observability-sre, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.