Module: Traces::Backend::Console::Interface
- Defined in:
- lib/traces/backend/console.rb
Instance Method Summary collapse
-
#trace(name, attributes: {}, &block) ⇒ Object
Trace the given block of code and log the execution.
-
#trace_context(span = nil) ⇒ Object
Get a trace context from the current execution scope.
-
#trace_context=(context) ⇒ Object
Assign a trace context to the current execution scope.
Instance Method Details
#trace(name, attributes: {}, &block) ⇒ Object
Trace the given block of code and log the execution.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/traces/backend/console.rb', line 58 def trace(name, attributes: {}, &block) context = Context.nested(Fiber.current.traces_backend_context) Fiber.current.traces_backend_context = context ::Console.logger.info(self, name, attributes) if block.arity.zero? yield else yield Span.new(context, self, name) end end |
#trace_context(span = nil) ⇒ Object
Get a trace context from the current execution scope.
78 79 80 81 82 83 84 |
# File 'lib/traces/backend/console.rb', line 78 def trace_context(span = nil) if span span.context else Fiber.current.traces_backend_context end end |
#trace_context=(context) ⇒ Object
Assign a trace context to the current execution scope.
72 73 74 |
# File 'lib/traces/backend/console.rb', line 72 def trace_context= context Fiber.current.traces_backend_context = context end |