Span API
editSpan API
editA span measures the duration of a single event.
When a span is created it will measure the time until span.end() is called.
To get a Span object,
you need to call apm.startSpan().
span.name
edit- Type: String
-
Default:
Unknown
The name of the span.
This can also be set via apm.startSpan().
span.type
edit- Type: String
-
Default:
custom
The type of span.
This can also be set via apm.startSpan().
The type is a hierarchical string used to group similar spans together.
For instance, all outgoing AJAX requests are given the type external.http.
In the above example, external is considered the type prefix.
Though there are no naming restrictions for this prefix,
the following are standardized across all Elastic APM agents:
app, db, cache, template, and external.
span.addTags()
edit
[4.1.x]
Deprecated in 4.1.x. Tags have been replaced with labels
, Please use span.addLabels() instead
span.addLabels()
editspan.addLabels({ [name]: value })
Add several labels on the span. If an error happens during the span, it will also get tagged with the same labels.
Arguments:
-
name- Any string. All periods (.), asterisks (*), and double quotation marks (") will be replaced by underscores (_), as those characters have special meaning in Elasticsearch -
value- Any string. If a non-string data type is given, it’s converted to a string before being sent to the APM Server.
span.end()
editspan.end()
Ends the span. If the span has already ended, nothing happens.