Skip to content

fix(otlp): return application/x-protobuf response format on otlp endpoints - #6801

Open
Tyagiquamar wants to merge 1 commit into
quickwit-oss:mainfrom
Tyagiquamar:fix/otlp-protobuf-response-content-type
Open

Tyagiquamar wants to merge 1 commit into
quickwit-oss:mainfrom
Tyagiquamar:fix/otlp-protobuf-response-content-type

Conversation

@Tyagiquamar

Copy link
Copy Markdown

Summary

Fixes #6786

OTLP REST ingest endpoints (/otlp/v1/logs and /otlp/v1/traces) previously routed successful responses through into_rest_api_response, which serialized payloads to JSON and set Content-Type: application/json. OpenTelemetry exporters sending Protobuf payloads over HTTP expect Protobuf binary responses with Content-Type: application/x-protobuf per the OTLP/HTTP specification.

This PR introduces into_otlp_protobuf_response:

  • Encodes successful ExportLogsServiceResponse and ExportTraceServiceResponse messages to Protobuf bytes using prost::Message::encode_to_vec().
  • Sets Content-Type: application/x-protobuf with StatusCode::OK.
  • Preserves standard JSON error structure when ingest errors occur.
  • Updates unit tests in quickwit/quickwit-serve/src/otlp_api/rest_handler.rs to decode protobuf responses and verify the application/x-protobuf content-type header.

Test Plan

  • Updated quickwit-serve OTLP unit tests (otlp_default_logs_handler, otlp_logs_handler, otlp_default_traces_handler, and otlp_ingest_traces_handler) to assert Content-Type: application/x-protobuf and decode response bodies using ExportLogsServiceResponse::decode and ExportTraceServiceResponse::decode.

…oints

Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com>
@Tyagiquamar
Tyagiquamar requested a review from a team as a code owner September 15, 2026 07:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +55 to +58
response.headers_mut().insert(
CONTENT_TYPE,
HeaderValue::from_static("application/x-protobuf"),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OTLP record with time_unix_nano: 0 is rejected with an empty error_message, and the response is JSON for a protobuf request

1 participant