Transactions

A transaction describes an event captured by an Elastic APM agent instrumeting a service. A transaction can for example be an HTTP request or an asynchrounous background job.

It contains the timestamp and duration of the event, a unique id, type, name, a result (for example a response code), some contextual data, and other relevant information depending on the agent. For instance, the JavaScript RUM captures transaction marks, which are points in time relative to the start of the transaction with some label.

The contextual data describes the environment in which an event is recorded. It includes the service, the system where the service runs, and the process.

It can also contain information about the authenticated user.

An event’s context can also include information about an authenticated user, a request leading to it, or a response. For instance, HTTP requests context have url, cookies, body, headers, etc.

The agents provide some settings for users to capture customized information. This data is stored as not-indexed in a custom object. Searchable information is stored as tags instead.

Agents decide whether to sample transactions or not, and provide settings to control sampling behaviour. If sampled, the spans of a transaction are sent and stored seperate documents.

Transactions are stored in transaction indices.

Spans

Transactions can have 0, 1, or many spans. Spans have a transaction.id attribute that refer to their transaction.

A span contains information about a specific code path, executed as part of a transaction. Such information includes start time, duration, name, type, and optionally a stack trace.

If for example a database query happens within a sampled transaction, a span describing the database query will be created. In such a case the name of the span will contain information about the query itself, and the type about the database.

Typically, agents instrument automatically a variety of libraries, but also provide an API for ad hoc instrumentation of specific code paths.

Transactions are stored in transaction indices and spans are stored in separated indices by default.

Spans are stored in span indices.