Skip to content

fix(ai): Use provider-specific model pricing - #6558

Open
akasakariko wants to merge 1 commit into
getsentry:masterfrom
akasakariko:fix/ai-provider-model-pricing
Open

akasakariko wants to merge 1 commit into
getsentry:masterfrom
akasakariko:fix/ai-provider-model-pricing

Conversation

@akasakariko

@akasakariko akasakariko commented Oct 24, 2026 •

Copy link
Copy Markdown

Summary

  • Read optional provider-specific AI model metadata and select it using the span provider in both EAP and legacy normalization
  • Map OpenTelemetry provider names to catalog IDs and keep prices and context sizes within the selected provider
  • Retain model-only lookup for old configurations and spans without a provider
  • Prefer exact full model IDs before normalized aliases and select the longest matching glob deterministically
  • Do not fall back to another provider when the supplied provider or model has no matching metadata

Reproduction

  • Reproduced on upstream commit 08526e6 before implementing the fix
  • A Cloudflare Workers AI span with 55132 input tokens used the OpenRouter rate of $42 per billion tokens instead of the Cloudflare rate of $240
  • The regression failed before the fix and passes after selecting the provider table

Verification

  • All workspace Rust tests and doc tests passed with make test-rust-all
  • The normalization crate passed 887 unit tests and 7 doc tests
  • make check passed including documentation, formatting, Clippy, flake8, and mypy
  • All 86 Python binding tests passed
  • cargo build --all-features passed
  • The initial make test run timed out during documentation tests, then the Rust suite and Python binding suite passed separately
  • AI integration tests were attempted but could not pass because the local Kafka broker refused connections on port 9092, the full integration suite remains unverified
  • Added coverage for provider separation, aliases, exact snapshots, context utilization, unknown providers and models, old configurations, provider-only configurations, and unsupported versions

Compatibility and security review

  • The optional provider tables remain within metadata version 1 and old configurations retain the existing fallback behavior
  • Complete resolution requires the companion metadata producer change in fix(ai): Preserve provider-specific model metadata sentry#128733
  • Reviewed untrusted provider and model handling, missing lookups return no metadata rather than panicking
  • No new dependencies, network requests, logging of span values, or authorization changes
  • Provider selection uses a bounded table lookup followed by the existing model matching mechanism

AI assistance

  • Substantial implementation and test work was generated with an AI coding assistant and validated through the checks above

Refs getsentry/sentry#128011

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

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.

1 participant