Class: Tep::Proxy::StreamStats

Inherits:
Object
  • Object
show all
Defined in:
lib/tep/proxy.rb

Overview

Per-stream telemetry, carried across every on_stream_chunk call and into on_stream_end. The framework maintains byte_count / chunk_count (input bytes dispatched, chunk/event count) and errored (set when the upstream stalls past the io_wait timeout or closes mid-frame). Accumulate custom counters (tokens, etc.) in the ‘meta_bag` bag – a typed object rather than the doc’s stats hash because spinel hashes are single-value-typed (same reason Tep::Llm::StreamState is a class).

Field names are deliberately collision-free: spinel unifies field/accessor types by NAME file-wide. ‘bytes` collides with String#bytes (int-array) and `data` collides with WebSocket Event#data (String) – either would mis-type these fields. Hence byte_count / chunk_count / meta_bag. See [[spinel-widening-dispatch]].

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStreamStats

Returns a new instance of StreamStats.



769
770
771
772
773
774
# File 'lib/tep/proxy.rb', line 769

def initialize
  @byte_count  = 0
  @chunk_count = 0
  @errored     = false
  @meta_bag    = Tep.str_hash
end

Instance Attribute Details

#byte_countObject

Returns the value of attribute byte_count.



767
768
769
# File 'lib/tep/proxy.rb', line 767

def byte_count
  @byte_count
end

#chunk_countObject

Returns the value of attribute chunk_count.



767
768
769
# File 'lib/tep/proxy.rb', line 767

def chunk_count
  @chunk_count
end

#erroredObject

Returns the value of attribute errored.



767
768
769
# File 'lib/tep/proxy.rb', line 767

def errored
  @errored
end

#meta_bagObject

Returns the value of attribute meta_bag.



767
768
769
# File 'lib/tep/proxy.rb', line 767

def meta_bag
  @meta_bag
end