abstract class OpenTelemetry::Trace::Span

Overview

A write-only span API. Implementations control the span lifetime and its recorded data. Concurrency: safe for concurrent use. Implementers must preserve this guarantee.

Direct Known Subclasses

Defined in:

api/trace/span.cr

Instance Method Summary

Instance Method Detail

def []=(key : String, value) : Nil #

[View source]
def add_event(name : String, attributes = nil, *, timestamp : Time | Nil = nil) : self #

[View source]
def add_event(name : String, *, timestamp : Time | Nil = nil, & : Attributes::Builder -> ) : self #

Runs the attribute builder block while the span is recording. Block failures are reported through the error handler and the event is skipped.


[View source]
def add_link(span_context : SpanContext, attributes = nil) : self #

Adds a link. Head samplers only see links passed at creation as links:. A link with an invalid span context is retained if it has attributes or tracestate.


[View source]
abstract def do_add_event(name : String, attributes : Attributes, timestamp : Time | Nil) : Nil #

SPI: implementers override. Applications call #add_event.


[View source]
abstract def do_add_link(link : Link) : Nil #

SPI: implementers override. Applications call #add_link.


[View source]
abstract def do_end(end_time : Time | Nil) : Nil #

SPI: implementers override. Applications call #end. Ignore repeated calls.


[View source]
abstract def do_set_attribute(key : String, value : AnyValue) : Nil #

SPI: implementers override. Applications call #set_attribute or #set_attributes.


[View source]
abstract def do_set_status(status : Status) : Nil #

SPI: implementers override. Applications call #set_status. Ignore changes after OK.


[View source]
abstract def do_update_name(name : String) : Nil #

SPI: implementers override. Applications call #update_name.


[View source]
def end(end_time : Time | Nil = nil) : Nil #

Ends the span once without changing any active context.


[View source]
def error!(description : String | Nil = nil) : self #

[View source]
def name=(name : String) : String #

[View source]
def ok! : self #

[View source]
def record_exception(exception : Exception, attributes = nil, *, timestamp : Time | Nil = nil) : self #

Records an exception event. Supplied attributes take precedence over the generated fields. Empty messages and missing backtraces are omitted. A stacktrace starts with ClassName: message and continues with one backtrace frame per line.


[View source]
abstract def recording? : Bool #

[View source]
def set_attribute(key : String, value) : self #

Sets one attribute. See Tracer#start_span for passing known attributes to samplers.


[View source]
def set_attributes(attributes) : self #

Sets multiple attributes. See Tracer#start_span for passing known attributes to samplers.


[View source]
def set_status(code : Status::Code, description : String | Nil = nil) : self #

[View source]
abstract def span_context : SpanContext #

Returns the span's immutable propagation identity.


[View source]
def status=(status : Status) : Status #

[View source]
def update_name(name : String) : self #

[View source]