Skip to content

Commit

Permalink
fix: remove WRITE_TIMEOUT_SUPPORTED (#1673)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Wear <[email protected]>
  • Loading branch information
xuan-cao-swi and mwear authored Aug 28, 2024
1 parent aad3cf7 commit 2f3ec59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class TraceExporter # rubocop:disable Metrics/ClassLength
# Default timeouts in seconds.
KEEP_ALIVE_TIMEOUT = 30
RETRY_COUNT = 5
WRITE_TIMEOUT_SUPPORTED = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
private_constant(:KEEP_ALIVE_TIMEOUT, :RETRY_COUNT, :WRITE_TIMEOUT_SUPPORTED)
private_constant(:KEEP_ALIVE_TIMEOUT, :RETRY_COUNT)

ERROR_MESSAGE_INVALID_HEADERS = 'headers must be a String with comma-separated URL Encoded UTF-8 k=v pairs or a Hash'
private_constant(:ERROR_MESSAGE_INVALID_HEADERS)
Expand Down Expand Up @@ -153,7 +152,7 @@ def send_bytes(bytes, timeout:) # rubocop:disable Metrics/MethodLength

@http.open_timeout = remaining_timeout
@http.read_timeout = remaining_timeout
@http.write_timeout = remaining_timeout if WRITE_TIMEOUT_SUPPORTED
@http.write_timeout = remaining_timeout
@http.start unless @http.started?
response = measure_request_duration { @http.request(request) }

Expand Down Expand Up @@ -209,7 +208,7 @@ def send_bytes(bytes, timeout:) # rubocop:disable Metrics/MethodLength
# Reset timeouts to defaults for the next call.
@http.open_timeout = @timeout
@http.read_timeout = @timeout
@http.write_timeout = @timeout if WRITE_TIMEOUT_SUPPORTED
@http.write_timeout = @timeout
end

def handle_redirect(location)
Expand Down
7 changes: 3 additions & 4 deletions exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class Exporter # rubocop:disable Metrics/ClassLength
# Default timeouts in seconds.
KEEP_ALIVE_TIMEOUT = 30
RETRY_COUNT = 5
WRITE_TIMEOUT_SUPPORTED = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
private_constant(:KEEP_ALIVE_TIMEOUT, :RETRY_COUNT, :WRITE_TIMEOUT_SUPPORTED)
private_constant(:KEEP_ALIVE_TIMEOUT, :RETRY_COUNT)

ERROR_MESSAGE_INVALID_HEADERS = 'headers must be a String with comma-separated URL Encoded UTF-8 k=v pairs or a Hash'
private_constant(:ERROR_MESSAGE_INVALID_HEADERS)
Expand Down Expand Up @@ -153,7 +152,7 @@ def send_bytes(bytes, timeout:) # rubocop:disable Metrics/CyclomaticComplexity,

@http.open_timeout = remaining_timeout
@http.read_timeout = remaining_timeout
@http.write_timeout = remaining_timeout if WRITE_TIMEOUT_SUPPORTED
@http.write_timeout = remaining_timeout
@http.start unless @http.started?
response = measure_request_duration { @http.request(request) }

Expand Down Expand Up @@ -213,7 +212,7 @@ def send_bytes(bytes, timeout:) # rubocop:disable Metrics/CyclomaticComplexity,
# Reset timeouts to defaults for the next call.
@http.open_timeout = @timeout
@http.read_timeout = @timeout
@http.write_timeout = @timeout if WRITE_TIMEOUT_SUPPORTED
@http.write_timeout = @timeout
end

def handle_redirect(location)
Expand Down
5 changes: 2 additions & 3 deletions exporter/zipkin/lib/opentelemetry/exporter/zipkin/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class Exporter # rubocop:disable Metrics/ClassLength
# Default timeouts in seconds.
KEEP_ALIVE_TIMEOUT = 30
RETRY_COUNT = 5
WRITE_TIMEOUT_SUPPORTED = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
private_constant(:KEEP_ALIVE_TIMEOUT, :RETRY_COUNT, :WRITE_TIMEOUT_SUPPORTED)
private_constant(:KEEP_ALIVE_TIMEOUT, :RETRY_COUNT)

def initialize(endpoint: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_ZIPKIN_ENDPOINT', default: 'http://localhost:9411/api/v2/spans'),
headers: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_HEADERS', 'OTEL_EXPORTER_ZIPKIN_HEADERS'),
Expand Down Expand Up @@ -130,7 +129,7 @@ def send_spans(zipkin_spans, timeout: nil) # rubocop:disable Metrics/MethodLengt

@http.open_timeout = remaining_timeout
@http.read_timeout = remaining_timeout
@http.write_timeout = remaining_timeout if WRITE_TIMEOUT_SUPPORTED
@http.write_timeout = remaining_timeout
@http.start unless @http.started?

response = measure_request_duration { @http.request(request) }
Expand Down

0 comments on commit 2f3ec59

Please sign in to comment.