Skip to content

[jaegerai] Refactor route registration and request body size handling#8468

Merged
yurishkuro merged 15 commits into
jaegertracing:mainfrom
yurishkuro:develop_mcp_ai_context-ysh
May 2, 2026
Merged

[jaegerai] Refactor route registration and request body size handling#8468
yurishkuro merged 15 commits into
jaegertracing:mainfrom
yurishkuro:develop_mcp_ai_context-ysh

Conversation

@yurishkuro
Copy link
Copy Markdown
Member

@yurishkuro yurishkuro commented May 2, 2026

Summary

Infrastructure cleanup for the jaegerai AI gateway, extracted as a prerequisite to the upcoming AG-UI / contextual tools work. No behavior change for end users.

  • jaegerai.Handler + RegisterRoutes (new routes.go): mirrors the APIHandler / HTTPGateway pattern used by sibling jaeger-query subsystems, replacing inline path math in server.go.
  • normalizeBasePath: fixes a double-slash bug when operators supply a trailing slash on BasePath (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.Validate is now a pointer receiver that applies the default in place when MaxRequestBodySize == 0.

Test plan

  • go build ./...
  • go test ./cmd/jaeger/internal/extension/jaegerquery/...
  • gofumpt -l -d clean on changed files
  • golangci-lint run reports 0 issues
  • New table-driven routes_test.go covers empty / / / /jaeger / /jaeger/ base-path cases

🤖 Generated with Claude Code

Nabil-Salah and others added 15 commits April 22, 2026 19:28
Signed-off-by: Nabil-Salah <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Copilot AI review requested due to automatic review settings May 2, 2026 21:55
@yurishkuro yurishkuro added the changelog:experimental Change to an experimental part of the code label May 2, 2026
@yurishkuro yurishkuro requested a review from a team as a code owner May 2, 2026 21:55
@yurishkuro yurishkuro changed the title Develop mcp ai context ysh [jaegerai] Refactor route registration and request body size handling May 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 initRouter with a jaegerai.Handler that registers its own routes.
  • Introduce AIConfig defaulting for MaxRequestBodySize (0 → DefaultMaxRequestBodySize) via a pointer-receiver Validate().
  • 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.

Comment on lines +44 to +49
// 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
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.51%. Comparing base (558d0ce) to head (3c73c36).
⚠️ Report is 3 commits behind head on main.

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     
Flag Coverage Δ
badger_direct 9.04% <ø> (ø)
badger_e2e 1.04% <ø> (ø)
cassandra-4.x-direct-manual 14.69% <ø> (ø)
cassandra-4.x-e2e-auto 1.03% <ø> (ø)
cassandra-4.x-e2e-manual 1.03% <ø> (ø)
cassandra-5.x-direct-manual 14.69% <ø> (ø)
cassandra-5.x-e2e-auto 1.03% <ø> (ø)
cassandra-5.x-e2e-manual 1.03% <ø> (ø)
clickhouse-direct 9.09% <ø> (ø)
clickhouse-e2e 1.16% <ø> (ø)
elasticsearch-6.x-direct 17.00% <ø> (ø)
elasticsearch-7.x-direct 17.03% <ø> (ø)
elasticsearch-8.x-direct 17.18% <ø> (ø)
elasticsearch-8.x-e2e 1.09% <ø> (+0.04%) ⬆️
elasticsearch-9.x-e2e 1.04% <ø> (ø)
grpc_direct 7.97% <ø> (ø)
grpc_e2e 1.04% <ø> (ø)
kafka-3.x-v2 1.04% <ø> (ø)
memory_v2 1.04% <ø> (ø)
opensearch-1.x-direct 17.08% <ø> (ø)
opensearch-2.x-direct 17.08% <ø> (ø)
opensearch-2.x-e2e 1.04% <ø> (-0.05%) ⬇️
opensearch-3.x-e2e 1.04% <ø> (ø)
query 1.04% <ø> (ø)
tailsampling-processor 0.52% <ø> (ø)
unittests 94.76% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 2, 2026

CI Summary Report

Metrics Comparison

❌ 72 metric change(s) detected

View changed metrics

For 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
3 added

  • jaeger_storage_latency_seconds
  • jaeger_storage_requests
  • rpc_server_call_duration_seconds

metrics_snapshot_elasticsearch_9.x_e2e⬇️ download diff
3 removed

  • jaeger_storage_latency_seconds
  • jaeger_storage_requests
  • rpc_server_call_duration_seconds

Code Coverage

✅ Coverage 97.2% (baseline 97.2%)

➡️ View CI run | View publish logs
2026-05-02 22:07:18 UTC

@yurishkuro yurishkuro merged commit 4cc44de into jaegertracing:main May 2, 2026
75 of 77 checks passed
@yurishkuro yurishkuro deleted the develop_mcp_ai_context-ysh branch May 2, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:experimental Change to an experimental part of the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants