Skip to content

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

@planetmarshall

Description

@planetmarshall

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 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 -
#include <perfetto.h>

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;
}
  1. Run tracebox as specified in 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
  1. Run the application to be traced.

  2. 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

  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions