Class: OpenTelemetry::Instrumentation::Rage::LogContext

Inherits:
Object
  • Object
show all
Defined in:
lib/opentelemetry/instrumentation/rage/log_context.rb

Overview

The class provides a custom log context to enrich Rage logs with the current OpenTelemetry trace and span IDs.

Class Method Summary collapse

Class Method Details

.callObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/opentelemetry/instrumentation/rage/log_context.rb', line 14

def call
  current_span = OpenTelemetry::Trace.current_span
  return unless current_span.recording?

  {
    trace_id: current_span.context.hex_trace_id,
    span_id: current_span.context.hex_span_id
  }
rescue => e
  OpenTelemetry.handle_error(exception: e)
  nil
end