Module: LlmCostTracker::Ingestion

Defined in:
lib/llm_cost_tracker/ingestion.rb,
lib/llm_cost_tracker/ingestion/pool.rb,
lib/llm_cost_tracker/ingestion/batch.rb,
lib/llm_cost_tracker/ingestion/inbox.rb,
lib/llm_cost_tracker/ingestion/worker.rb,
lib/llm_cost_tracker/ingestion/lease_claim.rb,
app/models/llm_cost_tracker/ingestion/lease.rb,
app/models/llm_cost_tracker/ingestion/inbox_entry.rb

Defined Under Namespace

Modules: Inbox, Pool, Worker Classes: Batch, InboxEntry, Lease, LeaseClaim

Constant Summary collapse

VERIFY_TAG =
"llm_cost_tracker_verify"

Class Method Summary collapse

Class Method Details

.async?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/llm_cost_tracker/ingestion.rb', line 39

def async?
  LlmCostTracker.configuration.ingestion == :async
end

.cache_rollups?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/llm_cost_tracker/ingestion.rb', line 43

def cache_rollups?
  LlmCostTracker.configuration.cache_rollups
end

.ensure_current_schema!Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/llm_cost_tracker/ingestion.rb', line 25

def ensure_current_schema!
  unless LlmCostTracker::Call.table_exists?
    raise Error, "llm_cost_tracker_calls table is missing; run install generator and migrate"
  end

  guards_for_current_config.each do |schema_module, table_name|
    errors = schema_module.current_schema_errors
    next if errors.empty?

    raise Error,
          "#{table_name} table is not on the current schema: #{errors.join('; ')}; see docs/upgrading.md"
  end
end

.guards_for_current_configObject



47
48
49
50
51
52
# File 'lib/llm_cost_tracker/ingestion.rb', line 47

def guards_for_current_config
  guards = Ledger::Schema::CORE_SCHEMAS.dup
  guards << Ledger::Schema::CACHE_ROLLUPS_SCHEMA if cache_rollups?
  guards += Ledger::Schema::ASYNC_SCHEMAS if async?
  guards
end

.table_name_prefixObject



21
22
23
# File 'lib/llm_cost_tracker/ingestion.rb', line 21

def table_name_prefix
  "llm_cost_tracker_ingestion_"
end

.verifyObject



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

def verify
  unless LlmCostTracker::Call.table_exists?
    return [
      LlmCostTracker::Check.new(
        :error,
        "active_record",
        "llm_cost_tracker_calls table is missing; run install generator and migrate"
      )
    ]
  end

  [capture_check]
rescue StandardError => e
  [LlmCostTracker::Check.new(:error, "active_record", "#{e.class}: #{e.message}")]
end