Skip to content

[observability] Add estimated usage fallback#4

Open
mfittko wants to merge 3 commits intofeat/initial-openai-proxyfrom
feat/usage-fallback-follow-up
Open

[observability] Add estimated usage fallback#4
mfittko wants to merge 3 commits intofeat/initial-openai-proxyfrom
feat/usage-fallback-follow-up

Conversation

@mfittko
Copy link
Copy Markdown
Contributor

@mfittko mfittko commented Apr 3, 2026

Summary

Add estimated usage fallback when upstream responses omit explicit usage data.

Changes

  • add fallback token counting for streamed chat-completions responses without usage chunks
  • add fallback request token counting for responses-style error payloads without usage
  • add SSE response-content reconstruction needed for that estimation path
  • add the proxy and usage-event-builder coverage for the fallback behavior

Scope

PR #1 stays focused on usage reported directly by the upstream API.

This PR adds the separate heuristic path for cases where upstream usage is missing.

Testing

  • bundle exec rspec spec/usage_event_builder_spec.rb spec/proxy_spec.rb
  • make coverage
  • make lint

@mfittko mfittko force-pushed the feat/usage-fallback-follow-up branch from 6167295 to f346d92 Compare April 3, 2026 21:31
@mfittko mfittko force-pushed the feat/usage-fallback-follow-up branch from f346d92 to 55006c4 Compare April 3, 2026 21:34
@mfittko mfittko changed the title [observability] Restore estimated usage fallback [observability] Add estimated usage fallback Apr 3, 2026
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