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

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

Instance Method Summary collapse

Instance Method Details

#trace(name, resource: nil, attributes: {}, &block) ⇒ Object

Trace the given block of code and log the execution.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/traces/backend/console.rb', line 40

def trace(name, resource: nil, attributes: {}, &block)
	context = Context.nested(Fiber.current.traces_backend_context)
	Fiber.current.traces_backend_context = context
	
	::Console.logger.info(resource || self, name, attributes)
	
	if block.arity.zero?
		yield
	else
		yield Span.new(context, name)
	end
end

#trace_contextObject

Get a trace context from the current execution scope.



59
60
61
# File 'lib/traces/backend/console.rb', line 59

def trace_context
	Fiber.current.traces_backend_context
end

#trace_context=(context) ⇒ Object

Assign a trace context to the current execution scope.



54
55
56
# File 'lib/traces/backend/console.rb', line 54

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