Class: Insika::Telemetry::Recorder::Instruments

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_rateObject (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_compactedObject (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

#costObject (readonly)

Returns the value of attribute cost.



43
44
45
# File 'lib/insika/telemetry/recorder.rb', line 43

def cost
  @cost
end

#loop_intervenedObject (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

#tokensObject (readonly)

Returns the value of attribute tokens.



43
44
45
# File 'lib/insika/telemetry/recorder.rb', line 43

def tokens
  @tokens
end

#tool_callsObject (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_durationObject (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_durationObject (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

#turnsObject (readonly)

Returns the value of attribute turns.



43
44
45
# File 'lib/insika/telemetry/recorder.rb', line 43

def turns
  @turns
end