Skip to content

Commit 51cf44d

Browse files
chen-andersotelbot-ruby[bot]otelbot[bot]kaylareopellexuan-cao-swi
authored
fix: issue with sending traces to IPv6 endpoints (#1935)
* Fix issue with sending traces to IPv6 endpoints * release: Release 5 gems (#1938) * release: Release 5 gems * opentelemetry-sdk 1.10.0 (was 1.9.0) * opentelemetry-common 0.23.0 (was 0.22.0) * opentelemetry-exporter-otlp 0.31.0 (was 0.30.0) * opentelemetry-test-helpers 0.7.0 (was 0.6.0) * opentelemetry-metrics-sdk 0.10.0 (was 0.9.1) * Apply suggestions from code review --------- Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> * chore: regenerate from opentelemetry-proto v1.8.0 for metrics, logs and common (#1945) * ci: Add PRs and Issues perms for release hooks (#1940) These were missed on earlier updates related to OTel security requirements * release: Release 2 gems (#1946) * release: Release 2 gems * opentelemetry-exporter-otlp-metrics 0.6.1 (was 0.6.0) * opentelemetry-exporter-otlp-logs 0.2.2 (was 0.2.1) * Apply suggestions from code review --------- Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> * fix(gem): Requires minimum SDK support for new parent_span_is_remote attribute (#1942) Fixes #1941 Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> * fix: add test case for metric_store and metric_view (#1894) * test: test case for metric_stream and store * update test case * refine the test case; safeguard the callback * remove typo * replace unsafe timeout.timeout with thread join time * test fix * sleep 0.2 * skip some test for truffleruby * update test case * lint * skip thread related test * remove unstable test due to thread management * lint --------- Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> * fix: change zipkin annotations timestamp from string to int (#1944) Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> * release: Release 3 gems (#1949) * release: Release 3 gems * opentelemetry-exporter-otlp 0.31.1 (was 0.31.0) * opentelemetry-exporter-zipkin 0.24.1 (was 0.24.0) * opentelemetry-metrics-sdk 0.10.1 (was 0.10.0) * Update metrics_sdk/CHANGELOG.md --------- Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> * feat: Add logging about export status to Metrics SDK (#1947) * Adds some debug log output for successfully exporting metrics, and additional error logging. Implementation is borrowed from the Batch Log Record Processor. Does not include a count. Eventually that can be handled with the `otel.sdk.exporter.metric_data_point.exported` internal metric. See https://opentelemetry.io/docs/specs/semconv/otel/sdk-metrics/ Fixes: #1888 * Add a test * remove rubocop disable * use endless syntax * remove unused RaisingExporter copied from BLRP test * don't set export interval or timeout * use let statements * Use public force_flush instead of internal export method * Remove skip for Windows platform * remove puts stmt from debugging * release: Release opentelemetry-metrics-sdk 0.11.0 (was 0.10.1) (#1950) Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> * Add IPv4/IPv6 compatibility tests on otlp-http/otlp-logs/otlp-metrics exporters * Remove extraneous export span tests / focus on validation only --------- Co-authored-by: otelbot-ruby[bot] <231965978+otelbot-ruby[bot]@users.noreply.github.com> Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> Co-authored-by: Kayla Reopelle <87386821+kaylareopelle@users.noreply.github.com> Co-authored-by: Xuan <112967240+xuan-cao-swi@users.noreply.github.com> Co-authored-by: Mark Sta Ana <192864+booyaa@users.noreply.github.com> Co-authored-by: Pavlo Chypiga <chipiga@users.noreply.github.com> Co-authored-by: Wendy Smoak <wsmoak@gmail.com>
1 parent f81fbee commit 51cf44d

8 files changed

Lines changed: 428 additions & 4 deletions

File tree

exporter/otlp-http/lib/opentelemetry/exporter/otlp/http/trace_exporter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def fetch_ssl_verify_mode
109109
end
110110

111111
def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file)
112-
http = Net::HTTP.new(uri.host, uri.port)
112+
http = Net::HTTP.new(uri.hostname, uri.port)
113113
http.use_ssl = uri.scheme == 'https'
114114
http.verify_mode = ssl_verify_mode
115115
http.ca_file = certificate_file unless certificate_file.nil?

exporter/otlp-http/test/opentelemetry/exporter/otlp/http/trace_exporter_test.rb

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,112 @@
271271
end
272272
end
273273

274+
describe 'IPv4/IPv6 compatibility' do
275+
it 'handles IPv6 loopback address with brackets' do
276+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'http://[::1]:4318/v1/traces')
277+
http = exp.instance_variable_get(:@http)
278+
_(http.address).must_equal '::1'
279+
_(http.port).must_equal 4318
280+
_(exp.instance_variable_get(:@path)).must_equal '/v1/traces'
281+
end
282+
283+
it 'handles IPv6 full address with brackets' do
284+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'http://[2001:db8::1]:4318/v1/traces')
285+
http = exp.instance_variable_get(:@http)
286+
_(http.address).must_equal '2001:db8::1'
287+
_(http.port).must_equal 4318
288+
end
289+
290+
it 'handles IPv6 address with https' do
291+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'https://[::1]:4318/v1/traces')
292+
http = exp.instance_variable_get(:@http)
293+
_(http.address).must_equal '::1'
294+
_(http.port).must_equal 4318
295+
_(http.use_ssl?).must_equal true
296+
end
297+
298+
it 'handles IPv6 address with custom path' do
299+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'http://[::1]:8080/custom/path')
300+
http = exp.instance_variable_get(:@http)
301+
_(http.address).must_equal '::1'
302+
_(http.port).must_equal 8080
303+
_(exp.instance_variable_get(:@path)).must_equal '/custom/path'
304+
end
305+
306+
it 'handles IPv4 loopback address' do
307+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'http://127.0.0.1:4318/v1/traces')
308+
http = exp.instance_variable_get(:@http)
309+
_(http.address).must_equal '127.0.0.1'
310+
_(http.port).must_equal 4318
311+
_(exp.instance_variable_get(:@path)).must_equal '/v1/traces'
312+
end
313+
314+
it 'handles IPv4 address with custom port' do
315+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'http://192.168.1.100:8080/v1/traces')
316+
http = exp.instance_variable_get(:@http)
317+
_(http.address).must_equal '192.168.1.100'
318+
_(http.port).must_equal 8080
319+
end
320+
321+
it 'handles IPv4 address with https' do
322+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'https://10.0.0.1:4318/v1/traces')
323+
http = exp.instance_variable_get(:@http)
324+
_(http.address).must_equal '10.0.0.1'
325+
_(http.port).must_equal 4318
326+
_(http.use_ssl?).must_equal true
327+
end
328+
329+
it 'handles IPv4 address with custom path' do
330+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'http://127.0.0.1:9090/custom/path')
331+
http = exp.instance_variable_get(:@http)
332+
_(http.address).must_equal '127.0.0.1'
333+
_(http.port).must_equal 9090
334+
_(exp.instance_variable_get(:@path)).must_equal '/custom/path'
335+
end
336+
337+
it 'handles IPv4 address from environment variable' do
338+
exp = OpenTelemetry::TestHelpers.with_env('OTEL_EXPORTER_OTLP_ENDPOINT' => 'http://192.168.1.1:4318') do
339+
OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new
340+
end
341+
http = exp.instance_variable_get(:@http)
342+
_(http.address).must_equal '192.168.1.1'
343+
_(http.port).must_equal 4318
344+
_(exp.instance_variable_get(:@path)).must_equal '/v1/traces'
345+
end
346+
347+
it 'handles hostnames' do
348+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'http://localhost:4318/v1/traces')
349+
http = exp.instance_variable_get(:@http)
350+
_(http.address).must_equal 'localhost'
351+
_(http.port).must_equal 4318
352+
end
353+
354+
it 'handles fully qualified domain names' do
355+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'http://otel.example.com:4318/v1/traces')
356+
http = exp.instance_variable_get(:@http)
357+
_(http.address).must_equal 'otel.example.com'
358+
_(http.port).must_equal 4318
359+
end
360+
361+
it 'handles hostnames with https' do
362+
exp = OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new(endpoint: 'https://otel-collector.prod.example.com:443/v1/traces')
363+
http = exp.instance_variable_get(:@http)
364+
_(http.address).must_equal 'otel-collector.prod.example.com'
365+
_(http.port).must_equal 443
366+
_(http.use_ssl?).must_equal true
367+
end
368+
369+
it 'handles IPv6 address from environment variable' do
370+
exp = OpenTelemetry::TestHelpers.with_env('OTEL_EXPORTER_OTLP_ENDPOINT' => 'http://[::1]:4318') do
371+
OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new
372+
end
373+
http = exp.instance_variable_get(:@http)
374+
_(http.address).must_equal '::1'
375+
_(http.port).must_equal 4318
376+
_(exp.instance_variable_get(:@path)).must_equal '/v1/traces'
377+
end
378+
end
379+
274380
describe '#export' do
275381
let(:exporter) { OpenTelemetry::Exporter::OTLP::HTTP::TraceExporter.new }
276382

exporter/otlp-logs/lib/opentelemetry/exporter/otlp/logs/logs_exporter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def handle_http_error(response)
115115
end
116116

117117
def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file)
118-
http = Net::HTTP.new(uri.host, uri.port)
118+
http = Net::HTTP.new(uri.hostname, uri.port)
119119
http.use_ssl = uri.scheme == 'https'
120120
http.verify_mode = ssl_verify_mode
121121
http.ca_file = certificate_file unless certificate_file.nil?

exporter/otlp-logs/test/opentelemetry/exporter/otlp/logs_exporter_test.rb

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,112 @@
337337
end
338338
end
339339

340+
describe 'IPv4/IPv6 compatibility' do
341+
it 'handles IPv6 loopback address with brackets' do
342+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'http://[::1]:4318/v1/logs')
343+
http = exp.instance_variable_get(:@http)
344+
_(http.address).must_equal '::1'
345+
_(http.port).must_equal 4318
346+
_(exp.instance_variable_get(:@path)).must_equal '/v1/logs'
347+
end
348+
349+
it 'handles IPv6 full address with brackets' do
350+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'http://[2001:db8::1]:4318/v1/logs')
351+
http = exp.instance_variable_get(:@http)
352+
_(http.address).must_equal '2001:db8::1'
353+
_(http.port).must_equal 4318
354+
end
355+
356+
it 'handles IPv6 address with https' do
357+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'https://[::1]:4318/v1/logs')
358+
http = exp.instance_variable_get(:@http)
359+
_(http.address).must_equal '::1'
360+
_(http.port).must_equal 4318
361+
_(http.use_ssl?).must_equal true
362+
end
363+
364+
it 'handles IPv6 address with custom path' do
365+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'http://[::1]:8080/custom/path')
366+
http = exp.instance_variable_get(:@http)
367+
_(http.address).must_equal '::1'
368+
_(http.port).must_equal 8080
369+
_(exp.instance_variable_get(:@path)).must_equal '/custom/path'
370+
end
371+
372+
it 'handles IPv4 loopback address' do
373+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'http://127.0.0.1:4318/v1/logs')
374+
http = exp.instance_variable_get(:@http)
375+
_(http.address).must_equal '127.0.0.1'
376+
_(http.port).must_equal 4318
377+
_(exp.instance_variable_get(:@path)).must_equal '/v1/logs'
378+
end
379+
380+
it 'handles IPv4 address with custom port' do
381+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'http://192.168.1.100:8080/v1/logs')
382+
http = exp.instance_variable_get(:@http)
383+
_(http.address).must_equal '192.168.1.100'
384+
_(http.port).must_equal 8080
385+
end
386+
387+
it 'handles IPv4 address with https' do
388+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'https://10.0.0.1:4318/v1/logs')
389+
http = exp.instance_variable_get(:@http)
390+
_(http.address).must_equal '10.0.0.1'
391+
_(http.port).must_equal 4318
392+
_(http.use_ssl?).must_equal true
393+
end
394+
395+
it 'handles IPv4 address with custom path' do
396+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'http://127.0.0.1:9090/custom/path')
397+
http = exp.instance_variable_get(:@http)
398+
_(http.address).must_equal '127.0.0.1'
399+
_(http.port).must_equal 9090
400+
_(exp.instance_variable_get(:@path)).must_equal '/custom/path'
401+
end
402+
403+
it 'handles IPv4 address from environment variable' do
404+
exp = OpenTelemetry::TestHelpers.with_env('OTEL_EXPORTER_OTLP_ENDPOINT' => 'http://192.168.1.1:4318') do
405+
OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new
406+
end
407+
http = exp.instance_variable_get(:@http)
408+
_(http.address).must_equal '192.168.1.1'
409+
_(http.port).must_equal 4318
410+
_(exp.instance_variable_get(:@path)).must_equal '/v1/logs'
411+
end
412+
413+
it 'handles hostnames' do
414+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'http://localhost:4318/v1/logs')
415+
http = exp.instance_variable_get(:@http)
416+
_(http.address).must_equal 'localhost'
417+
_(http.port).must_equal 4318
418+
end
419+
420+
it 'handles fully qualified domain names' do
421+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'http://otel.example.com:4318/v1/logs')
422+
http = exp.instance_variable_get(:@http)
423+
_(http.address).must_equal 'otel.example.com'
424+
_(http.port).must_equal 4318
425+
end
426+
427+
it 'handles hostnames with https' do
428+
exp = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: 'https://otel-collector.prod.example.com:443/v1/logs')
429+
http = exp.instance_variable_get(:@http)
430+
_(http.address).must_equal 'otel-collector.prod.example.com'
431+
_(http.port).must_equal 443
432+
_(http.use_ssl?).must_equal true
433+
end
434+
435+
it 'handles IPv6 address from environment variable' do
436+
exp = OpenTelemetry::TestHelpers.with_env('OTEL_EXPORTER_OTLP_ENDPOINT' => 'http://[::1]:4318') do
437+
OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new
438+
end
439+
http = exp.instance_variable_get(:@http)
440+
_(http.address).must_equal '::1'
441+
_(http.port).must_equal 4318
442+
_(exp.instance_variable_get(:@path)).must_equal '/v1/logs'
443+
end
444+
end
445+
340446
describe '#export' do
341447
let(:exporter) { OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new }
342448
# TODO: replace with a before block to set a global logger provider through OpenTelemetry.logger_provider when the API code is merged

exporter/otlp-metrics/lib/opentelemetry/exporter/otlp/metrics/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Util # rubocop:disable Metrics/ModuleLength
1616
DEFAULT_USER_AGENT = "OTel-OTLP-MetricsExporter-Ruby/#{OpenTelemetry::Exporter::OTLP::Metrics::VERSION} Ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM}; #{RUBY_ENGINE}/#{RUBY_ENGINE_VERSION})".freeze
1717

1818
def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file)
19-
http = Net::HTTP.new(uri.host, uri.port)
19+
http = Net::HTTP.new(uri.hostname, uri.port)
2020
http.use_ssl = uri.scheme == 'https'
2121
http.verify_mode = ssl_verify_mode
2222
http.ca_file = certificate_file unless certificate_file.nil?

exporter/otlp-metrics/test/opentelemetry/exporter/otlp/metrics/metrics_exporter_test.rb

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,112 @@
334334
end
335335
end
336336

337+
describe 'IPv4/IPv6 compatibility' do
338+
it 'handles IPv6 loopback address with brackets' do
339+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'http://[::1]:4318/v1/metrics')
340+
http = exp.instance_variable_get(:@http)
341+
_(http.address).must_equal '::1'
342+
_(http.port).must_equal 4318
343+
_(exp.instance_variable_get(:@path)).must_equal '/v1/metrics'
344+
end
345+
346+
it 'handles IPv6 full address with brackets' do
347+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'http://[2001:db8::1]:4318/v1/metrics')
348+
http = exp.instance_variable_get(:@http)
349+
_(http.address).must_equal '2001:db8::1'
350+
_(http.port).must_equal 4318
351+
end
352+
353+
it 'handles IPv6 address with https' do
354+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'https://[::1]:4318/v1/metrics')
355+
http = exp.instance_variable_get(:@http)
356+
_(http.address).must_equal '::1'
357+
_(http.port).must_equal 4318
358+
_(http.use_ssl?).must_equal true
359+
end
360+
361+
it 'handles IPv6 address with custom path' do
362+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'http://[::1]:8080/custom/path')
363+
http = exp.instance_variable_get(:@http)
364+
_(http.address).must_equal '::1'
365+
_(http.port).must_equal 8080
366+
_(exp.instance_variable_get(:@path)).must_equal '/custom/path'
367+
end
368+
369+
it 'handles IPv4 loopback address' do
370+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'http://127.0.0.1:4318/v1/metrics')
371+
http = exp.instance_variable_get(:@http)
372+
_(http.address).must_equal '127.0.0.1'
373+
_(http.port).must_equal 4318
374+
_(exp.instance_variable_get(:@path)).must_equal '/v1/metrics'
375+
end
376+
377+
it 'handles IPv4 address with custom port' do
378+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'http://192.168.1.100:8080/v1/metrics')
379+
http = exp.instance_variable_get(:@http)
380+
_(http.address).must_equal '192.168.1.100'
381+
_(http.port).must_equal 8080
382+
end
383+
384+
it 'handles IPv4 address with https' do
385+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'https://10.0.0.1:4318/v1/metrics')
386+
http = exp.instance_variable_get(:@http)
387+
_(http.address).must_equal '10.0.0.1'
388+
_(http.port).must_equal 4318
389+
_(http.use_ssl?).must_equal true
390+
end
391+
392+
it 'handles IPv4 address with custom path' do
393+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'http://127.0.0.1:9090/custom/path')
394+
http = exp.instance_variable_get(:@http)
395+
_(http.address).must_equal '127.0.0.1'
396+
_(http.port).must_equal 9090
397+
_(exp.instance_variable_get(:@path)).must_equal '/custom/path'
398+
end
399+
400+
it 'handles IPv4 address from environment variable' do
401+
exp = OpenTelemetry::TestHelpers.with_env('OTEL_EXPORTER_OTLP_ENDPOINT' => 'http://192.168.1.1:4318') do
402+
OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new
403+
end
404+
http = exp.instance_variable_get(:@http)
405+
_(http.address).must_equal '192.168.1.1'
406+
_(http.port).must_equal 4318
407+
_(exp.instance_variable_get(:@path)).must_equal '/v1/metrics'
408+
end
409+
410+
it 'handles hostnames' do
411+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'http://localhost:4318/v1/metrics')
412+
http = exp.instance_variable_get(:@http)
413+
_(http.address).must_equal 'localhost'
414+
_(http.port).must_equal 4318
415+
end
416+
417+
it 'handles fully qualified domain names' do
418+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'http://otel.example.com:4318/v1/metrics')
419+
http = exp.instance_variable_get(:@http)
420+
_(http.address).must_equal 'otel.example.com'
421+
_(http.port).must_equal 4318
422+
end
423+
424+
it 'handles hostnames with https' do
425+
exp = OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(endpoint: 'https://otel-collector.prod.example.com:443/v1/metrics')
426+
http = exp.instance_variable_get(:@http)
427+
_(http.address).must_equal 'otel-collector.prod.example.com'
428+
_(http.port).must_equal 443
429+
_(http.use_ssl?).must_equal true
430+
end
431+
432+
it 'handles IPv6 address from environment variable' do
433+
exp = OpenTelemetry::TestHelpers.with_env('OTEL_EXPORTER_OTLP_ENDPOINT' => 'http://[::1]:4318') do
434+
OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new
435+
end
436+
http = exp.instance_variable_get(:@http)
437+
_(http.address).must_equal '::1'
438+
_(http.port).must_equal 4318
439+
_(exp.instance_variable_get(:@path)).must_equal '/v1/metrics'
440+
end
441+
end
442+
337443
describe '#export' do
338444
let(:exporter) { OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new }
339445
let(:meter_provider) { OpenTelemetry::SDK::Metrics::MeterProvider.new(resource: OpenTelemetry::SDK::Resources::Resource.telemetry_sdk) }

exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def build_span_flags(parent_span_is_remote, base_flags)
124124
end
125125

126126
def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file)
127-
http = Net::HTTP.new(uri.host, uri.port)
127+
http = Net::HTTP.new(uri.hostname, uri.port)
128128
http.use_ssl = uri.scheme == 'https'
129129
http.verify_mode = ssl_verify_mode
130130
http.ca_file = certificate_file unless certificate_file.nil?

0 commit comments

Comments
 (0)