class Rage::Telemetry::Handler

def handle(*span_ids, with:, except: nil)

Other tags:
    Example: Observe all spans except specific ones -
    Example: Observe multiple spans with wildcards -
    Example: Observe a specific span -

Raises:
  • (ArgumentError) - if any specified span ID is unknown or if no spans match a wildcard ID

Parameters:
  • except (String, Array, nil) -- optional list of span IDs to exclude from observation; supports wildcards (`*`) to match multiple spans
  • with (Symbol) -- the method name to invoke when the specified spans are executed
  • span_ids (Array) -- one or more span IDs to observe; supports wildcards (`*`) to match multiple spans
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