Skip to content

How to switch between HTTP1 and HTTP2 protocols when using default otel exporters #7272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
I576510 opened this issue Apr 14, 2025 · 3 comments
Labels
needs author feedback Waiting for additional feedback from the author

Comments

@I576510
Copy link

I576510 commented Apr 14, 2025

Hi Team,

We are using default otel exporter in our java and node js applications. Can you please provide us ways to achieve this? we don't want to use gRPC or create a custom exporter. How can we switch between HTTP1 and HTTP2 protocols when using default otel exporters?

Please suggest options for both Java and node.js

Below is our understanding wrt to using HTTP2 with default exporter, please check

JAVA

  • OpenTelemetry does not provide an automatic runtime toggle between HTTP/1.1 and HTTP/2.
  • It does provide a way to switch between http/protobuf and grpc, which is effectively how you switch between HTTP/1.1 and HTTP/2 (because gRPC uses HTTP/2).
  • If you're using default exporters, switching protocols generally means changing the exporter protocol (http/protobuf ↔ grpc).
  • we can't create our custom HTTP client and set it explicitly in default OTEL exporter.

Node.js

  • JavaScript (Node.js) doesn’t auto-switch protocols at runtime — you explicitly choose the protocol via the exporter you use (http or grpc).

  • If you use @opentelemetry/exporter-trace-otlp-http → you're using HTTP/1.1 by default.

  • If you use @opentelemetry/exporter-trace-otlp-grpc → you're using HTTP/2 (because gRPC requires HTTP/2).

  • In JS, the "default exporter" is usually OTLP/HTTP, especially in examples or SDK auto-instrumentation.

    To use gRPC (i.e., HTTP/2), you need to:
    Manually install the gRPC exporter package:
    npm install @opentelemetry/exporter-trace-otlp-grpc
    And manually wire it up in your code.
    So in JS, switching from HTTP/1.1 to HTTP/2 is not just changing a config value — it requires using a different package/exporter.

@I576510 I576510 changed the title How to switch between HTTP 1 and HTTP2 protocols when using default otel exporters How to switch between HTTP1 and HTTP2 protocols when using default otel exporters Apr 14, 2025
@jack-berg
Copy link
Member

Under the hood, the OtllpHttp{Signal}Exporters use either the JDK 11+ built-in HTTP client, or OkHttp.

Both JDK 11+ HTTP client and OkHttp implementation uses either http/2 or http/1.1 based on negotiation with the server, and prioritize http/2.

@I576510
Copy link
Author

I576510 commented Apr 14, 2025

@jack-berg what is the case for node.js?

@trask
Copy link
Member

trask commented Apr 14, 2025

@I576510 I'd recommend asking this in the JS repo

@jack-berg jack-berg added the needs author feedback Waiting for additional feedback from the author label Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs author feedback Waiting for additional feedback from the author
Projects
None yet
Development

No branches or pull requests

3 participants