Choosing the Right OTLP Exporter Transport for Java Services: gRPC vs HTTP/Protobuf
When instrumenting Java services with OpenTelemetry, choosing between gRPC and HTTP/1.1 OTLP exporters boils down to latency, infrastructure, and operational simplicity. This guide compares both transports, explains trade‑offs, and shows concrete Java code to validate your choice.
07 Jul 2025, 18:33 UTC

Decision: Pick the OTLP Exporter Transport for Java Tracing
When you instrument a Java application with OpenTelemetry and need to send spans to an OpenTelemetry Collector, you face a single, well‑defined choice: which OTLP transport to use? The OpenTelemetry Protocol (OTLP) supports two HTTP‑based transports: gRPC (HTTP/2) and HTTP/1.1 with Protobuf payloads. Your decision should balance latency, throughput, operational simplicity, and existing network constraints.
Constraints to Consider
- Network Infrastructure: Does your environment support HTTP/2? Are you behind proxies that only understand HTTP/1.1?
- Collector Version: The Collector must expose the matching OTLP endpoint (4317 for gRPC, 4318 for HTTP/1.1).
- Security Requirements: TLS or mTLS is mandatory in production. Plain HTTP endpoints expose sensitive trace data.
- Operational Complexity: gRPC requires a more advanced runtime and may need additional configuration for keep‑alive, flow control, and compression.
- Throughput vs Latency: High‑volume services may benefit from gRPC’s multiplexing, while low‑volume or highly intermittent traffic may be fine with HTTP/1.1.
Transport Options in a Compact Table
| Option | Transport | Pros | Cons |
|---|---|---|---|
| gRPC | HTTP/2 | Low latency, multiplexing, built‑in flow control, compression support | Requires HTTP/2 support, more complex setup, larger runtime footprint |
| HTTP/Protobuf | HTTP/1.1 | Simple, works behind any HTTP proxy, easy to debug with curl or Wireshark | Higher per‑request overhead, no multiplexing, larger payload per request |
Trade‑offs Explained
Latency and Throughput
gRPC uses HTTP/2, which allows multiple streams over a single TCP connection. This reduces connection overhead and improves latency, especially when sending many small spans. HTTP/1.1 must open a new connection or reuse a persistent one for each request, adding round‑trip time and increasing CPU usage for connection establishment.
Operational Simplicity
HTTP/1.1 requires no special runtime support and works with any standard Java HTTP client. gRPC demands the io.grpc library and a proper HTTP/2 stack (e.g., Jetty or Netty). In environments where HTTP/2 is not yet enabled, HTTP/1.1 is the safer default.
Compatibility with Proxies and Firewalls
Many corporate proxies only understand HTTP/1.1. gRPC traffic can be blocked or require special configuration (e.g., ALPN). If you cannot guarantee HTTP/2 support across the path to the Collector, HTTP/1.1 is the pragmatic choice.
Security Considerations
Both transports should use TLS in production. gRPC supports mTLS out of the box; HTTP/1.1 requires configuring the underlying HTTP client. Be aware that using plain HTTP exposes trace data to network sniffing.
Concrete Implementation Example (Java, OpenTelemetry SDK 1.28)
Below is a minimal setup for each transport. Replace http://collector:4317 or http://collector:4318 with your Collector’s address.
gRPC Exporter
OtlpGrpcSpanExporter exporter = OtlpGrpcSpanExporter.builder()
.setEndpoint("http://collector:4317")
.build();
SdkTracerProvider provider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(exporter).build())
.build();
HTTP/1.1 Exporter
OtlpHttpSpanExporter exporter = OtlpHttpSpanExporter.builder()
.setEndpoint("http://collector:4318")
.build();
SdkTracerProvider provider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(exporter).build())
.build();
Both snippets use BatchSpanProcessor to batch spans, which is recommended for production. For debugging, replace BatchSpanProcessor with SimpleSpanProcessor and a ConsoleSpanExporter to see the exporter’s behavior.
Validation & Verification Steps
- Run a Local Collector: Start an OpenTelemetry Collector with both OTLP gRPC (port 4317) and OTLP HTTP/1.1 (port 4318) endpoints enabled.
receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 http: endpoint: 0.0.0.0:4318 exporters: jaeger: endpoint: "localhost:14250" insecure: true service: pipelines: traces: receivers: [otlp] exporters: [jaeger] - Instrument the Java App: Use the exporter code above, point to the Collector’s local address, and run the application.
- Check Collector Logs: The Collector logs should show inbound OTLP requests on the selected port. Look for entries similar to
Received 10 spans. - Verify Span Export: Open the Jaeger UI (or any backend you configured) and confirm that the spans appear. If they do not, check for TLS/mTLS mismatches or incorrect endpoint URLs.
- Inspect Exporter Errors: The SDK logs any export failures. In production, enable
LoggingSpanExportertemporarily to capture errors.
Limitations & Edge Cases
- The decision table assumes a single Collector instance. If you have multiple collectors or a load‑balanced setup, you may need to duplicate the exporter configuration or use service discovery.
- gRPC requires Java 8+ and the
io.grpclibrary. Ensure no class‑path conflicts with other HTTP/2 libraries. - HTTP/1.1 can still suffer from high latency under heavy load; consider enabling TCP keep‑alive and adjusting the
maxConcurrentRequestssetting in the Collector. - Both transports support compression (gzip). Enabling it requires matching Collector configuration; otherwise, the Collector may reject requests.
Practical Decision Checklist
- Do you have HTTP/2 enabled throughout the network? If yes, gRPC is usually the better choice.
- Are you behind a proxy that only supports HTTP/1.1? Choose HTTP/1.1.
- Do you need the lowest possible latency for high‑volume tracing? gRPC.
- Do you prioritize operational simplicity and quick debugging? HTTP/1.1.
- Is TLS/mTLS already in place for your application traffic? Ensure the exporter uses
https://endpoints and the Collector is configured accordingly.
By following this guide, you can make an informed decision that aligns with your infrastructure constraints and performance goals.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.