| LTTNG-ADD-CONTEXT(1) | LTTng Manual | LTTNG-ADD-CONTEXT(1) |
lttng-add-context - Add context fields to be recorded by LTTng
Add context fields to be recorded to the event records of one or more channels:
lttng [GENERAL OPTIONS] add-context
(--kernel | --userspace | --jul | --log4j)
[--session=SESSION] [--channel=CHANNEL]
--type=TYPE [--type=TYPE]...
List the available context field types:
lttng [GENERAL OPTIONS] add-context --list
The lttng add-context command can:
Without the --list option
With the --session=SESSION option
Without the --session option
With the --channel=CHANNEL
Without the --channel option
With the --list option
See lttng-concepts(7) to learn more about recording sessions and channels.
Repeat the --type=TYPE option to add more than one context field to be recorded. TYPE is one of:
Per-CPU
Only available with the --kernel option.
Per-thread
Only available with the --userspace, --jul, or --log4j option.
Add Performance Monitoring Unit (PMU) counter context fields by raw ID with the perf:cpu:raw:rN:NAME (--kernel option) or perf:thread:raw:rN:NAME (--userspace, --jul, or --log4j option) types, with:
N
The possible values for this part are processor-specific.
NAME
$app.PROVIDER:TYPE
TYPE
Only available with the --jul and --log4j options.
Important
Make sure to single-quote TYPE when you run the add-context command from a shell, as $ is a special character for variable substitution in most shells.
Note
As of LTTng 2.13.15, you may NOT add context fields to be recorded to the event records of a given channel once its recording session has been started (see lttng-start(1)) at least once.
See the “EXAMPLES” section below for usage examples.
See lttng(1) for GENERAL OPTIONS.
One of:
-j, --jul
-k, --kernel
-l, --log4j
-u, --userspace
-c CHANNEL, --channel=CHANNEL
-s SESSION, --session=SESSION
--list
You may NOT use this option with the --channel, --session, or --type options.
-t TYPE, --type=TYPE
Repeat this option to add more than one context field.
-h, --help
This option attempts to launch /usr/bin/man to view this manual page. Override the manual pager path with the LTTNG_MAN_BIN_PATH environment variable.
--list-options
0
1
2
3
4
LTTNG_ABORT_ON_ERROR
LTTNG_HOME
Defaults to $HOME.
Useful when the Unix user running the commands has a non-writable home directory.
LTTNG_MAN_BIN_PATH
LTTNG_SESSION_CONFIG_XSD_PATH
LTTNG_SESSIOND_PATH
The --sessiond-path general option overrides this environment variable.
$LTTNG_HOME/.lttngrc
This is where LTTng stores the name of the Unix user’s current recording session between executions of lttng(1). lttng-create(1) and lttng-set-session(1) set the current recording session.
$LTTNG_HOME/lttng-traces
Override this path with the --output option of the lttng-create(1) command.
$LTTNG_HOME/.lttng
$LTTNG_HOME/.lttng/sessions
/etc/lttng/sessions
Note
$LTTNG_HOME defaults to the value of the HOME environment variable.
Example 1. List the available context field types.
See the --list option.
$ lttng add-context --list
Example 2. Add a single statically-known context field to be recorded to all the Linux kernel channels of the current recording session.
$ lttng add-context --kernel --type=pid
Example 3. Add three statically-known context fields to be recorded to a specific user space channel of a specific recording session.
See the --session and --channel options.
$ lttng add-context --userspace --session=my-session \
--channel=my-channel \
--type=vpid --type=procname --type=ip
Example 4. Add a perf counter context field to be recorded to a specific Linux kernel channel of the current recording session.
See the --channel option.
$ lttng add-context --kernel --channel=my-channel \
--type=perf:cpu:cache-misses
Example 5. Add an LTTng application-specific context field to be recorded to all the JUL channels of the current recording session.
$ lttng add-context --jul --type='$app.my_server:user_cnt'
This program is part of the LTTng-tools project.
LTTng-tools is distributed under the GNU General Public License version 2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html>. See the LICENSE <https://github.com/lttng/lttng-tools/blob/master/LICENSE> file for details.
Special thanks to Michel Dagenais and the DORSAL laboratory <http://www.dorsal.polymtl.ca/> at École Polytechnique de Montréal for the LTTng journey.
Also thanks to the Ericsson teams working on tracing which helped us greatly with detailed bug reports and unusual test cases.
| 14 June 2021 | LTTng 2.13.15 |