Module: OpenTelemetry::Common::Utilities
Overview
Utilities contains common helpers.
Instance Method Summary collapse
-
#maybe_timeout(timeout, start_time) ⇒ Object
private
Returns nil if timeout is nil, 0 if timeout has expired, or the remaining (positive) time left in seconds.
Instance Method Details
#maybe_timeout(timeout, start_time) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns nil if timeout is nil, 0 if timeout has expired, or the remaining (positive) time left in seconds.
16 17 18 19 20 21 |
# File 'lib/opentelemetry/common/utilities.rb', line 16 def maybe_timeout(timeout, start_time) return nil if timeout.nil? timeout -= (Time.now - start_time) timeout.positive? ? timeout : 0 end |