Module: Apidepth::Event

Defined in:
lib/apidepth/event.rb

Constant Summary collapse

REQUIRED =

Fields that must be present on every event regardless of outcome. error_class is optional (only present on :timeout events).

%i[vendor endpoint method outcome duration_ms ts].freeze

Class Method Summary collapse

Class Method Details

.build(attrs) ⇒ Object

Build a validated, frozen event hash. Raises ArgumentError immediately if any required field is missing so the bug surfaces at call site.



25
26
27
28
29
30
31
32
33
34
# File 'lib/apidepth/event.rb', line 25

def self.build(attrs)
  missing = REQUIRED - attrs.keys
  unless missing.empty?
    raise ArgumentError,
          "Apidepth event is missing required fields: #{missing.join(', ')}. " \
          "This is a bug in the SDK — please open an issue."
  end

  attrs.freeze
end