Skip to content

feat(telemetry): add USD currency attribute alongside tool cost - #1493

Open
DevChiniwala wants to merge 1 commit into
AgentOps-AI:mainfrom
DevChiniwala:fix/tool-cost-currency-attribute
Open

DevChiniwala wants to merge 1 commit into
AgentOps-AI:mainfrom
DevChiniwala:fix/tool-cost-currency-attribute

Conversation

@DevChiniwala

Copy link
Copy Markdown

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:

  • Cross-deployment cost comparison
  • Non-USD billing regions
  • Downstream cost dashboards and reconciliation

Changes

Add LLM_USAGE_TOOL_COST_CURRENCY attribute set to "USD" alongside every tool cost recording:

  1. span_attributes.py: Define new LLM_USAGE_TOOL_COST_CURRENCY = "gen_ai.usage.cost.currency" constant
  2. factory.py: Set currency in 3 decorator cost paths (sync/async/generator)
  3. ag2/instrumentor.py: Set currency in AG2 instrumentation cost path

Standard alignment

Follows the OpenTelemetry GenAI semantic conventions proposal #443 which defines:

  • gen_ai.usage.cost.amount — the monetary cost
  • gen_ai.usage.cost.currency — ISO 4217 code (conditionally required when amount is set)

The attribute is set to "USD" because all cost values come from tokencost price tables which use USD.

🤖 Generated with Claude Code

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>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool costs are recorded with no currency — attach a unit to gen_ai.usage.total_cost

2 participants