Class: FiberAudit::Runtime::SessionSummary
- Inherits:
-
Data
- Object
- Data
- FiberAudit::Runtime::SessionSummary
- Defined in:
- lib/fiber_audit/runtime/session.rb
Instance Attribute Summary collapse
-
#ended_at ⇒ Object
readonly
Returns the value of attribute ended_at.
-
#ended_monotonic_ns ⇒ Object
readonly
Returns the value of attribute ended_monotonic_ns.
-
#events_emitted ⇒ Object
readonly
Returns the value of attribute events_emitted.
-
#events_observed ⇒ Object
readonly
Returns the value of attribute events_observed.
-
#internal_errors ⇒ Object
readonly
Returns the value of attribute internal_errors.
-
#oversize ⇒ Object
readonly
Returns the value of attribute oversize.
-
#rate_limited ⇒ Object
readonly
Returns the value of attribute rate_limited.
-
#sampled_out ⇒ Object
readonly
Returns the value of attribute sampled_out.
-
#session_byte_limited ⇒ Object
readonly
Returns the value of attribute session_byte_limited.
-
#session_event_limited ⇒ Object
readonly
Returns the value of attribute session_event_limited.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(ended_at:, ended_monotonic_ns:, status:, **counters) ⇒ SessionSummary
constructor
A new instance of SessionSummary.
Constructor Details
#initialize(ended_at:, ended_monotonic_ns:, status:, **counters) ⇒ SessionSummary
Returns a new instance of SessionSummary.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/fiber_audit/runtime/session.rb', line 65 def initialize(ended_at:, ended_monotonic_ns:, status:, **counters) unknown = counters.keys - SessionSummary::COUNTERS missing = SessionSummary::COUNTERS - counters.keys raise RuntimeContractError, "unknown session summary field: #{unknown.first}" unless unknown.empty? raise RuntimeContractError, "missing session summary field: #{missing.first}" unless missing.empty? normalized_status = status.is_a?(String) || status.is_a?(Symbol) ? status.to_sym : nil unless SessionSummary::STATUSES.include?(normalized_status) raise RuntimeContractError, "status must be one of: #{SessionSummary::STATUSES.join(', ')}" end normalized_counters = counters.to_h do |name, value| [name, Validation.integer(value, name.to_s)] end accounted = %i[ events_emitted sampled_out rate_limited session_event_limited session_byte_limited oversize ].sum { |name| normalized_counters.fetch(name) } if accounted > normalized_counters.fetch(:events_observed) raise RuntimeContractError, 'event accounting exceeds events_observed' end super( ended_at: Validation.utc_time(ended_at, 'ended_at'), ended_monotonic_ns: Validation.integer(ended_monotonic_ns, 'ended_monotonic_ns'), status: normalized_status, **normalized_counters ) end |
Instance Attribute Details
#ended_at ⇒ Object (readonly)
Returns the value of attribute ended_at
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def ended_at @ended_at end |
#ended_monotonic_ns ⇒ Object (readonly)
Returns the value of attribute ended_monotonic_ns
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def ended_monotonic_ns @ended_monotonic_ns end |
#events_emitted ⇒ Object (readonly)
Returns the value of attribute events_emitted
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def events_emitted @events_emitted end |
#events_observed ⇒ Object (readonly)
Returns the value of attribute events_observed
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def events_observed @events_observed end |
#internal_errors ⇒ Object (readonly)
Returns the value of attribute internal_errors
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def internal_errors @internal_errors end |
#oversize ⇒ Object (readonly)
Returns the value of attribute oversize
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def oversize @oversize end |
#rate_limited ⇒ Object (readonly)
Returns the value of attribute rate_limited
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def rate_limited @rate_limited end |
#sampled_out ⇒ Object (readonly)
Returns the value of attribute sampled_out
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def sampled_out @sampled_out end |
#session_byte_limited ⇒ Object (readonly)
Returns the value of attribute session_byte_limited
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def session_byte_limited @session_byte_limited end |
#session_event_limited ⇒ Object (readonly)
Returns the value of attribute session_event_limited
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def session_event_limited @session_event_limited end |
#status ⇒ Object (readonly)
Returns the value of attribute status
52 53 54 |
# File 'lib/fiber_audit/runtime/session.rb', line 52 def status @status end |