Adds OpenAIUsageDebuggingPlugin. Closes #1413#1427
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new OpenAIUsageDebuggingPlugin that tracks and logs OpenAI API usage metrics to a CSV file, while refactoring shared utility code from OpenAITelemetryPlugin into reusable components.
- Extracts
TryGetOpenAIRequest,IsStreamingResponse, andGetBodyFromStreamingResponseto shared utilities - Implements
OpenAIUsageDebuggingPluginto record token usage, rate limits, and error details to CSV - Adds
PromptTokenDetailsmodel to capture cached token metrics
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| DevProxy.Plugins/Utils/HttpUtils.cs | New utility class containing shared HTTP response handling methods for streaming responses |
| DevProxy.Plugins/Inspection/OpenAIUsageDebuggingPlugin.cs | New plugin that logs OpenAI API usage metrics (tokens, rate limits, errors) to CSV files |
| DevProxy.Plugins/Inspection/OpenAITelemetryPlugin.cs | Refactored to use shared utilities from HttpUtils and OpenAIRequest |
| DevProxy.Abstractions/LanguageModel/OpenAIModels.cs | Added TryGetOpenAIRequest static method and PromptTokenDetails class for cached token tracking |
garrytrinder
previously approved these changes
Oct 28, 2025
- Use DateTime.TryParse for the response Date header and fall back to DateTime.Now when missing/invalid. - Extract TryParseHeaderAsLong helper to centralize/parsing of numeric headers. - Replace inline parsing for x-ratelimit-remaining-tokens and x-ratelimit-remaining-requests with the new helper. - Add missing using for Titanium.Web.Proxy.Http.
garrytrinder
approved these changes
Oct 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds OpenAIUsageDebuggingPlugin. Closes #1413