Adds skipping non-matching URLs in OpenAITelemetryPlugin#1206
Adds skipping non-matching URLs in OpenAITelemetryPlugin#1206waldekmastykarz merged 1 commit intodotnet:mainfrom
Conversation
waldekmastykarz
commented
May 22, 2025
- Adds skipping non-matching URLs in OpenAITelemetryPlugin
- Changes the order of checks in OpenAIMockResponsePlugin so that checking for matching URLs is done first, which makes more sense.
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the URL matching logic to skip non-matching URLs in the telemetry and mock response plugins, and reorders the checks in the mock response plugin for improved logical consistency.
- Prioritize URL matching before checking if a response is already set in OpenAIMockResponsePlugin.
- Add URL matching logic to OpenAITelemetryPlugin for early bailout on non-matching requests.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dev-proxy-plugins/Mocks/OpenAIMockResponsePlugin.cs | Reorders the condition checks to perform URL matching before checking if the response has been set. |
| dev-proxy-plugins/Inspection/OpenAITelemetryPlugin.cs | Introduces URL matching logic to skip processing when the request URL does not match. |
ba6e2e9 to
867122e
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that both the telemetry and mock response plugins skip processing when a request’s URL doesn’t match the configured list, and it reorders checks in the mock plugin to first verify the URL before checking if a response is already set.
- Added a URL-match guard in
OpenAITelemetryPluginto early-return on non-matching URLs. - Reordered the
ifconditions inOpenAIMockResponsePluginso URL matching is checked beforeResponseState.HasBeenSet. - Updated skipped log messages to reflect the new check order.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dev-proxy-plugins/Mocks/OpenAIMockResponsePlugin.cs | Swapped the order of URL-match and response-set checks; updated corresponding log messages. |
| dev-proxy-plugins/Inspection/OpenAITelemetryPlugin.cs | Introduced an early-return guard for non-matching URLs in OnRequestAsync. |
Comments suppressed due to low confidence (2)
dev-proxy-plugins/Inspection/OpenAITelemetryPlugin.cs:139
- Consider adding unit tests that verify telemetry is correctly skipped when URLs do not match, and that it proceeds when they do.
if (UrlsToWatch is null || !e.HasRequestUrlMatch(UrlsToWatch))
dev-proxy-plugins/Mocks/OpenAIMockResponsePlugin.cs:38
- Replacing the original
e.ShouldExecute(UrlsToWatch)withe.HasRequestUrlMatch(...)may omit additional checks thatShouldExecuteperformed. Verify that no other execution conditions (e.g., HTTP method or headers) are lost, or consolidate into a single guard method.
!e.HasRequestUrlMatch(UrlsToWatch)