Repository navigation
feat(telemetry): add USD currency attribute alongside tool cost - #1493
Open
DevChiniwala wants to merge 1 commit into
Open
DevChiniwala wants to merge 1 commit into
DevChiniwala wants to merge 1 commit into
Conversation
Tool costs are recorded as gen_ai.usage.total_cost but have no currency unit. This prevents cost comparison across deployments or currency regions, and makes downstream cost dashboards ambiguous. Add LLM_USAGE_TOOL_COST_CURRENCY attribute set to "USD" alongside every cost recording, following the OpenTelemetry GenAI semantic conventions proposal for gen_ai.usage.cost.currency (PR AgentOps-AI#443). Changes: - span_attributes.py: add LLM_USAGE_TOOL_COST_CURRENCY constant - factory.py: set currency attribute in 3 decorator cost paths - ag2/instrumentor.py: set currency attribute in AG2 cost path Fixes AgentOps-AI#1462 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1462
Tool costs are recorded via
SpanAttributes.LLM_USAGE_TOOL_COST(gen_ai.usage.total_cost) but have no currency unit attached. This makes the monetary value ambiguous for:Changes
Add
LLM_USAGE_TOOL_COST_CURRENCYattribute set to"USD"alongside every tool cost recording:LLM_USAGE_TOOL_COST_CURRENCY = "gen_ai.usage.cost.currency"constantStandard alignment
Follows the OpenTelemetry GenAI semantic conventions proposal #443 which defines:
gen_ai.usage.cost.amount— the monetary costgen_ai.usage.cost.currency— ISO 4217 code (conditionally required when amount is set)The attribute is set to
"USD"because all cost values come fromtokencostprice tables which use USD.🤖 Generated with Claude Code