Class: LlmCostTracker::Doctor

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_cost_tracker/doctor.rb,
lib/llm_cost_tracker/doctor/check.rb,
lib/llm_cost_tracker/doctor/probe.rb,
lib/llm_cost_tracker/doctor/price_check.rb,
lib/llm_cost_tracker/doctor/schema_check.rb,
lib/llm_cost_tracker/doctor/ingestion_check.rb,
lib/llm_cost_tracker/doctor/capture_verifier.rb,
lib/llm_cost_tracker/doctor/cost_drift_check.rb,
lib/llm_cost_tracker/doctor/legacy_audit_check.rb,
lib/llm_cost_tracker/doctor/legacy_billing_status_check.rb,
lib/llm_cost_tracker/doctor/invoice_reconciliation_check.rb,
lib/llm_cost_tracker/doctor/pricing_snapshot_drift_check.rb

Defined Under Namespace

Modules: Probe Classes: CaptureVerifier, Check, CostDriftCheck, IngestionCheck, InvoiceReconciliationCheck, LegacyAuditCheck, LegacyBillingStatusCheck, PriceCheck, PricingSnapshotDriftCheck, SchemaCheck

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.callObject



49
50
51
# File 'lib/llm_cost_tracker/doctor.rb', line 49

def call
  new.checks
end

.healthy?(checks = call) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/llm_cost_tracker/doctor.rb', line 69

def healthy?(checks = call)
  checks.none? { |check| check.status == :error }
end

.report(checks = call, color: $stdout.tty?) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/llm_cost_tracker/doctor.rb', line 53

def report(checks = call, color: $stdout.tty?)
  name_width = checks.map { |c| c.name.length }.max.to_i

  lines = [bold("LLM Cost Tracker doctor", color), ""]
  each_section(checks) do |section, members|
    lines << bold(section, color)
    members.each do |check|
      status = paint_status("[#{STATUS_GLYPHS.fetch(check.status, check.status)}]", check.status, color)
      lines << "  #{status} #{"#{check.name}:".ljust(name_width + 1)} #{check.message}"
    end
    lines << ""
  end
  lines.pop if lines.last == ""
  lines.join("\n")
end

Instance Method Details

#checksObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/llm_cost_tracker/doctor.rb', line 97

def checks
  [
    configuration_check,
    capture_check,
    *LlmCostTracker::Integrations.checks,
    active_record_check,
    table_check,
    column_check,
    *dependent_core_schema_checks,
    *reconciliation_schema_checks,
    CostDriftCheck.new.call,
    PricingSnapshotDriftCheck.new.call,
    *reconciliation_invoice_check,
    LegacyBillingStatusCheck.new.call,
    LegacyAuditCheck.new.call,
    call_rollups_check,
    IngestionCheck.new.call,
    PriceCheck.new.call,
    calls_check
  ].compact
end