Span

interface Span : AutoCloseable

Represents a unit of work in a distributed trace.

Follows OpenTelemetry Semantic Conventions 1.25.0.

Thread Safety: Span implementations must be thread-safe. Spans may be modified from multiple threads.

Since

0.4.0

Inheritors

Properties

Link copied to clipboard
abstract val context: SpanContext

The span context containing trace/span IDs.

Functions

Link copied to clipboard
abstract fun addEvent(name: String, attributes: Map<String, String> = emptyMap()): Span

Add an event (annotation) to this span.

abstract fun addEvent(name: String, timestamp: Instant, attributes: Map<String, String> = emptyMap()): Span

Add an event with timestamp.

Link copied to clipboard
open override fun close()

Close is an alias for end() (for use with AutoCloseable).

Link copied to clipboard
abstract fun end()

End this span with the current timestamp.

abstract fun end(timestamp: Instant)

End this span with a specific timestamp.

Link copied to clipboard
abstract fun isRecording(): Boolean

Check if this span is recording (not a no-op).

Link copied to clipboard
abstract fun recordException(exception: Throwable): Span

Record an exception on this span.

Link copied to clipboard
abstract fun setAttribute(key: String, value: Boolean): Span

Set a boolean attribute on this span.

abstract fun setAttribute(key: String, value: Double): Span

Set a double attribute on this span.

abstract fun setAttribute(key: String, value: Long): Span

Set a long attribute on this span.

abstract fun setAttribute(key: String, value: String): Span

Set a string attribute on this span.

Link copied to clipboard
abstract fun setStatus(status: SpanStatus, description: String? = null): Span

Set the status of this span.

Link copied to clipboard
abstract fun updateName(name: String): Span

Update the span name.