Module: BetterAuth::Instrumentation

Defined in:
lib/better_auth/instrumentation.rb

Defined Under Namespace

Modules: SpanStatusCode Classes: NoopSpan, NoopTracer, Trace

Class Method Summary collapse

Class Method Details

.traceObject



60
61
62
# File 'lib/better_auth/instrumentation.rb', line 60

def trace
  @trace ||= Trace.new
end

.with_span(name, attributes: {}, &block) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/better_auth/instrumentation.rb', line 64

def with_span(name, attributes: {}, &block)
  trace.get_tracer("better-auth").start_active_span(name, attributes: attributes) do |span|
    block.call(span)
  rescue => error
    span.record_exception(error)
    span.set_status(SpanStatusCode::ERROR)
    raise
  end
end