![]() |
LTTng control library C API
|

Data Structures | |
| struct | lttng_event |
| Recording event rule descriptor. More... | |
| union | lttng_event_attr_u |
| Linux kprobe/kretprobe recording event rule configuration. More... | |
| struct | lttng_event_probe_attr |
| Legacy Linux kprobe/kretprobe location. More... | |
Functions | |
| int | lttng_disable_event (struct lttng_handle *handle, const char *event_rule_name, const char *channel_name) |
Alias of lttng_disable_event_ext() which creates a temporary recording event rule descriptor, settings its lttng_event::name member to event_rule_name if not NULL and its lttng_event::type member to LTTNG_EVENT_ALL. | |
| int | lttng_disable_event_ext (struct lttng_handle *handle, struct lttng_event *event_rule, const char *channel_name, const char *filter_expr) |
Disables recording event rules by instrumentation point type and event name condition within the event record channel named channel_name (or within a default event record channel if NULL) within the recording session handle handle. | |
| int | lttng_enable_event (struct lttng_handle *handle, struct lttng_event *event_rule, const char *channel_name) |
Alias of lttng_enable_event_with_exclusions() which passes the event payload and context filter expression of event_rule as the filter_expr parameter and the event name exclusion patterns of event_rule as the event_name_exclusion_count and event_name_exclusions parameters. | |
| int | lttng_enable_event_with_exclusions (struct lttng_handle *handle, struct lttng_event *event_rule, const char *channel_name, const char *filter_expr, int event_name_exclusion_count, char **event_name_exclusions) |
Creates or enables a recording event rule described by event_rule, having the event payload and context filter expression filter_expr and the event name exclusion patterns event_name_exclusions, within the event record channel named channel_name (or within a default event record channel if NULL) within the recording session handle handle. | |
| int | lttng_enable_event_with_filter (struct lttng_handle *handle, struct lttng_event *event_rule, const char *channel_name, const char *filter_expr) |
Alias of lttng_enable_event_with_exclusions() which passes the the event name exclusion patterns of event_rule as the event_name_exclusion_count and event_name_exclusions parameters. | |
| struct lttng_event * | lttng_event_create (void) |
| Creates and returns an empty recording event rule descriptor. | |
| void | lttng_event_destroy (struct lttng_event *event_rule) |
Destroys the recording event rule descriptor event_rule. | |
| int | lttng_event_get_exclusion_name (const struct lttng_event *event_rule, size_t index, const char **event_name_exclusion) |
Sets *event_name_exclusion to the event name exclusion pattern at index index of the recording event rule described by event_rule. | |
| int | lttng_event_get_exclusion_name_count (const struct lttng_event *event_rule) |
Returns the number of event name exclusion patterns of the recording event rule described by event_rule. | |
| int | lttng_event_get_filter_expression (const struct lttng_event *event_rule, const char **filter_expr) |
Sets *filter_expr to the event payload and context filter expression of the recording event rule described by event_rule. | |
| const struct lttng_userspace_probe_location * | lttng_event_get_userspace_probe_location (const struct lttng_event *event_rule) |
Returns the Linux user space probe location of the recording event rule described by event_rule. | |
| int | lttng_event_set_userspace_probe_location (struct lttng_event *event_rule, struct lttng_userspace_probe_location *location) |
Sets the Linux user space probe location of the recording event rule described by event_rule to location. | |
An instrumentation point is a point, within a piece of software, which, when executed, creates an LTTng event. See Instrumentation point listing API to learn how to list the available instrumentation points.
An event rule is a set of conditions to match a set of events.
A recording event rule is a specific type of event rule of which the action is to serialize and write the matched event as an event record to a sub-buffer of its attached event record channel.
An event record has a name and fields.
When LTTng creates an event E, a recording event rule ER is said to match E when E satisfies all the conditions of ER. This concept is similar to a regular expression which matches a set of strings.
When a recording event rule matches an event, LTTng emits the event, therefore attempting to record it.
The event creation and emission processes are documentation concepts to help understand the journey from an instrumentation point to an event record.
The actual creation of an event can be costly because LTTng needs to evaluate the arguments of the instrumentation point.
In practice, LTTng implements various optimizations for the Linux kernel and user space tracing domains to avoid actually creating an event when the tracer knows, thanks to properties which are independent from the event payload and current context, that it would never emit such an event. Those properties are:
In other words: if, for a given instrumentation point IP, the LTTng tracer knows that it would never emit an event, executing IP represents a simple boolean variable check and, for a Linux kernel recording event rule, a few current process attribute checks.
You always attach a recording event rule to an event record channel, which belongs to a recording session, when you create it. An event record channel owns recording event rules.
When multiple matching recording event rules are attached to the same event record channel, LTTng attempts to serialize and record the matched event once.
As of LTTng-tools 16.2, you cannot remove a recording event rule: it exists as long as its recording session exists.
The recording event rule operations are:
| Operation | Means |
|---|---|
| Creation |
|
| Property access | See:
|
| Enabling | With an lttng_event instance which comes from lttng_list_events(), use lttng_enable_event(). Otherwise, use lttng_enable_event_with_exclusions().
|
| Disabling | Use lttng_disable_event() or lttng_disable_event_ext().
|
For LTTng to emit and record an event E, E must satisfy all the conditions of a recording event rule ER, that is:
You set the following conditions when you create ER from some recording event rule descriptor event_rule (lttng_event).
| Name | Description |
|---|---|
| Instrumentation point type | E satisfies the instrumentation point type condition of ER if the instrumentation point from which LTTng creates E is, depending on the tracing domain which contains ER:
|
| Event name | An event E satisfies the event name condition of ER if the two following statements are true:
This condition is only meaningful when In all cases, |
| Instrumentation point log level | An event E satisfies the instrumentation point log level condition of ER if, depending on
This condition is only meaningful when the tracing domain containing ER is not LTTNG_DOMAIN_KERNEL: it's always satisfied for LTTNG_DOMAIN_KERNEL. |
| Event payload and context filter | An event E satisfies the event payload and context filter condition of ER if This condition is only meaningful when Set the event payload and context filter expression of Get the event payload and context filter expression of |
ER itself is enabled.
A recording event rule is enabled on creation.
The event record channel which contains ER is enabled.
An event record channel is enabled on creation.
The recording session which contains ER is active (started).
A recording session is inactive (stopped) on creation.
The process for which LTTng creates E is allowed to record events.
All processes are allowed to record events on recording session creation.
When LTTng records an event E, the resulting event record has a name which depends on the instrumentation point type condition of the recording event rule ER which matched E as well as on the tracing domain which contains ER:
| Tracing domain | Instrumentation point type | Event record name |
|---|---|---|
| LTTNG_DOMAIN_KERNEL or LTTNG_DOMAIN_UST | LTTNG_EVENT_TRACEPOINT | Full name of the tracepoint from which LTTng creates E. Note that the full name of a user space tracepoint is |
| LTTNG_DOMAIN_JUL | LTTNG_EVENT_TRACEPOINT |
Such an event record has a string field |
| LTTNG_DOMAIN_LOG4J | LTTNG_EVENT_TRACEPOINT |
Such an event record has a string field |
| LTTNG_DOMAIN_LOG4J2 | LTTNG_EVENT_TRACEPOINT |
Such an event record has a string field |
| LTTNG_DOMAIN_PYTHON | LTTNG_EVENT_TRACEPOINT |
Such an event record has a string field |
| LTTNG_DOMAIN_KERNEL | LTTNG_EVENT_SYSCALL | Location:
|
| LTTNG_DOMAIN_KERNEL | LTTNG_EVENT_PROBE or LTTNG_EVENT_USERSPACE_PROBE | The lttng_event::name member of the descriptor you used to create ER with lttng_enable_event_with_exclusions(). |
| LTTNG_DOMAIN_KERNEL | LTTNG_EVENT_FUNCTION | Location:
where |
| enum lttng_event_type |
Instrumentation point type condition of a recording event rule, or instrumentation point type when lttng_list_tracepoints() or lttng_list_syscalls() creates the lttng_event structure.
| Enumerator | |
|---|---|
| LTTNG_EVENT_ALL |
|
| LTTNG_EVENT_TRACEPOINT |
|
| LTTNG_EVENT_PROBE |
|
| LTTNG_EVENT_FUNCTION |
|
| LTTNG_EVENT_SYSCALL |
|
| LTTNG_EVENT_USERSPACE_PROBE |
|
| enum lttng_loglevel |
Value of the instrumentation point log level condition of an LTTng user space tracepoint recording event rule descriptor.
| enum lttng_loglevel_jul |
Value of the instrumentation point log level condition of a java.util.logging recording event rule.
| enum lttng_loglevel_log4j |
Value of the instrumentation point log level condition of an Apache log4j 1.x recording event rule.
| Enumerator | |
|---|---|
| LTTNG_LOGLEVEL_LOG4J_OFF | Logging turned off. |
| LTTNG_LOGLEVEL_LOG4J_FATAL | Very severe error events that will presumably lead the application to abort. |
| LTTNG_LOGLEVEL_LOG4J_ERROR | Error events that might still allow the application to continue running. |
| LTTNG_LOGLEVEL_LOG4J_WARN | Potentially harmful situations. |
| LTTNG_LOGLEVEL_LOG4J_INFO | Informational messages that highlight the progress of the application at coarse-grained level. |
| LTTNG_LOGLEVEL_LOG4J_DEBUG | Fine-grained informational events that are most useful to debug an application. |
| LTTNG_LOGLEVEL_LOG4J_TRACE | Finer-grained informational events than the LTTNG_LOGLEVEL_LOG4J_DEBUG level. |
| LTTNG_LOGLEVEL_LOG4J_ALL | All levels, including custom levels. |
Value of the instrumentation point log level condition of a Apache Log4j 2 recording event rule.
| Enumerator | |
|---|---|
| LTTNG_LOGLEVEL_LOG4J2_OFF | Logging turned off. |
| LTTNG_LOGLEVEL_LOG4J2_FATAL | Very severe error events that will presumably lead the application to abort. |
| LTTNG_LOGLEVEL_LOG4J2_ERROR | Error events that might still allow the application to continue running. |
| LTTNG_LOGLEVEL_LOG4J2_WARN | Potentially harmful situations. |
| LTTNG_LOGLEVEL_LOG4J2_INFO | Informational messages that highlight the progress of the application at coarse-grained level. |
| LTTNG_LOGLEVEL_LOG4J2_DEBUG | Fine-grained informational events that are most useful to debug an application. |
| LTTNG_LOGLEVEL_LOG4J2_TRACE | Finer-grained informational events than the LTTNG_LOGLEVEL_LOG4J2_DEBUG level. |
| LTTNG_LOGLEVEL_LOG4J2_ALL | All levels, including custom levels. |
Value of the instrumentation point log level condition of a Python recording event rule.
| enum lttng_loglevel_type |
Operand of the instrumentation point log level condition of a recording event rule.
In the enumerator descriptions below, consider that LL is the log level value of the condition, that is, the value of the lttng_event::loglevel member when the lttng_event::loglevel_type member is the described enumerator.
Depending on the tracing domain of the recording event rule, LL is one of the enumerators of lttng_loglevel, lttng_loglevel_jul, lttng_loglevel_log4j, lttng_loglevel_log4j2, or lttng_loglevel_python.
|
extern |
Alias of lttng_disable_event_ext() which creates a temporary recording event rule descriptor, settings its lttng_event::name member to event_rule_name if not NULL and its lttng_event::type member to LTTNG_EVENT_ALL.
This function is equivalent to:
| [in] | handle | See lttng_disable_event_ext(). |
| [in] | event_rule_name | What to use as the lttng_event::name member of the created temporary event rule descriptor passed to lttng_disable_event_ext(). |
| [in] | channel_name | See lttng_disable_event_ext(). |
|
extern |
Disables recording event rules by instrumentation point type and event name condition within the event record channel named channel_name (or within a default event record channel if NULL) within the recording session handle handle.
Depending on event_rule->name, this function:
Depending on event_rule->type:
Disables all the recording event rules of which the event name pattern is exactly event_rule->name within the selected event record channel.
Disables all the recording event rules of which the instrumentation point type is event_rule->type and the event name pattern is exactly event_rule->name within the selected event record channel.
Only supported when handle->domain.type is LTTNG_DOMAIN_KERNEL.
Depending on event_rule->type:
Disables all the recording event rules within the selected event record channel.
Disables all the recording event rules of which the instrumentation point type is event_rule->type within the selected event record channel.
Only supported when handle->domain.type is LTTNG_DOMAIN_KERNEL.
This function ignores all the other condition properties of event_rule.
To use this function, create a temporary, zeroed recording event rule descriptor, setting only:
handle->domain.type is LTTNG_DOMAIN_KERNEL: its lttng_event::type member.For example:
| [in] | handle | Recording session handle which contains the name of the recording session and the summary of the tracing domain which own the selected event record channel. |
| [in] | event_rule | Recording event rule descriptor which contains the instrumentation point type and event name conditions to consider to disable recording event rules within the selected event record channel. |
| [in] | channel_name | Name of the event record channel, within If |
| [in] | filter_expr | Unused: must be NULL. |
Success
handle is not NULL.handle->session_name is a valid (null-terminated) C string.handle->session_name names an accessible recording session within the connected session daemon.handle->domain is valid as per the documentation of lttng_domain.event_rule is not NULL.handle->domain.type is not LTTNG_DOMAIN_KERNEL, then event_rule->type is LTTNG_EVENT_ALL.event_rule->type is the instrumentation point type of at least one Linux kernel recording event rule within the selected event record channel.event_rule->name is the exact event name pattern of at least one recording event rule within the selected event record channel.NULL, then channel_name names an existing event record channel within the recording session and tracing domain of handle.channel_name is NULL, then the event record channel named channel0 exists within the recording session and tracing domain of handle.event_rule->type set to LTTNG_EVENT_ALL.
|
extern |
Alias of lttng_enable_event_with_exclusions() which passes the event payload and context filter expression of event_rule as the filter_expr parameter and the event name exclusion patterns of event_rule as the event_name_exclusion_count and event_name_exclusions parameters.
This function is equivalent to:
| [in] | handle | See lttng_enable_event_with_exclusions(). |
| [in] | event_rule | See lttng_enable_event_with_exclusions(). |
| [in] | channel_name | See lttng_enable_event_with_exclusions(). |
|
extern |
Creates or enables a recording event rule described by event_rule, having the event payload and context filter expression filter_expr and the event name exclusion patterns event_name_exclusions, within the event record channel named channel_name (or within a default event record channel if NULL) within the recording session handle handle.
This function, depending on the instrumentation point type, event name, and log level conditions of event_rule, as well as on filter_expr and event_name_exclusions:
Enables the existing recording event rule.
If event_rule->type is LTTNG_EVENT_ALL and handle->domain.type is LTTNG_DOMAIN_KERNEL, then this function actually creates or enables two recording event rules: one with the LTTNG_EVENT_TRACEPOINT type, and one with the LTTNG_EVENT_SYSCALL type.
| [in] | handle | Recording session handle which contains the name of the recording session and the summary of the tracing domain which own the selected event record channel. |
| [in] | event_rule | Descriptor of the recording event rule to create or enable. This function:
|
| [in] | channel_name | Name of the event record channel, within If |
| [in] | filter_expr | Event payload and context filter expression of the recording event rule to create or enable (copied). If This parameter, even when |
| [in] | event_name_exclusion_count | Number of items in event_name_exclusions. |
| [in] | event_name_exclusions | Event name exclusion patterns of the recording event rule to create or enable. This function copies the strings of this array.
This parameter, even when |
Success
handle is not NULL.handle->session_name is a valid (null-terminated) C string.handle->session_name names an accessible recording session within the connected session daemon.handle->domain is valid as per the documentation of lttng_domain.event_rule is not NULL.event_rule is valid.handle->domain.type is not LTTNG_DOMAIN_KERNEL, then event_rule->type is LTTNG_EVENT_TRACEPOINT.handle->domain.type is not LTTNG_DOMAIN_UST, then event_name_exclusion_count is 0.NULL, channel_name names an existing event record channel within the recording session and tracing domain of handle.channel_name is NULL, then handle contains either no event record channels or a default event record channel named channel0.NULL, filter_expr is a valid event payload and context filter expression.event_name_exclusion_count ≥ 0.
|
extern |
Alias of lttng_enable_event_with_exclusions() which passes the the event name exclusion patterns of event_rule as the event_name_exclusion_count and event_name_exclusions parameters.
This function is equivalent to:
| [in] | handle | See lttng_enable_event_with_exclusions(). |
| [in] | event_rule | See lttng_enable_event_with_exclusions(). |
| [in] | channel_name | See lttng_enable_event_with_exclusions(). |
| [in] | filter_expr | See lttng_enable_event_with_exclusions(). |
|
extern |
Creates and returns an empty recording event rule descriptor.
After you create a recording event rule descriptor with this function, you can modify its properties and call lttng_enable_event_with_exclusions() to create and enable a recording event rule.
New recording event rule descriptor.
Destroy the returned recording event rule descriptor with lttng_event_destroy().
|
extern |
Destroys the recording event rule descriptor event_rule.
event_rule describes: you can't destroy a recording event rule.| [in] | event_rule | Recording event rule descriptor to destroy. May be |
NULL, event_rule was created with lttng_event_create().
|
extern |
Sets *event_name_exclusion to the event name exclusion pattern at index index of the recording event rule described by event_rule.
| [in] | event_rule | Descriptor of the recording event rule of which to get the event name exclusion pattern at index index. |
| [in] | index | Index of the event name exclusion pattern to get from event_rule. |
| [out] | event_name_exclusion | On success, this function sets
|
Success.
event_rule is not NULL.index is less than the number of event name exclusion patterns (as returned by lttng_event_get_exclusion_name_count()) of event_rule.event_name_exclusion is not NULL.
|
extern |
Returns the number of event name exclusion patterns of the recording event rule described by event_rule.
| [in] | event_rule | Descriptor of the recording event rule of which to get the number of event name exclusion patterns. |
event_rule, or a negative lttng_error_code enumerator otherwise.event_rule is not NULL.
|
extern |
Sets *filter_expr to the event payload and context filter expression of the recording event rule described by event_rule.
| [in] | event_rule | Descriptor of the recording event rule of which to get the event payload and context filter expression. |
| [out] | filter_expr | On success, this function sets
|
Success.
event_rule is not NULL.filter_expr is not NULL.
|
extern |
Returns the Linux user space probe location of the recording event rule described by event_rule.
| [in] | event_rule | Descriptor of the recording event rule of which to get the Linux user space probe location. |
Linux user space probe location of the recording event rule described by event_rule, or NULL if none.
The returned location remains valid as long as event_rule exists and you don't modify it.
event_rule is not NULL.event_rule->type (see lttng_event::type) is LTTNG_EVENT_USERSPACE_PROBE.
|
extern |
Sets the Linux user space probe location of the recording event rule described by event_rule to location.
| [in] | event_rule | Descriptor of the recording event rule of which to set the Linux user space probe location to location. |
| [in] | location | New Linux user space probe location of event_rule. |
Success.
event_rule is not NULL.event_rule was created with lttng_event_create().event_rule->type (see lttng_event::type) is LTTNG_EVENT_USERSPACE_PROBE.location is not NULL.*location is invalid (its ownership is transfered to event_rule).