Class: Rage::Telemetry::Handler
- Inherits:
-
Object
- Object
- Rage::Telemetry::Handler
- Defined in:
- lib/rage/telemetry/handler.rb
Overview
The class allows developers to define telemetry handlers that observe and react to specific span executions.
Handlers are defined by subclassing Rage::Telemetry::Handler and using the handle class method to specify which spans to observe and which methods to invoke when those spans are executed.
See Spans for a list of available spans and arguments passed to the handler methods.
Each handler method is expected to call yield to pass control to the next handler in the stack or the frameworkâs core logic. The call to yield returns an instance of SpanResult which contains information about the span execution.
Class Method Summary collapse
-
.handle(*span_ids, with:, except: nil) ⇒ Object
Defines which spans the handler will observe and which method to invoke for those spans.
Class Method Details
.handle(*span_ids, with:, except: nil) ⇒ Object
Defines which spans the handler will observe and which method to invoke for those spans.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rage/telemetry/handler.rb', line 64 def handle(*span_ids, with:, except: nil) resolved_span_ids = resolve_span_ids(span_ids) if except resolved_span_ids -= resolve_span_ids(Array(except)) end if @handlers_map.nil? @handlers_map = {} elsif @handlers_map.frozen? @handlers_map = @handlers_map.transform_values(&:dup) end resolved_span_ids.each do |span_id| @handlers_map[span_id] ||= Set.new @handlers_map[span_id] << with end end |