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) #

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.


def self.current_trace #

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


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.


def self.validate_id(id : Slice(Uint8)) #

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


def self.validate_id(id : String) #

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


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.


def []=(key, value) #

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


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.


def close_span(span = OpenTelemetry.current_span) #

Close a previosly opened span.


def current_span : Span | Nil #

def current_span=(current_span : Span | Nil) #

def exporter #

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


def get_attribute(key) #

An alias for #[]


def id #

Return the trace_id for this trace.


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.


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.


def merge_configuration_from_provider=(val : OpenTelemetry::TraceProvider) #

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


def output_stack : Deque(Span) #

def provider : TraceProvider #

def provider=(val : OpenTelemetry::TraceProvider) #

Set the TraceProvider for this trace.


def resource : Resource #

def schema_url : String #

def schema_url=(schema_url : String) #

def service_name : String #

Return the service name of this trace.


def service_name=(val : String) #

Set the service name of this trace.


def service_version : String #

Return the service version of this trace.


def service_version=(val : String) #

Set the service version of this trace.


def set_attribute(key, value) #

An alias for #[]=


def set_sampling(span) #

ameba:disable Naming/AccessorMethodName


def span_context : SpanContext #

def span_context=(span_context : SpanContext) #

def span_stack : Array(Span) #

def to_json(json : JSON::Builder) #

def to_json #

def to_protobuf #

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


def trace_id : Slice(UInt8) #

def trace_id=(trace_id : Slice(UInt8)) #