Module: Traces::Backend::Console::Interface

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

Instance Method Summary collapse

Instance Method Details

#trace(name, resource: self, 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, resource: self, attributes: {}, &block)
	context = Context.nested(Fiber.current.traces_backend_context)
	Fiber.current.traces_backend_context = context
	
	::Console.logger.info(resource, name, attributes)
	
	if block.arity.zero?
		yield
	else
		yield Span.new(context, self, name)
	end
end

#trace_contextObject

Get a trace context from the current execution scope.



77
78
79
# File 'lib/traces/backend/console.rb', line 77

def trace_context
	Fiber.current.traces_backend_context
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