Skip to content

opentelemetry-exporter-otlp: http_connection does not handle ipv6 host #1721

@acarella1

Description

@acarella1

The OT library uses host from URI which fails to unwrap ipv6 brackets properly. Fix is to update this to use hostname instead, which will return a plain ipv6 address which is what Net::HTTP expects as the first argument.

http = Net::HTTP.new(uri.host, uri.port)

Share details about your runtime

Operating system details: FROM ruby:3.3.5-bookworm
RUBY_ENGINE: "ruby"
RUBY_VERSION: "3.3.5"
RUBY_DESCRIPTION: "ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [aarch64-linux]"

Share a simplified reproduction if possible

failure.rb

require 'net/http'
uri = URI('http://[::1]:4318')
http = Net::HTTP.new(uri.host, uri.port)
http.start

(hard error) getaddrinfo: Name or service not known (Socket::ResolutionError)

success.rb

require 'net/http'
uri = URI('http://[::1]:4318')
http = Net::HTTP.new(uri.hostname, uri.port)
http.start

(would be a success if something were on the port) Connection refused - connect(2) for "::1" port 4318 (Errno::ECONNREFUSED)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingkeep

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions