Span

sealed abstract class Span extends Operation

A Span encapsulates information about an operation performed by the application and its relationship to other operations. At the most basic level, all Spans have an operation name and they are bound to the time taken by the application to perform that operation, meaning that they have start and end time time stamps.

Spans connect to each other creating a hierarchical structure of operations, where an operation can have several child operations but only one parent operation. Furthermore, all related Spans share the same Trace information.

Spans can be enriched with two types of information: tags and marks. Tags are key/value pairs that give additional information about the operation; for example, a Span that represents an HTTP request could have tags that indicate the full request URL, the response status code and the size of the payload, information that might come handy when analyzing and troubleshooting issues using the trace data. Marks represent events related to the operation and they are bound to a specific instant in time; for example, a mark could be used to indicate the instant when a connection was established, when the SSL handshake finished and when the payload was transferred for a single HTTP request operation.

Optionally, Spans can generate metrics about the processing time of the operations they represent. By default, all Spans will generate metrics unless they are explicitly disabled. Since metrics are very susceptible to high cardinality tags, the Spans handle two different sets of tags: the Span tags that can have any sort of information (like URLs, user ids and so on) and the metric tags which should only include information with low cardinality (like HTTP status codes or operation names).

Once a Span is finished it will be flushed to the Span reporters and, if metrics stayed enabled, the processing time of the Span will be recorded on the "span.processing-time" metric with all provided metric tags in addition to the operationName and error tags which are always added.

Companion:
object
trait Operation
class Object
trait Matchable
class Any
class Delayed
object Empty.type
class Local
class Remote

Value members

Abstract methods

Disables tracking of metrics for this Span.

Disables tracking of metrics for this Span.

def fail(errorMessage: String): Span

Marks the operation represented by this Span as failed and adds the provided message as a Span tag using the "error.message" key.

Marks the operation represented by this Span as failed and adds the provided message as a Span tag using the "error.message" key.

def fail(cause: Throwable): Span

Marks the operation represented by this Span as failed and optionally adds the "error.stacktrace" Span tag with the stack trace from the provided throwable. See the "kamon.trace.include-error-stacktrace" setting for more information.

Marks the operation represented by this Span as failed and optionally adds the "error.stacktrace" Span tag with the stack trace from the provided throwable. See the "kamon.trace.include-error-stacktrace" setting for more information.

def fail(errorMessage: String, cause: Throwable): Span

Marks the operation represented by this Span as failed and adds the provided message as a Span tag using the "error.message" key and optionally adds the "error.stacktrace" Span tag with the stack trace from the provided throwable. See the "kamon.trace.include-error-stacktrace" setting for more information.

Marks the operation represented by this Span as failed and adds the provided message as a Span tag using the "error.message" key and optionally adds the "error.stacktrace" Span tag with the stack trace from the provided throwable. See the "kamon.trace.include-error-stacktrace" setting for more information.

def finish(): Unit

Finishes this Span. Even though it is possible to call any of the methods that modify/write information on the Span, once it is finished no further changes are taken into account.

Finishes this Span. Even though it is possible to call any of the methods that modify/write information on the Span, once it is finished no further changes are taken into account.

def finish(at: Instant): Unit

Finishes this Span using the provided finish instant. Even though it is possible to call any of the methods that modify/write information on the Span, once it is finished no further changes are taken into account.

Finishes this Span using the provided finish instant. Even though it is possible to call any of the methods that modify/write information on the Span, once it is finished no further changes are taken into account.

def finishAfter(duration: Duration): Unit

Finishes this Span using the provided duration. Even though it is possible to call any of the methods that modify/write information on the Span, once it is finished no further changes are taken into account.

Finishes this Span using the provided duration. Even though it is possible to call any of the methods that modify/write information on the Span, once it is finished no further changes are taken into account.

Uniquely identifies this Span within the Trace.

Uniquely identifies this Span within the Trace.

def isEmpty: Boolean

Returns true if this Span is a placeholder because no Span information is available.

Returns true if this Span is a placeholder because no Span information is available.

def isRemote: Boolean

Returns true if this Span was initially created in another process and then transferred to this process.

Returns true if this Span was initially created in another process and then transferred to this process.

def kind: Kind

Returns the kind of operation represented by this Span.

Returns the kind of operation represented by this Span.

def mark(key: String): Span

Adds a new mark with the provided key using the current instant from Kamon's clock.

Adds a new mark with the provided key using the current instant from Kamon's clock.

def mark(key: String, at: Instant): Span

Adds a new mark with the provided key and instant.

Adds a new mark with the provided key and instant.

def name(name: String): Span

Changes the operation name on this Span. Even though it is possible (and sometimes necessary) to change the operation name in a Span, take into account that the operation name might be captured by child Spans when parent operation scoping is enabled and any updates done after the child spans read the operation name will not be reflected on the "parentOperation" tag.

Changes the operation name on this Span. Even though it is possible (and sometimes necessary) to change the operation name in a Span, take into account that the operation name might be captured by child Spans when parent operation scoping is enabled and any updates done after the child spans read the operation name will not be reflected on the "parentOperation" tag.

def operationName(): String

Returns the current operation name for this Span.

Returns the current operation name for this Span.

Identifier for the parent of this this Span, if any. If a Span has no parent (e.g. it is the first Span in the trace) then an empty identifier is returned.

Identifier for the parent of this this Span, if any. If a Span has no parent (e.g. it is the first Span in the trace) then an empty identifier is returned.

Returns the position of this Span in the trace to which it belongs.

Returns the position of this Span in the trace to which it belongs.

def tag(key: String, value: String): Span

Adds the provided key/value pair to the Span tags. If a tag with the provided key was already present then its value will be overwritten.

Adds the provided key/value pair to the Span tags. If a tag with the provided key was already present then its value will be overwritten.

def tag(key: String, value: Long): Span

Adds the provided key/value pair to the Span tags. If a tag with the provided key was already present then its value will be overwritten.

Adds the provided key/value pair to the Span tags. If a tag with the provided key was already present then its value will be overwritten.

def tag(key: String, value: Boolean): Span

Adds the provided key/value pair to the Span tags. If a tag with the provided key was already present then its value will be overwritten.

Adds the provided key/value pair to the Span tags. If a tag with the provided key was already present then its value will be overwritten.

def tag(tags: TagSet): Span

Adds all key/value pairs in the provided tags to the Span tags. If a tag with the provided key was already present then its value will be overwritten.

Adds all key/value pairs in the provided tags to the Span tags. If a tag with the provided key was already present then its value will be overwritten.

def tagMetrics(key: String, value: String): Span

Adds the provided key/value pair to the Span metric tags. If a tag with the provided key was already present then its value will be overwritten.

Adds the provided key/value pair to the Span metric tags. If a tag with the provided key was already present then its value will be overwritten.

def tagMetrics(key: String, value: Long): Span

Adds the provided key/value pair to the Span metric tags. If a tag with the provided key was already present then its value will be overwritten.

Adds the provided key/value pair to the Span metric tags. If a tag with the provided key was already present then its value will be overwritten.

def tagMetrics(key: String, value: Boolean): Span

Adds the provided key/value pair to the Span metric tags. If a tag with the provided key was already present then its value will be overwritten.

Adds the provided key/value pair to the Span metric tags. If a tag with the provided key was already present then its value will be overwritten.

def tagMetrics(tags: TagSet): Span

Adds all key/value pairs in the provided tags to the Span metric tags. If a tag with the provided key was already present then its value will be overwritten.

Adds all key/value pairs in the provided tags to the Span metric tags. If a tag with the provided key was already present then its value will be overwritten.

Makes the Span decide for a Sample or DoNotSample decision for the Trace it belongs to, in case the current that the current Sampling Decision is Unknown. If the Sampling Decision is already taken, calling this method will have no effect on the Span.

Makes the Span decide for a Sample or DoNotSample decision for the Trace it belongs to, in case the current that the current Sampling Decision is Unknown. If the Sampling Decision is already taken, calling this method will have no effect on the Span.

Trace to which this Span belongs.

Trace to which this Span belongs.

Enables tracking of metrics for this Span. For a plain Span, this means that the span.processing-time metric will be tracked and for a Delayed Span, the span.elapsed-time and span.wait-time metrics will be tracked as well.

Enables tracking of metrics for this Span. For a plain Span, this means that the span.processing-time metric will be tracked and for a Delayed Span, the span.elapsed-time and span.wait-time metrics will be tracked as well.