11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/llm_cost_tracker/doctor/ingestion_check.rb', line 11
def call
return unless table_exists?("llm_api_calls")
missing = missing_parts
if missing.empty?
quarantined = quarantined_count
if quarantined.positive?
return Check.new(:warn, "durable ingestion", "#{quarantined} inbox events quarantined after retries")
end
pending = pending_snapshot
pending_count = pending.try(:pending_count).to_i
oldest_pending_at = pending.try(:oldest_created_at)&.to_time&.utc
pending_age = oldest_pending_at && (Time.now.utc - oldest_pending_at)
if pending_count.positive? && pending_age && pending_age >= PENDING_AGE_WARNING_SECONDS
return Check.new(
:warn,
"durable ingestion",
"#{pending_count} inbox events pending; oldest pending age #{pending_age.round}s"
)
end
return Check.new(:ok, "durable ingestion", "inbox and ingestor lease tables available")
end
Check.new(
:error,
"durable ingestion",
"missing #{missing.join(', ')}; run bin/rails generate llm_cost_tracker:add_ingestion && bin/rails db:migrate"
)
end
|