Spans
editSpans
editSpans contain information about the execution of a specific code path. They measure from the start to the end of an activity, and they can have a parent/child relationship with other spans.
Agents automatically instrument a variety of libraries to capture these spans from within your application, but you can also use the Agent API for custom instrumentation of specific code paths.
Among other things, spans can contain:
-
A
transaction.id
attribute that refers to its parent transaction. -
A
parent.id
attribute that refers to its parent span or transaction. - Its start time and duration.
-
A
name
. -
A
type
,subtype
, andaction
. -
An optional
stack trace
. Stack traces consist of stack frames, which represent a function call on the call stack. They include attributes like function name, file name and path, line number, etc.
Most agents limit keyword fields, like span.id
, to 1024 characters,
and non-keyword fields, like span.start.us
, to 10,000 characters.
Spans are stored in span indices. This storage is separate from transaction indices by default.
Dropped spans
editFor performance reasons, APM agents can choose to sample or omit spans purposefully. This can be useful in preventing edge cases, like long-running transactions with over 100 spans, that would otherwise overload both the Agent and the APM Server. When this occurs, the APM app will display the number of spans dropped.
To configure the number of spans recorded per transaction, see the relevant Agent documentation:
-
Go:
ELASTIC_APM_TRANSACTION_MAX_SPANS
-
Java:
transaction_max_spans
-
.NET:
TransactionMaxSpans
-
Node.js:
transactionMaxSpans
-
PHP:
transaction_max_spans
-
Python:
transaction_max_spans
-
Ruby:
transaction_max_spans
Missing spans
editAgents stream spans to the APM Server separately from their transactions. Because of this, unforeseen errors may cause spans to go missing. Agents know how many spans a transaction should have; if the number of expected spans does not equal the number of spans received by the APM Server, the APM app will calculate the difference and display a message.