Module: Traces::Backend::Capture::Interface

Defined in:
lib/traces/backend/capture.rb

Instance Method Summary collapse

Instance Method Details

#trace(name, resource: self, attributes: {}) {|span| ... } ⇒ Object

Trace the given block of code and log the execution.

Yields:

  • (span)


63
64
65
66
67
68
69
70
71
# File 'lib/traces/backend/capture.rb', line 63

def trace(name, resource: self, attributes: {}, &block)
  context = Context.nested(Fiber.current.traces_backend_context)
  Fiber.current.traces_backend_context = context
  
  span = Span.new(context, self, name, resource, attributes)
  Capture.spans << span
  
  yield span
end

#trace_contextObject

Get a trace context from the current execution scope.



79
80
81
# File 'lib/traces/backend/capture.rb', line 79

def trace_context
  Fiber.current.traces_backend_context
end

#trace_context=(context) ⇒ Object

Assign a trace context to the current execution scope.



74
75
76
# File 'lib/traces/backend/capture.rb', line 74

def trace_context= context
  Fiber.current.traces_backend_context = context
end