fix(otlp): return application/x-protobuf response format on otlp endpoints - #6801
Tyagiquamar wants to merge 1 commit into
Conversation
…oints Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 284e6554b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| status_code, | ||
| message: error.to_string(), | ||
| }; | ||
| RestApiResponse::new(&Err(rest_api_error), status_code, BodyFormat::Json) |
There was a problem hiding this comment.
Specify the success type for the error-only Result
When quickwit-serve is compiled, Err(rest_api_error) provides no information from which Rust can infer the T: Serialize parameter required by RestApiResponse::new, producing E0283. Give this result an explicit success type (for example, Result::<(), _>::Err(...)) or use a non-generic error serializer; otherwise the crate cannot build and its tests cannot run.
AGENTS.md reference: AGENTS.md:L131-L138
Useful? React with 👍 / 👎.
| response.headers_mut().insert( | ||
| CONTENT_TYPE, | ||
| HeaderValue::from_static("application/x-protobuf"), | ||
| ); |
There was a problem hiding this comment.
Advertise protobuf responses in OpenAPI
When clients consume the generated OpenAPI document, all four OTLP response annotations still omit content_type, so utoipa describes their successful bodies as application/json even though this branch now returns binary protobuf; openapi.rs:89 publishes these OtlpApi paths. Update the response annotations to declare application/x-protobuf, or generated clients may attempt to decode these successful responses as JSON.
AGENTS.md reference: AGENTS.md:L23-L24
Useful? React with 👍 / 👎.
Summary
Fixes #6786
OTLP REST ingest endpoints (
/otlp/v1/logsand/otlp/v1/traces) previously routed successful responses throughinto_rest_api_response, which serialized payloads to JSON and setContent-Type: application/json. OpenTelemetry exporters sending Protobuf payloads over HTTP expect Protobuf binary responses withContent-Type: application/x-protobufper the OTLP/HTTP specification.This PR introduces
into_otlp_protobuf_response:ExportLogsServiceResponseandExportTraceServiceResponsemessages to Protobuf bytes usingprost::Message::encode_to_vec().Content-Type: application/x-protobufwithStatusCode::OK.quickwit/quickwit-serve/src/otlp_api/rest_handler.rsto decode protobuf responses and verify theapplication/x-protobufcontent-type header.Test Plan
quickwit-serveOTLP unit tests (otlp_default_logs_handler,otlp_logs_handler,otlp_default_traces_handler, andotlp_ingest_traces_handler) to assertContent-Type: application/x-protobufand decode response bodies usingExportLogsServiceResponse::decodeandExportTraceServiceResponse::decode.