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

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

Overview

The capture backend interface.

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/traces/backend/capture.rb', line 86

def active?
	!!Fiber.current.traces_backend_context
end

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

Trace the given block of code and log the execution.

Yields:

  • (span)


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

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

#trace_contextObject

Get a trace context from the current execution scope.



81
82
83
# File 'lib/traces/backend/capture.rb', line 81

def trace_context
	Fiber.current.traces_backend_context
end

#trace_context=(context) ⇒ Object

Assign a trace context to the current execution scope.



76
77
78
# File 'lib/traces/backend/capture.rb', line 76

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