opentelemetry-collector
opentelemetry-collector copied to clipboard
Allow for http2 connection to otlphttpreceiver for insecure connections
Describe the bug Right now, the OTLP HTTP receiver only allows for http2 upgrades if you specify a TLS configuration. This is an issue for environments that terminate TLS before the collector.
Steps to reproduce
- Run a collector withthe config provided
- Run the curl locally:
curl -v --http2-prior-knowledge http://localhost:4318/v1/traces
What did you expect to see? that http2 succeeds
What did you see instead? A failure
* Host localhost:4318 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:4318...
* Immediate connect fail for ::1: Cannot assign requested address
* Trying 127.0.0.1:4318...
* Connected to localhost (127.0.0.1) port 4318
* [HTTP/2] [1] OPENED stream for http://localhost:4318/v1/traces
* [HTTP/2] [1] [:method: GET]
* [HTTP/2] [1] [:scheme: http]
* [HTTP/2] [1] [:authority: localhost:4318]
* [HTTP/2] [1] [:path: /v1/traces]
* [HTTP/2] [1] [user-agent: curl/8.5.0]
* [HTTP/2] [1] [accept: */*]
> GET /v1/traces HTTP/2
> Host: localhost:4318
> User-Agent: curl/8.5.0
> Accept: */*
>
* Remote peer returned unexpected data while we expected SETTINGS frame. Perhaps, peer does not support HTTP/2 properly.
* Closing connection
curl: (56) Remote peer returned unexpected data while we expected SETTINGS frame. Perhaps, peer does not support HTTP/2 properly.
What version did you use? v0.107.0
What config did you use?
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
batch:
exporters:
otlp:
endpoint: otelcol:4317
extensions:
health_check:
pprof:
zpages:
service:
extensions: [health_check, pprof, zpages]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlp]
Environment
Mac OS
Additional context This is the only place where the http2 protocol is allowed right now. Related issue. We could manually create an http2 handler following something like this:
if serverOptions.AllowH2CUpgrade {
h2s := &http2.Server{IdleTimeout: 0}
// handler.ServeHTTP blocks until the connection is closed. It creates a new server which managed the ]
// upgraded connection and uses handler to serve requests to it.
handler = h2c.NewHandler(handler, h2s)
}
I can work on this if @jaronoff97 is ok with that
thanks @iblancasa, i've assigned this to you