@@ -44,7 +44,7 @@ def self.ssl_verify_mode
4444 end
4545 end
4646
47- def initialize ( endpoint : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT' , 'OTEL_EXPORTER_OTLP_ENDPOINT' , default : 'https://localhost:4318/v1/traces' ) , # rubocop:disable Metrics/AbcSize, Metrics/ CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
47+ def initialize ( endpoint : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT' , 'OTEL_EXPORTER_OTLP_ENDPOINT' , default : 'https://localhost:4318/v1/traces' ) , # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
4848 certificate_file : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE' , 'OTEL_EXPORTER_OTLP_CERTIFICATE' ) ,
4949 ssl_verify_mode : Exporter . ssl_verify_mode ,
5050 headers : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_HEADERS' , 'OTEL_EXPORTER_OTLP_HEADERS' , default : { } ) ,
@@ -60,11 +60,7 @@ def initialize(endpoint: config_opt('OTEL_EXPORTER_OTLP_TRACES_ENDPOINT', 'OTEL_
6060 URI ( endpoint )
6161 end
6262
63- @http = Net ::HTTP . new ( @uri . host , @uri . port )
64- @http . use_ssl = @uri . scheme == 'https'
65- @http . verify_mode = ssl_verify_mode
66- @http . ca_file = certificate_file unless certificate_file . nil?
67- @http . keep_alive_timeout = KEEP_ALIVE_TIMEOUT
63+ @http = http_connection ( @uri , ssl_verify_mode , certificate_file )
6864
6965 @path = @uri . path
7066 @headers = case headers
@@ -114,6 +110,15 @@ def shutdown(timeout: nil)
114110
115111 private
116112
113+ def http_connection ( uri , ssl_verify_mode , certificate_file )
114+ http = Net ::HTTP . new ( uri . host , uri . port )
115+ http . use_ssl = uri . scheme == 'https'
116+ http . verify_mode = ssl_verify_mode
117+ http . ca_file = certificate_file unless certificate_file . nil?
118+ http . keep_alive_timeout = KEEP_ALIVE_TIMEOUT
119+ http
120+ end
121+
117122 def config_opt ( *env_vars , default : nil )
118123 env_vars . each do |env_var |
119124 val = ENV [ env_var ]
0 commit comments