Skip to content

Set operation.cost attribute on anthropic spans when genai-prices is installed#1761

Merged
alexmojaki merged 8 commits intomainfrom
alex/anthropic-operation.cost
Mar 6, 2026
Merged

Set operation.cost attribute on anthropic spans when genai-prices is installed#1761
alexmojaki merged 8 commits intomainfrom
alex/anthropic-operation.cost

Conversation

@alexmojaki
Copy link
Copy Markdown
Collaborator

@alexmojaki alexmojaki commented Mar 6, 2026

Summary by cubic

Adds operation.cost to Anthropic spans when genai-prices is available, enabling per-request cost tracking. Tests are updated and skip on older Pydantic to avoid import issues.

  • New Features
    • Compute cost from usage and model via genai-prices and set operation.cost on spans.
    • Graceful fallback if genai-prices is not installed or errors.
    • Tests assert operation.cost (and schema) across sync, async, and tool messages, and skip when Pydantic < 2.5.

Written for commit b99b337. Summary will update on new commits.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 6, 2026

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: b99b337
Status: ✅  Deploy successful!
Preview URL: https://3ef6723f.logfire-docs.pages.dev
Branch Preview URL: https://alex-anthropic-operation-cos.logfire-docs.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@alexmojaki alexmojaki merged commit 50920ed into main Mar 6, 2026
16 checks passed
@alexmojaki alexmojaki deleted the alex/anthropic-operation.cost branch March 6, 2026 17:43
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.

1 participant