Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR propagates the incoming HTTP User-Agent through REST/ES search endpoints into the root search request, and extends logging/metrics to include user-agent context for troubleshooting and observability.
Changes:
- Add
user_agenttoSearchRequest(proto + generated code) and propagate it from REST/Elasticsearch-compatible handlers intoroot_search. - Add root-search metrics labeling by (normalized) user-agent and include user-agent in root-search logs.
- Replace warp log-based HTTP metrics with a Tower layer that also logs each request and counts cancelled requests.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| quickwit/quickwit-serve/src/search_api/rest_handler.rs | Extracts User-Agent header for /search routes and forwards it into SearchRequest; updates route tests accordingly. |
| quickwit/quickwit-serve/src/rest.rs | Introduces a Tower layer to record HTTP metrics (including cancellations) and adds a per-request log line. |
| quickwit/quickwit-serve/src/metrics.rs | Changes serve-side HTTP metrics label dimensions to match the new Tower layer labeling. |
| quickwit/quickwit-serve/src/elasticsearch_api/rest_handler.rs | Threads user_agent through ES-compatible count/search/msearch request building into SearchRequest. |
| quickwit/quickwit-serve/src/elasticsearch_api/filter.rs | Extracts User-Agent header for ES-compatible routes. |
| quickwit/quickwit-serve/Cargo.toml | Adds pin-project dependency for the new Tower metrics future with pinned drop. |
| quickwit/quickwit-search/src/root.rs | Propagates user-agent through scroll simplification, adds it to root-search logs, and passes it into metrics trackers. |
| quickwit/quickwit-search/src/metrics_trackers.rs | Adds user-agent to root-search metrics labels and introduces normalize_user_agent bucketing. |
| quickwit/quickwit-search/src/metrics.rs | Expands root-search metric vectors to include user_agent as a label. |
| quickwit/quickwit-rest-client/src/rest_client.rs | Sets a default User-Agent header (qw-rest-client) on outgoing requests. |
| quickwit/quickwit-proto/src/codegen/quickwit/quickwit.search.rs | Adds user_agent field to generated SearchRequest. |
| quickwit/quickwit-proto/protos/quickwit/search.proto | Adds optional user_agent field to SearchRequest proto. |
| quickwit/quickwit-cli/src/tool.rs | Updates call site to pass None for the new user_agent parameter. |
| quickwit/Cargo.lock | Locks pin-project dependency addition. |
Comments suppressed due to low confidence (1)
quickwit/quickwit-serve/src/search_api/rest_handler.rs:547
- New
user-agentextraction isn’t asserted in these route tests (it’s currently ignored as_). Since this PR adds UA propagation, consider adding a test that sets aUser-Agentheader and asserts the extracted third tuple element isSome(...)(and/or that it is forwarded into the builtSearchRequest).
#[tokio::test]
async fn test_rest_search_api_route_post() {
let rest_search_api_filter = search_post_filter();
let (indexes, req, _) = warp::test::request()
.method("POST")
.path("/quickwit-demo-index/search")
.json(&true)
.body(r#"{"query": "*", "max_hits":10, "aggs": {"range":[]} }"#)
.filter(&rest_search_api_filter)
.await
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description
Add user agent to metrics and logs.
For now, user agent is only propagated to the root search.
This PR also adds a request log to help troubleshoot.
How was this PR tested?
I tested that logs are ok in integrations tests.