From 693423f9f3e5d61096965d81ac4bbec381f1744d Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Fri, 29 May 2026 14:23:19 -0700 Subject: [PATCH] Add proxy_address to OTLP Exporter This allows more fine-graned control over proxy configurations of various exporters. Fixes #2166 --- .../otlp/lib/opentelemetry/exporter/otlp/exporter.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb b/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb index 9647177f6..b3a00ad4c 100644 --- a/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb +++ b/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb @@ -53,12 +53,14 @@ def initialize(endpoint: nil, headers: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_TRACES_HEADERS', 'OTEL_EXPORTER_OTLP_HEADERS', default: {}), compression: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_TRACES_COMPRESSION', 'OTEL_EXPORTER_OTLP_COMPRESSION', default: 'gzip'), timeout: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_TRACES_TIMEOUT', 'OTEL_EXPORTER_OTLP_TIMEOUT', default: 10), - metrics_reporter: nil) + metrics_reporter: nil, + proxy_address: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_TRACES_PROXY_ADDRESS', 'OTEL_EXPORTER_OTLP_PROXY_ADDRESS'), + proxy_port: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_TRACES_PROXY_PORT', 'OTEL_EXPORTER_OTLP_PROXY_PORT')) @uri = prepare_endpoint(endpoint) raise ArgumentError, "unsupported compression key #{compression}" unless compression.nil? || %w[gzip none].include?(compression) - @http = http_connection(@uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file) + @http = http_connection(@uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file, proxy_address: proxy_address, proxy_port: proxy_port) @path = @uri.path @headers = prepare_headers(headers) @@ -123,8 +125,8 @@ def build_span_flags(parent_span_is_remote, base_flags) flags end - def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file) - http = Net::HTTP.new(uri.hostname, uri.port) + def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file, proxy_address: nil, proxy_port: nil) + http = Net::HTTP.new(uri.hostname, uri.port, proxy_address, proxy_port) http.use_ssl = uri.scheme == 'https' http.verify_mode = ssl_verify_mode http.ca_file = certificate_file unless certificate_file.nil?