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

Data Structures | |
| struct | lttng_event_rule |
| Event rule (opaque type). More... | |
Enumerations | |
| enum | lttng_event_rule_status { LTTNG_EVENT_RULE_STATUS_OK , LTTNG_EVENT_RULE_STATUS_ERROR , LTTNG_EVENT_RULE_STATUS_UNKNOWN , LTTNG_EVENT_RULE_STATUS_INVALID , LTTNG_EVENT_RULE_STATUS_UNSET , LTTNG_EVENT_RULE_STATUS_UNSUPPORTED } |
| Return type of event rule API functions. More... | |
| enum | lttng_event_rule_type { LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT , LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL , LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE , LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE , LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT , LTTNG_EVENT_RULE_TYPE_JUL_LOGGING , LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING , LTTNG_EVENT_RULE_TYPE_LOG4J2_LOGGING , LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING , LTTNG_EVENT_RULE_TYPE_UNKNOWN } |
| Event rule type. More... | |
Functions | |
| void | lttng_event_rule_destroy (struct lttng_event_rule *rule) |
Destroys the event rule rule. | |
| enum lttng_event_rule_type | lttng_event_rule_get_type (const struct lttng_event_rule *rule) |
Returns the type of the event rule rule. | |
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.
An event has a name and fields.
When LTTng creates an event E, an 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 an event rule matches an event, LTTng emits the event, therefore attempting to execute an action.
The event creation and emission processes are documentation concepts to help understand the journey from an instrumentation point to the execution of an action.
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 event rule, a few current process attribute checks.
The only purpose of an event rule object is to create an “event rule matches” trigger condition from it. When the event rule of the trigger condition matches an event, LTTng can execute a user-defined action such as sending an LTTng notification, starting a recording session, and more.
Get the type of an event rule with lttng_event_rule_get_type().
Destroy an event rule with lttng_event_rule_destroy().
lttng-concepts(7).lttng-event-rule(7).For LTTng to emit an event E, E must satisfy all the conditions of an event rule ER.
You set the following conditions when or after you create ER with one of the creation functions listed below:
| Condition | 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 type of ER:
|
| Event name | An event E satisfies the event name condition of ER if the two following statements are true:
This condition isn't meaningful (always satisfied) if the type of ER is LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE or LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE. In all cases, the event name and event name exclusion patterns are globbing patterns: the |
| Instrumentation point log level | An event E satisfies the instrumentation point log level condition of ER if the log level LL of the LTTng user space tracepoint or logging statement from which LTTng creates E satisfies the log level rule LLR of ER. An event E satisfies this condition if LL is, depending on the type of LLR:
If ER has no log level rule, then this condition is always satisfied. This condition isn't meaningful (always satisfied) if the type of ER is one of:
When you create ER, there's no initial log level rule (this condition is always satisfied). Set the log level rule of ER with one of:
Get the log level rule of ER with one of: |
| Event payload and context filter | An event E satisfies the event payload and context filter condition of ER if ER has no filter expression or if its filter expression EXPR evaluates to true when LTTng creates E. This condition isn't meaningful (always satisfied) if the type of ER is LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE or LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE. When you create ER, the initial event payload and context filter is equivalent to Set the event payload and context filter expression of ER with one of:
Get the event payload and context filter expression of ER with one of:
|
When LTTng emits an event E, the resulting event has a name which depends on the instrumentation point type condition of the event rule ER which matched E:
| Instrumentation point type | Event name |
|---|---|
| LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT or LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT | Full name of the tracepoint from which LTTng creates E. Note that the full name of an LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT event rule is |
| LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL | Location:
|
| LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE or LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE | Location:
where Both lttng_event_rule_kernel_kprobe_create() and lttng_event_rule_kernel_uprobe_create() set an initial event name from the probe location. Override the event name of ER with lttng_event_rule_kernel_kprobe_set_event_name() or lttng_event_rule_kernel_uprobe_set_event_name(). Get the event name of ER with lttng_event_rule_kernel_kprobe_get_event_name() or lttng_event_rule_kernel_uprobe_get_event_name(). |
| LTTNG_EVENT_RULE_TYPE_JUL_LOGGING |
Such an event has a string field |
| LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING |
Such an event has a string field |
| LTTNG_EVENT_RULE_TYPE_LOG4J2_LOGGING |
Such an event has a string field |
| LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING |
Such an event has a string field |
Event rule type.
See the instrumentation point type condition.
Get the type of an event rule with lttng_event_rule_get_type().
| Enumerator | |
|---|---|
| LTTNG_EVENT_RULE_TYPE_KERNEL_TRACEPOINT | Match LTTng kernel tracepoints. |
| LTTNG_EVENT_RULE_TYPE_KERNEL_SYSCALL | Match Linux kernel system calls. |
| LTTNG_EVENT_RULE_TYPE_KERNEL_KPROBE | Match Linux kprobes. |
| LTTNG_EVENT_RULE_TYPE_KERNEL_UPROBE | Match Linux user space probes. |
| LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT | Match LTTng user space tracepoints. |
| LTTNG_EVENT_RULE_TYPE_JUL_LOGGING | |
| LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING | |
| LTTNG_EVENT_RULE_TYPE_LOG4J2_LOGGING | |
| LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING | Match Python logging statements. |
| LTTNG_EVENT_RULE_TYPE_UNKNOWN | Unknown (error). |
|
extern |
Destroys the event rule rule.
| [in] | rule | Event rule to destroy. May be |
|
extern |
Returns the type of the event rule rule.
| [in] | rule | Event rule of which to get the type. |
rule.rule is not NULL.