[jaegerai] Refactor route registration and request body size handling#8468
Conversation
…ooling Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
…s for the tools context Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Nabil-Salah <[email protected]>
…ah/jaeger into develop_mcp_ai_context
Signed-off-by: Yuri Shkuro <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR refactors jaeger-query’s AI gateway endpoint wiring by moving route registration into the jaegerai package and tightening AI request-body size configuration defaults/validation.
Changes:
- Replace inline AI route path construction in
initRouterwith ajaegerai.Handlerthat registers its own routes. - Introduce
AIConfigdefaulting forMaxRequestBodySize(0 →DefaultMaxRequestBodySize) via a pointer-receiverValidate(). - Add unit tests for AI route registration/base-path behavior and for the updated
AIConfig.Validate()semantics.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cmd/jaeger/internal/extension/jaegerquery/internal/server.go | Switch AI endpoint registration to jaegerai.NewHandler(...).RegisterRoutes(...). |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/routes.go | Add AI routing helper/handler to encapsulate route registration and base-path normalization. |
| cmd/jaeger/internal/extension/jaegerquery/internal/jaegerai/routes_test.go | Add tests for AI handler config storage and route mounting (including base-path variants). |
| cmd/jaeger/internal/extension/jaegerquery/internal/flags.go | Add DefaultMaxRequestBodySize and make AIConfig.Validate() default zero body size. |
| cmd/jaeger/internal/extension/jaegerquery/internal/flags_test.go | Update tests to assert defaulting behavior and accept positive body sizes. |
| cmd/jaeger/internal/extension/jaegermcp/server_test.go | Minor formatting change in test helper return struct literal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Operator-supplied trailing slash must be normalized away so we | ||
| // don't register a "/jaeger//api/..." pattern. | ||
| name: "trailing slash in base path is normalized", | ||
| basePath: "/jaeger/", | ||
| wantChat: "/jaeger/api/ai/chat", | ||
| }, |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8468 +/- ##
==========================================
+ Coverage 96.48% 96.51% +0.02%
==========================================
Files 323 323
Lines 17123 17093 -30
==========================================
- Hits 16521 16497 -24
+ Misses 452 448 -4
+ Partials 150 148 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CI Summary ReportMetrics Comparison❌ 72 metric change(s) detected View changed metricsFor label-level diff details, open the CI run and expand the "Compare metrics and generate summary" step logs. metrics_snapshot_elasticsearch_8.x_e2e — ⬇️ download diff
metrics_snapshot_elasticsearch_9.x_e2e — ⬇️ download diff
Code Coverage✅ Coverage 97.2% (baseline 97.2%) ➡️ View CI run | View publish logs |
Summary
Infrastructure cleanup for the
jaegeraiAI gateway, extracted as a prerequisite to the upcoming AG-UI / contextual tools work. No behavior change for end users.jaegerai.Handler+RegisterRoutes(newroutes.go): mirrors theAPIHandler/HTTPGatewaypattern used by sibling jaeger-query subsystems, replacing inline path math inserver.go.normalizeBasePath: fixes a double-slash bug when operators supply a trailing slash onBasePath(e.g./jaeger/→ registered as/jaeger/api/ai/chat, not/jaeger//api/ai/chat).DefaultMaxRequestBodySize(1 MiB) lifted from a magic number into a named constant;AIConfig.Validateis now a pointer receiver that applies the default in place whenMaxRequestBodySize == 0.Test plan
go build ./...go test ./cmd/jaeger/internal/extension/jaegerquery/...gofumpt -l -dclean on changed filesgolangci-lint runreports 0 issuesroutes_test.gocovers empty ////jaeger//jaeger/base-path cases🤖 Generated with Claude Code