WARNING: Version 6.2 of APM Server has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Spansedit
A span contains information about a specific code path, executed as part of a transaction. Every span is identified by an unique ID per transaction.
Elastic APM agents automatically instrument a variety of libraries, but also support custom instrumentation for code paths.
Every code path that is captured by an agent creates a span. Spans at least collect information about when the code path execution started, the duration, and the type of the code path execution.
This means, if for example a database query happens within a recorded transaction, a span representing this database query will be created. In such a case the name of the span will contain information about the query itself, and the type will hold information about the database type.
Some of the key attributes of a span are described in more detail:
Contextedit
In case a database query was captured, the span’s context contains information about this database access. The context also contains information about the service the agent is monitoring.
Spanedit
The information available within the span group includes the duration of the recorded span,
a unique ID within a transaction and an automatically retrieved name.
Additionally a span can contain stack trace
information.
Example documentedit
{ "context": { "db": { "instance": "customers", "statement": "SELECT * FROM product_types WHERE user_id=?", "type": "sql", "user": "readonly_user" }, "service": { "agent": { "name": "elastic-node", "version": "3.14.0" }, "name": "1234_service-12a3" } }, "processor": { "event": "span", "name": "transaction" }, "span": { "duration": { "us": 3781 }, "id": 0, "name": "SELECT FROM product_types", "stacktrace": [ { "abs_path": "net.js", "context": { "post": [ " ins.currentTransaction = prev", " return result", "}" ], "pre": [ " var trans = this.currentTransaction", "" ] }, "exclude_from_grouping": false, "filename": "net.js", "function": "onread", "library_frame": true, "line": { "column": 4, "context": "line3", "number": 547 }, "module": "some module", "vars": { "key": "value" } }, { "exclude_from_grouping": false, "filename": "my2file.js", "line": { "number": 10 } } ], "start": { "us": 2830 }, "type": "db.postgresql.query" }, "transaction": { "id": "945254c5-67a5-417e-8a4e-aa29efcbfb79" } }