Class: LlmCostTracker::Event

Inherits:
Data
  • Object
show all
Defined in:
lib/llm_cost_tracker/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost

Returns:

  • (Object)

    the current value of cost



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def cost
  @cost
end

#event_idObject (readonly)

Returns the value of attribute event_id

Returns:

  • (Object)

    the current value of event_id



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def event_id
  @event_id
end

#latency_msObject (readonly)

Returns the value of attribute latency_ms

Returns:

  • (Object)

    the current value of latency_ms



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def latency_ms
  @latency_ms
end

#modelObject (readonly)

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def model
  @model
end

#pricing_modeObject (readonly)

Returns the value of attribute pricing_mode

Returns:

  • (Object)

    the current value of pricing_mode



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def pricing_mode
  @pricing_mode
end

#providerObject (readonly)

Returns the value of attribute provider

Returns:

  • (Object)

    the current value of provider



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def provider
  @provider
end

#provider_response_idObject (readonly)

Returns the value of attribute provider_response_id

Returns:

  • (Object)

    the current value of provider_response_id



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def provider_response_id
  @provider_response_id
end

#streamObject (readonly)

Returns the value of attribute stream

Returns:

  • (Object)

    the current value of stream



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def stream
  @stream
end

#tagsObject (readonly)

Returns the value of attribute tags

Returns:

  • (Object)

    the current value of tags



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def tags
  @tags
end

#token_usageObject (readonly)

Returns the value of attribute token_usage

Returns:

  • (Object)

    the current value of token_usage



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def token_usage
  @token_usage
end

#tracked_atObject (readonly)

Returns the value of attribute tracked_at

Returns:

  • (Object)

    the current value of tracked_at



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def tracked_at
  @tracked_at
end

#usage_sourceObject (readonly)

Returns the value of attribute usage_source

Returns:

  • (Object)

    the current value of usage_source



4
5
6
# File 'lib/llm_cost_tracker/event.rb', line 4

def usage_source
  @usage_source
end

Instance Method Details

#to_hObject



22
23
24
25
26
27
28
# File 'lib/llm_cost_tracker/event.rb', line 22

def to_h
  super.merge(
    token_usage: token_usage.to_h,
    cost: cost&.to_h,
    tags: tags ? tags.to_h : {}
  )
end

#total_costObject



18
19
20
# File 'lib/llm_cost_tracker/event.rb', line 18

def total_cost
  cost&.fetch(:total_cost, nil)
end