Class: Riffer::Tracing::Otel::Span

Inherits:
Object
  • Object
show all
Defined in:
lib/riffer/tracing/otel.rb,
sig/generated/riffer/tracing/otel.rbs

Overview

Wraps a live OTEL span behind the port's span surface, so callers never touch ::OpenTelemetry constants (status objects in particular).

Instance Method Summary collapse

Constructor Details

#initialize(otel_span) ⇒ Span

-- : (untyped) -> void

Parameters:

  • (Object)


17
18
19
# File 'lib/riffer/tracing/otel.rb', line 17

def initialize(otel_span)
  @otel_span = otel_span
end

Instance Method Details

#add_event(name, attributes: nil) ⇒ void

This method returns an undefined value.

-- : (String, ?attributes: Hash[String, untyped]?) -> void

Parameters:

  • (String)
  • attributes: (Hash[String, untyped], nil) (defaults to: nil)


29
30
31
# File 'lib/riffer/tracing/otel.rb', line 29

def add_event(name, attributes: nil)
  @otel_span.add_event(name, attributes: attributes)
end

#error!(description = "") ⇒ void

This method returns an undefined value.

Marks the span status as error.

: (?String) -> void

Parameters:

  • (String)


42
43
44
# File 'lib/riffer/tracing/otel.rb', line 42

def error!(description = "")
  @otel_span.status = ::OpenTelemetry::Trace::Status.error(description)
end

#record_exception(exception) ⇒ void

This method returns an undefined value.

-- : (Exception) -> void

Parameters:

  • (Exception)


35
36
37
# File 'lib/riffer/tracing/otel.rb', line 35

def record_exception(exception)
  @otel_span.record_exception(exception)
end

#recording?Boolean

-- : () -> bool

Returns:

  • (Boolean)


48
49
50
# File 'lib/riffer/tracing/otel.rb', line 48

def recording?
  @otel_span.recording?
end

#set_attribute(key, value) ⇒ void

This method returns an undefined value.

-- : (String, untyped) -> void

Parameters:

  • (String)
  • (Object)


23
24
25
# File 'lib/riffer/tracing/otel.rb', line 23

def set_attribute(key, value)
  @otel_span.set_attribute(key, value)
end