Skip to content

Support configurable OTLP exporter protocol for traces and logs#6254

Open
shuheiktgw wants to merge 1 commit intomainfrom
refactor/otlp-exporter-protocol-resolution
Open

Support configurable OTLP exporter protocol for traces and logs#6254
shuheiktgw wants to merge 1 commit intomainfrom
refactor/otlp-exporter-protocol-resolution

Conversation

@shuheiktgw
Copy link
Copy Markdown
Collaborator

@shuheiktgw shuheiktgw commented Mar 31, 2026

Summary

  • Currently, the OTLP protocol for the exporter is hardcoded to gRPC. However, some vendors do not support gRPC, so we would like to support other protocols as well and make the protocol configurable through standard environment variables.
  • Add support for OTEL_EXPORTER_OTLP_PROTOCOL and per-signal env vars (OTEL_EXPORTER_OTLP_TRACES_PROTOCOL, OTEL_EXPORTER_OTLP_LOGS_PROTOCOL) to select gRPC, HTTP/protobuf, or HTTP/JSON transport for the OTLP exporter. Default remains gRPC for backward compatibility.

I'm new to Rust, so I'd really appreciate any feedback on my coding style 🙇

Test

Verified all 3 protocols deliver both traces and logs to a local OTEL Collector (v0.84.0).

Collector setup:

Save the following as /tmp/otel-debug-config.yaml:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

exporters:
  logging:
    loglevel: debug

service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [logging]
    logs:
      receivers: [otlp]
      exporters: [logging]

Note: v0.84.0 uses logging exporter; the debug exporter is not yet available at this version.

docker run --rm -p 4317:4317 -p 4318:4318 \
  -v /tmp/otel-debug-config.yaml:/etc/otel-config.yaml \
  otel/opentelemetry-collector:0.84.0 \
  --config=/etc/otel-config.yaml

Prerequisite:

mkdir -p /tmp/qwdata

1. gRPC (default)

QW_ENABLE_OPENTELEMETRY_OTLP_EXPORTER=true \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
QW_DATA_DIR=/tmp/qwdata \
cargo run --manifest-path quickwit/Cargo.toml -p quickwit-cli -- run

2. HTTP/protobuf

QW_ENABLE_OPENTELEMETRY_OTLP_EXPORTER=true \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf \
QW_DATA_DIR=/tmp/qwdata \
cargo run --manifest-path quickwit/Cargo.toml -p quickwit-cli -- run

3. HTTP/JSON

QW_ENABLE_OPENTELEMETRY_OTLP_EXPORTER=true \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 \
OTEL_EXPORTER_OTLP_PROTOCOL=http/json \
QW_DATA_DIR=/tmp/qwdata \
cargo run --manifest-path quickwit/Cargo.toml -p quickwit-cli -- run

What to verify in Collector stdout:

  • TracesExporter + ResourceSpans output (traces received)
  • LogsExporter + ResourceLog + LogRecord output (logs received)

@shuheiktgw shuheiktgw marked this pull request as draft March 31, 2026 12:51
@shuheiktgw shuheiktgw force-pushed the refactor/otlp-exporter-protocol-resolution branch 3 times, most recently from 9933587 to 0a1d6b3 Compare March 31, 2026 13:18
@shuheiktgw

This comment was marked as outdated.

@shuheiktgw shuheiktgw marked this pull request as ready for review March 31, 2026 13:28
.with_tonic()
.build()
.context("failed to initialize OpenTelemetry OTLP exporter")?;
let global_protocol = env::var("OTEL_EXPORTER_OTLP_PROTOCOL").ok();
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note that these environment variables are not supported by the Rust SDK, so we need to handle them manually.

open-telemetry/opentelemetry-rust#3363

@shuheiktgw shuheiktgw force-pushed the refactor/otlp-exporter-protocol-resolution branch from 0a1d6b3 to 2e0ae4c Compare March 31, 2026 15:04
@shuheiktgw shuheiktgw force-pushed the refactor/otlp-exporter-protocol-resolution branch from 2e0ae4c to cd77bf2 Compare March 31, 2026 15:54
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.

1 participant