@@ -32,14 +32,14 @@ class Exporter # rubocop:disable Metrics/ClassLength
3232 ERROR_MESSAGE_INVALID_HEADERS = 'headers must be a String with comma-separated URL Encoded UTF-8 k=v pairs or a Hash'
3333 private_constant ( :ERROR_MESSAGE_INVALID_HEADERS )
3434
35- def initialize ( endpoint : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT' , 'OTEL_EXPORTER_OTLP_ENDPOINT' , default : 'http://localhost:4318/v1/traces' ) , # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
36- certificate_file : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE' , 'OTEL_EXPORTER_OTLP_CERTIFICATE' ) ,
35+ def initialize ( endpoint : OpenTelemetry :: Common :: Utilities . config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT' , 'OTEL_EXPORTER_OTLP_ENDPOINT' , default : 'http://localhost:4318/v1/traces' ) , # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
36+ certificate_file : OpenTelemetry :: Common :: Utilities . config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE' , 'OTEL_EXPORTER_OTLP_CERTIFICATE' ) ,
3737 ssl_verify_mode : fetch_ssl_verify_mode ,
38- headers : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_HEADERS' , 'OTEL_EXPORTER_OTLP_HEADERS' , default : { } ) ,
39- compression : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_COMPRESSION' , 'OTEL_EXPORTER_OTLP_COMPRESSION' , default : 'gzip' ) ,
40- timeout : config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_TIMEOUT' , 'OTEL_EXPORTER_OTLP_TIMEOUT' , default : 10 ) ,
38+ headers : OpenTelemetry :: Common :: Utilities . config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_HEADERS' , 'OTEL_EXPORTER_OTLP_HEADERS' , default : { } ) ,
39+ compression : OpenTelemetry :: Common :: Utilities . config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_COMPRESSION' , 'OTEL_EXPORTER_OTLP_COMPRESSION' , default : 'gzip' ) ,
40+ timeout : OpenTelemetry :: Common :: Utilities . config_opt ( 'OTEL_EXPORTER_OTLP_TRACES_TIMEOUT' , 'OTEL_EXPORTER_OTLP_TIMEOUT' , default : 10 ) ,
4141 metrics_reporter : nil )
42- raise ArgumentError , "invalid url for OTLP::Exporter #{ endpoint } " if invalid_url ?( endpoint )
42+ raise ArgumentError , "invalid url for OTLP::Exporter #{ endpoint } " unless OpenTelemetry :: Common :: Utilities . valid_url ?( endpoint )
4343 raise ArgumentError , "unsupported compression key #{ compression } " unless compression . nil? || %w[ gzip none ] . include? ( compression )
4444
4545 @uri = if endpoint == ENV [ 'OTEL_EXPORTER_OTLP_ENDPOINT' ]
@@ -117,23 +117,6 @@ def http_connection(uri, ssl_verify_mode, certificate_file)
117117 http
118118 end
119119
120- def config_opt ( *env_vars , default : nil )
121- env_vars . each do |env_var |
122- val = ENV [ env_var ]
123- return val unless val . nil?
124- end
125- default
126- end
127-
128- def invalid_url? ( url )
129- return true if url . nil? || url . strip . empty?
130-
131- URI ( url )
132- false
133- rescue URI ::InvalidURIError
134- true
135- end
136-
137120 # The around_request is a private method that provides an extension
138121 # point for the exporters network calls. The default behaviour
139122 # is to not trace these operations.
0 commit comments