Module: Traces::Backend::Console::Interface
- Defined in:
- lib/traces/backend/console.rb
Overview
The console backend interface.
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#trace(name, attributes: {}, &block) ⇒ Object
Trace the given block of code and log the execution.
-
#trace_context ⇒ 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
#active? ⇒ Boolean
67 68 69 |
# File 'lib/traces/backend/console.rb', line 67 def active? !!Fiber.current.traces_backend_context end |
#trace(name, attributes: {}, &block) ⇒ Object
Trace the given block of code and log the execution.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/traces/backend/console.rb', line 43 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, name) end end |
#trace_context ⇒ Object
Get a trace context from the current execution scope.
62 63 64 |
# File 'lib/traces/backend/console.rb', line 62 def trace_context Fiber.current.traces_backend_context end |
#trace_context=(context) ⇒ Object
Assign a trace context to the current execution scope.
57 58 59 |
# File 'lib/traces/backend/console.rb', line 57 def trace_context= context Fiber.current.traces_backend_context = context end |