Record Class CostTracker.CostStatistics

java.lang.Object
java.lang.Record
com.tnsai.llm.cost.CostTracker.CostStatistics
Enclosing interface:
CostTracker

public static record CostTracker.CostStatistics(int recordCount, long totalInputTokens, long totalOutputTokens, long totalCachedTokens, BigDecimal totalInputCost, BigDecimal totalOutputCost, BigDecimal totalCost, BigDecimal averageCostPerRequest, long averageLatencyMs, Optional<UsageRecord> mostExpensiveRequest, Map<String,BigDecimal> costByModel, Map<String,BigDecimal> costByProvider, Duration timeSpan) extends Record
Aggregated cost statistics.
  • Constructor Details

    • CostStatistics

      public CostStatistics(int recordCount, long totalInputTokens, long totalOutputTokens, long totalCachedTokens, BigDecimal totalInputCost, BigDecimal totalOutputCost, BigDecimal totalCost, BigDecimal averageCostPerRequest, long averageLatencyMs, Optional<UsageRecord> mostExpensiveRequest, Map<String,BigDecimal> costByModel, Map<String,BigDecimal> costByProvider, Duration timeSpan)
      Creates an instance of a CostStatistics record class.
      Parameters:
      recordCount - the value for the recordCount record component
      totalInputTokens - the value for the totalInputTokens record component
      totalOutputTokens - the value for the totalOutputTokens record component
      totalCachedTokens - the value for the totalCachedTokens record component
      totalInputCost - the value for the totalInputCost record component
      totalOutputCost - the value for the totalOutputCost record component
      totalCost - the value for the totalCost record component
      averageCostPerRequest - the value for the averageCostPerRequest record component
      averageLatencyMs - the value for the averageLatencyMs record component
      mostExpensiveRequest - the value for the mostExpensiveRequest record component
      costByModel - the value for the costByModel record component
      costByProvider - the value for the costByProvider record component
      timeSpan - the value for the timeSpan record component
  • Method Details

    • empty

      public static CostTracker.CostStatistics empty()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • recordCount

      public int recordCount()
      Returns the value of the recordCount record component.
      Returns:
      the value of the recordCount record component
    • totalInputTokens

      public long totalInputTokens()
      Returns the value of the totalInputTokens record component.
      Returns:
      the value of the totalInputTokens record component
    • totalOutputTokens

      public long totalOutputTokens()
      Returns the value of the totalOutputTokens record component.
      Returns:
      the value of the totalOutputTokens record component
    • totalCachedTokens

      public long totalCachedTokens()
      Returns the value of the totalCachedTokens record component.
      Returns:
      the value of the totalCachedTokens record component
    • totalInputCost

      public BigDecimal totalInputCost()
      Returns the value of the totalInputCost record component.
      Returns:
      the value of the totalInputCost record component
    • totalOutputCost

      public BigDecimal totalOutputCost()
      Returns the value of the totalOutputCost record component.
      Returns:
      the value of the totalOutputCost record component
    • totalCost

      public BigDecimal totalCost()
      Returns the value of the totalCost record component.
      Returns:
      the value of the totalCost record component
    • averageCostPerRequest

      public BigDecimal averageCostPerRequest()
      Returns the value of the averageCostPerRequest record component.
      Returns:
      the value of the averageCostPerRequest record component
    • averageLatencyMs

      public long averageLatencyMs()
      Returns the value of the averageLatencyMs record component.
      Returns:
      the value of the averageLatencyMs record component
    • mostExpensiveRequest

      public Optional<UsageRecord> mostExpensiveRequest()
      Returns the value of the mostExpensiveRequest record component.
      Returns:
      the value of the mostExpensiveRequest record component
    • costByModel

      public Map<String,BigDecimal> costByModel()
      Returns the value of the costByModel record component.
      Returns:
      the value of the costByModel record component
    • costByProvider

      public Map<String,BigDecimal> costByProvider()
      Returns the value of the costByProvider record component.
      Returns:
      the value of the costByProvider record component
    • timeSpan

      public Duration timeSpan()
      Returns the value of the timeSpan record component.
      Returns:
      the value of the timeSpan record component