Skip to content

Tracing

Kazuho Oku edited this page Aug 27, 2019 · 4 revisions

This page describes the method to obtain traces once https://github.com/h2o/quicly/pull/166 gets merged.

DTrace / eBPF Tracing

The H2O project implements dtrace (or eBPF) probes, to let the users obtain traces in a cross-protocol-stack manner.

Each subproject defines it's own probe definition in file named <subproject>-probes.d.

Step 1. Generating the Trace Script

In case of quicly, a helper program is provided for generating dtrace / ebpf script from the probe definition file.

Run misc/probe2trace.pl < quicly-probes.d > trace.d to generate and save the trace script as trace.d.

Step 2. Collecting the Trace

macOS

To collect the trace log on macOS, invoke the command that you want to run via dtrace. The example below runs the cli command, with trace.d script being attached. The trace log is stored in trace.out.

% sudo dtrace -s trace.d -o trace.out -c './cli <options...>'

As the log would contain both the output of the dtrace command and the output from the script, apply egrep '^{', to extract the output from the script (i.e., JSON logging).

Alternatively, you can specify the process ID of the cli command by using the -p option.

linux

On linux, we recommend to designate the process to be traced by using the process id. It is a bit difficult to specify the process using the path, as the path needs to be specified in the command line and also in the probe script.

First, run the cli command as usual.

Then, invoke the bpftrace command.

% sudo bpftrace -p PID_OF_CLI_COMMAND trace.d
Clone this wiki locally