Skip to content

Metric gen_ai_client_estimated_cost_total uses obscure format #1947

@fedinskiy

Description

@fedinskiy

Quarkus langchain4j generates some gen_ai usage metrics, including gen_ai_client_estimated_cost_total, which I would expect to contain estimated cost of calls in dollars (or cents). Unfortunately, it uses floating-point number to store/represent the value, which is known anti pattern[1] generally and makes output unclear in our particular use case.

Example (obtained from sample/chatbot module after adding quarkus-micrometer and quarkus-micrometer-registry-prometheusextensions):

gen_ai_client_estimated_cost_total{ai_service_class_name="io.quarkiverse.langchain4j.sample.chatbot.Bot",ai_service_method_name="chat",currency="USD",gen_ai_operation_name="completion",gen_ai_request_model="gpt-4o-mini",gen_ai_response_model="gpt-4o-mini-2024-07-18",gen_ai_token_type="output",} 8.67E-5

[1] eg https://dzone.com/articles/never-use-float-and-double-for-monetary-calculatio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions