Minor Changes to the Fix added for Suppressing two Analytics Event per LLM proxy call and adding Integration and Unit Tests - #3006
Conversation
…call and adding integration and unit tests for it
📝 WalkthroughWalkthroughAnalytics now suppresses duplicate internal LLM provider loopback events, fails open when direct peer data is missing, and verifies single-event publication through unit and end-to-end tests. ChangesAnalytics deduplication
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant LlmProxy
participant LlmProvider
participant Analytics
Client->>LlmProxy: Send chat completions request
LlmProxy->>LlmProvider: Forward request
LlmProxy->>Analytics: Process proxy hop
LlmProvider->>Analytics: Process provider hop
Analytics->>Analytics: Detect internal loopback
Analytics-->>Client: Publish one proxy analytics event
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@gateway/gateway-runtime/policy-engine/internal/analytics/analytics_test.go`:
- Around line 469-503: Extend
TestProcess_DirectProviderCallPublishesExactlyOneEvent with a marked LlmProvider
entry whose direct peer is empty, then assert it still publishes exactly one
event and retains the LlmProvider API type. Use the existing entry-construction
helpers and preserve the current unmarked direct-provider coverage.
In `@gateway/it/features/analytics-basic.feature`:
- Around line 131-136: Replace the fixed 3-second delay after the deployment
response in the analytics scenario with the existing endpoint-readiness step for
/analytics-dedup-proxy/chat/completions, then keep the existing Given I reset
the analytics collector step immediately afterward.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c806387b-b889-4657-96ca-fa8b347ac9bd
📒 Files selected for processing (5)
gateway/gateway-controller/pkg/eventlistener/llm_provider_processor_test.gogateway/gateway-runtime/policy-engine/internal/analytics/analytics.gogateway/gateway-runtime/policy-engine/internal/analytics/analytics_test.gogateway/it/features/analytics-basic.featuregateway/system-policies/analytics/analytics.go
Purpose
This PR adds some minor improvements to the fix added for suppressing the LLMProvider call analytics event emitted when invoking an LLMProxy. Along with that, this will add both unit tests and integration tests for verifying the intended behavior is provided.
Correctness / clarity
Logging / observability
Tests
Related PRs