Class: Insika::Telemetry::Recorder::Instruments
- Inherits:
-
Object
- Object
- Insika::Telemetry::Recorder::Instruments
- Defined in:
- lib/insika/telemetry/recorder.rb
Overview
The metric instruments of the convention, created once per Recorder. Names and units are part of the documented contract (docs/OBSERVABILITY.md) — renaming one breaks every dashboard built on it.
Instance Attribute Summary collapse
-
#cache_hit_rate ⇒ Object
readonly
Returns the value of attribute cache_hit_rate.
-
#context_compacted ⇒ Object
readonly
Returns the value of attribute context_compacted.
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#loop_intervened ⇒ Object
readonly
Returns the value of attribute loop_intervened.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
-
#tool_calls ⇒ Object
readonly
Returns the value of attribute tool_calls.
-
#tool_duration ⇒ Object
readonly
Returns the value of attribute tool_duration.
-
#turn_duration ⇒ Object
readonly
Returns the value of attribute turn_duration.
-
#turns ⇒ Object
readonly
Returns the value of attribute turns.
Instance Method Summary collapse
-
#initialize(meter) ⇒ Instruments
constructor
A new instance of Instruments.
Constructor Details
#initialize(meter) ⇒ Instruments
Returns a new instance of Instruments.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/insika/telemetry/recorder.rb', line 46 def initialize(meter) @turns = meter.create_counter("insika.turns", unit: "{turn}", description: "Turns completed, by outcome") @turn_duration = meter.create_histogram("insika.turn.duration", unit: "s", description: "Wall time of a turn") @tokens = meter.create_counter("insika.tokens", unit: "{token}", description: "Tokens consumed, by type") @cost = meter.create_counter("insika.cost", unit: "{USD}", description: "Estimated turn cost in USD") @tool_calls = meter.create_counter("insika.tool.calls", unit: "{call}", description: "Tool invocations") @tool_duration = meter.create_histogram("insika.tool.duration", unit: "s", description: "Wall time of a tool call") @cache_hit_rate = meter.create_histogram("insika.cache.hit_rate", unit: "%", description: "Prompt-cache hit rate of a turn (cached / billed prompt tokens)") @loop_intervened = meter.create_counter("insika.tool.loop_intervened", unit: "{intervention}", description: "Loop-detector warnings delivered to the model") @context_compacted = meter.create_counter("insika.context.compacted", unit: "{compaction}", description: "In-session compactions persisted (RFC-0044)") end |
Instance Attribute Details
#cache_hit_rate ⇒ Object (readonly)
Returns the value of attribute cache_hit_rate.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def cache_hit_rate @cache_hit_rate end |
#context_compacted ⇒ Object (readonly)
Returns the value of attribute context_compacted.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def context_compacted @context_compacted end |
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def cost @cost end |
#loop_intervened ⇒ Object (readonly)
Returns the value of attribute loop_intervened.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def loop_intervened @loop_intervened end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def tokens @tokens end |
#tool_calls ⇒ Object (readonly)
Returns the value of attribute tool_calls.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def tool_calls @tool_calls end |
#tool_duration ⇒ Object (readonly)
Returns the value of attribute tool_duration.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def tool_duration @tool_duration end |
#turn_duration ⇒ Object (readonly)
Returns the value of attribute turn_duration.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def turn_duration @turn_duration end |
#turns ⇒ Object (readonly)
Returns the value of attribute turns.
43 44 45 |
# File 'lib/insika/telemetry/recorder.rb', line 43 def turns @turns end |