Skip to content

feat(lens): estimate OTEL costs with shared Rust pricing - #45111

Closed
tin-berri wants to merge 1 commit into
mainfrom
litellm_lens_otel_cost
Closed

tin-berri wants to merge 1 commit into
mainfrom
litellm_lens_otel_cost

Conversation

@tin-berri

@tin-berri tin-berri commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

  • Direct calls show tokens but leave Lens cost empty
  • Estimate supported costs using shared Rust pricing
  • Keep incomplete search, tool and routing charges unknown

Intentional product change: eligible direct calls display labeled estimates; unsupported charges remain unknown

User Flow

Before: a direct cached call has no visible cost

  1. Send a recorded Moyai trace to POST /v1/traces
  2. Open /lens and select the model call
  3. See 3,010 input tokens and an empty cost

After: the same trace has a labeled estimate

  1. Send the recorded Moyai trace to POST /v1/traces
  2. Open /lens and select the model call
  3. See Estimated $0.0013 and its pricing source

Relevant issues

Changes

  • Select rates for recorded cache durations, reasoning, service tiers and call times
  • Preserve GenAI/OpenInference evidence across list, detail and batch queries
  • Set catalog supports_token_only_pricing for hosted search and routing entries
  • Resolve deployment paths and aliases to routing requirements independently of served token rates
  • Preserve Python gateway/SDK billing and recorded spend precedence, including zero

Screenshots / Proof of Fix

Local gateway, rebuilt standalone Rust Lens and real ClickHouse; labeled synthetic controls and previously captured provider usage

Local demo and actual HTTP recording · Screenshot · Receipt

Before (d3e867a)

  1. Export azure_ai/model_router/my-deployment, served gpt-4o, with 100 input and 10 output tokens
  2. Read GET http://127.0.0.1:4691/v1/traces/000000000000000000000000000e7201
  3. The incomplete token-only total is $0.00035, omitting the routing fee

After (8dbee5f)

  1. Read the same persisted spans through http://127.0.0.1:4691/v1/traces
  2. Unsupported search, tool and routing charges remain unknown in list and detail
  3. Ordinary text, optional search, zero usage and client tools retain estimates
  4. Cached direct usage remains $0.00125758; recorded gateway spend remains $0.00002455 and $0

Validation

  • 1,370 focused Rust tests and 98 Python catalog/schema tests pass
  • 20 routed-identity regressions fail before the fix; all pass afterward
  • 26 live controls agree between list and detail
  • Three cache-price comparisons agree with existing Python billing
  • Rust Clippy, formatting, make check and the unchanged base catalog validator pass
  • Greptile 5/5 on 8dbee5ff; Bugbot found no issues; Veria passed

CI status

Pre-Submission checklist

  • Added meaningful tests for estimation and unknown costs
  • Focused tests and live verification pass
  • Current-head CI completed
  • Scope is Lens cost estimation
  • Current-head Greptile confidence is at least 4/5

Caveats

Medium

  • Estimates use bundled catalog prices, excluding private billing arrangements
  • Missing evidence or unsupported charges keep cost unknown

Low

  • Demo and recording are local artifacts
  • Other CI jobs are still running

@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review this direct OTEL pricing change, including gateway precedence, cache token accounting, duplicate estimates, and list/detail integration.

@codspeed

codspeed Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_lens_otel_cost (8dbee5f) with main (406514f)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High impact] The PR appears safe to merge, with both numbered findings addressed and no new blocking issue established

Summary

Lens adds labeled cost estimates for eligible direct calls using the shared Rust calculator and bundled model prices

  • Requested routing requirements remain attached when the served model differs
  • Unsupported charges and incomplete pricing evidence keep costs unknown
  • Recorded gateway spend, including zero, takes precedence
  • Named regression cases address both numbered findings

This review inspected code and tests; it did not run tests or live UI checks

Reviews (17) · Last reviewed commit: "feat(lens): estimate OTEL costs with sha..." · Reviewed by Greptile

Comment thread litellm-rust/crates/traces/src/resolve/estimates.rs Outdated
Comment thread litellm-rust/crates/traces/src/resolve/estimates.rs Outdated
Comment thread litellm-rust/crates/traces-cache/src/list.rs Outdated
Comment thread litellm/llms/base_llm/otel_cost.py Outdated
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread litellm/rust_bridge/trace/pricing.py Outdated
@veria-ai

veria-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@tin-berri
tin-berri force-pushed the litellm_lens_otel_cost branch from 4e916d2 to a8ca357 Compare October 7, 2026 18:38
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review a8ca357, which addresses all previous findings and adds offline pricing, consistent call grouping, and batch regressions

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review the current tip a8ca357 after the cost identity, batching, and offline pricing fixes

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread litellm/llms/base_llm/otel_cost.py Outdated
@tin-berri
tin-berri force-pushed the litellm_lens_otel_cost branch from a8ca357 to 8b441a4 Compare October 7, 2026 19:11
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review this final tip for tier-only pricing, strict selected-rate validation, and used cache-duration handling; all focused tests pass

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review the final tip with tier-only pricing, strict selected-rate validation, and cache-duration regressions passing locally

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread litellm/llms/base_llm/otel_cost.py Outdated
Comment thread litellm/llms/base_llm/otel_cost.py Outdated
Comment thread litellm/llms/base_llm/otel_cost.py Outdated
@tin-berri
tin-berri force-pushed the litellm_lens_otel_cost branch from 8b441a4 to 52ca0e2 Compare October 7, 2026 19:50
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review 52ca0e2 for GenAI compatibility, captured call time, and reasoning pricing. All three findings have regression coverage

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review 52ca0e2 for GenAI alias compatibility, stored timestamps, and reasoning pricing after the latest fixes and regression tests

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

@tin-berri
tin-berri force-pushed the litellm_lens_otel_cost branch from 52ca0e2 to 71d7e0a Compare October 8, 2026 03:09
@tin-berri
tin-berri requested a review from a team October 8, 2026 03:09
@tin-berri
tin-berri changed the base branch from main to litellm_lens_gateway_cost October 8, 2026 03:09
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review 71d7e0a against gateway base e3d70ec, focusing on native pricing ownership, catalog parity, and late gateway reconciliation.

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review 71d7e0a against gateway base e3d70ec, including standalone native estimation, bundled catalog assets, and authoritative gateway amounts

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread litellm-rust/crates/traces/src/pricing.rs
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review the missing search-charge fix, including canonical model admission, reported usage, ordinary text controls, and all four storage projections

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please recheck search cost admission and verify normal token estimates and recorded gateway spend precedence remain intact

Comment thread litellm-rust/crates/traces/src/pricing.rs Outdated

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai please review b64de19: catalog-owned pricing requirements replace model-name heuristics, preserving request context and declining incomplete tool charges

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review b64de19 for catalog pricing requirements, requested-model context, and unsupported tool usage; gateway billing execution remains unchanged

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread litellm-rust/crates/traces/src/pricing.rs Outdated
Comment thread litellm-rust/crates/traces/src/pricing.rs Outdated
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai please review d3e867a: pricing eligibility uses catalog supports_token_only_pricing metadata, compatible with base validation; request context and tool-usage regressions pass

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

Please review d3e867a, including catalog schema compatibility, requested-model pricing requirements, and tool usage; Python gateway billing remains unchanged

@cursor cursor Bot 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.

Stale Bugbot comment from a previous run.

Comment thread litellm-rust/crates/traces/tests/pricing.rs Outdated
@tin-berri

Copy link
Copy Markdown
Contributor Author

@greptileai Please review 8dbee5f, including catalog routing contexts and named regression cases; gateway billing remains unchanged and live controls pass

@tin-berri

Copy link
Copy Markdown
Contributor Author

bugbot run Please review 8dbee5f for routing context preservation, catalog admission, and regressions; gateway and SDK billing remain on Python

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8dbee5f. Configure here.

@tin-berri tin-berri closed this Oct 9, 2026

This branch is waiting to be deployed

1 waiting deployment
e2e-changed — 8dbee5ff Waiting Oct 8, 2026 by tin-berri via oauth #3928
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.

3 participants