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.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/insika/telemetry/recorder.rb', line 45

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")
end

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost.



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

def cost
  @cost
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