class OpenTelemetry::Trace

Included Modules

Defined in:

trace.cr
trace/exceptions.cr

Constant Summary

MATCH = /(?<trace_id>[A-Fa-f0-9]{32})/

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module OpenTelemetry::Sendable

size size, to_json to_json, to_protobuf to_protobuf

Constructor Detail

def self.new(service_name = nil, service_version = nil, schema_url = nil, exporter = nil, provider : OpenTelemetry::TraceProvider = nil) #

[View source]

Class Method Detail

def self.current_span #

Returns the current active Span in the current fiber, or nil if there is no currently active Span.


[View source]
def self.current_trace #

Returns the currently active Tracer in the current fiber, or nil if there is no currently active Tracer.


[View source]
def self.prng : Random::PCG32 #

This returns the currently initialized random number generator. The Crystal OpenTelemetry currently utilizes only the PCG32 algorithm, as in earlier versions of Crystal, the Random::ISAAC algorithm, which is arguably superior to the PCG32 algorithm, was not concurrency-safe, and would cause strange and unpleasant problems under heavy concurrent loads. If/when it is determined that this is no longer an issue, the library will support both algorithms, but will default to the ISAAC algorithm.


[View source]
def self.validate_id(id : Slice(Uint8)) #

Take a slice of UInt8 (Bytes) and determine if it is a valid trace_id.


[View source]
def self.validate_id(id : String) #

Take a string and determine if it is a valid trace_id.


[View source]

Instance Method Detail

def [](key) #

Get the value of an attribute on the Resource that is attached to this trace. This will throw an exception if the key does not exist.


[View source]
def []=(key, value) #

Set an attribute on the Resource that is attached to this trace.


[View source]
def []?(key) #

Get the value of an attribute on the Resource that is attached to this trace, or nil if the key does not exist.


[View source]
def close_span(span = OpenTelemetry.current_span) #

Close a previosly opened span.


[View source]
def current_span : Span | Nil #

[View source]
def current_span=(current_span : Span | Nil) #

[View source]
def exporter #

This returns the exporter that this trace will be exported to.


[View source]
def get_attribute(key) #

An alias for #[]


[View source]
def id #

Return the trace_id for this trace.


[View source]
def in_span(span_name) #

Start a new span in the current trace. A matching #close_span call must be made to complete the span.


[View source]
def in_span(span_name, &) #

Start a new span in the current trace. The block provided will be executed within the context of the new span, and the span will be closed automatically when the block returns.


[View source]
def merge_configuration_from_provider=(val : OpenTelemetry::TraceProvider) #

Merge the configuration from a given TraceProvider into the configuration for this trace's TraceProvider.


[View source]
def output_stack : Deque(Span) #

[View source]
def provider : TraceProvider #

[View source]
def provider=(val : OpenTelemetry::TraceProvider) #

Set the TraceProvider for this trace.


[View source]
def resource : Resource #

[View source]
def schema_url : String #

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

[View source]
def service_name : String #

Return the service name of this trace.


[View source]
def service_name=(val : String) #

Set the service name of this trace.


[View source]
def service_version : String #

Return the service version of this trace.


[View source]
def service_version=(val : String) #

Set the service version of this trace.


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

An alias for #[]=


[View source]
def set_sampling(span) #

[View source]
def span_context : SpanContext #

[View source]
def span_context=(span_context : SpanContext) #

[View source]
def span_stack : Array(Span) #

[View source]
def to_json(json : JSON::Builder) #

[View source]
def to_json #

[View source]
def to_protobuf #

This method returns a ProtoBuf object containing all of the Trace information.


[View source]
def trace_id : Slice(UInt8) #

[View source]
def trace_id=(trace_id : Slice(UInt8)) #

[View source]