5 If you read all the sections of
6 [Controlling tracing](#doc-controlling-tracing) so far, you should be
7 able to create tracing sessions, create and enable channels and events
8 within them and start/stop the LTTng tracers. Event fields recorded in
9 trace files provide important information about occurring events, but
10 sometimes external context may help you solve a problem faster. This
11 section discusses how to add context information to events of a
12 specific channel using the `lttng` tool.
14 There are various available context values which can accompany events
15 recorded by LTTng, for example:
17 * **process information**:
21 * scheduling priority (niceness)
22 * thread identifier (TID)
23 * the **hostname** of the system on which the event occurred
24 * plenty of **performance counters** using perf, for example:
25 * CPU cycles, stalled cycles, idle cycles, and the other cycle types
27 * branch instructions, misses, loads
30 The full list is available in the output of `lttng add-context --help`.
31 Some of them are reserved for a specific domain (kernel or
32 user space) while others are available for both.
34 To add context information to one or all channels of a given tracing
35 session, use the `add-context` command:
38 lttng add-context --userspace --type vpid --type perf:thread:cpu-cycles
41 The above example adds the virtual process identifier and per-thread
42 CPU cycles count values to all recorded user space domain events of the
43 current tracing session. Use the `--channel` option to select a specific
47 lttng add-context --kernel --channel my-channel --type tid
50 adds the thread identifier value to all recorded kernel domain events
51 in the channel `my-channel` of the current tracing session.
53 Beware that context information cannot be removed from channels once
54 it's added for a given tracing session.