20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/datadog/tracing/contrib/rack/request_queue.rb', line 20
def get_request_start(env, now = Time.now.utc)
= env[REQUEST_START] || env[QUEUE_START]
return unless
time_string = .to_s.delete('^0-9')
return if time_string.nil?
time_value = "#{time_string[0, 10]}.#{time_string[10, 6]}".to_f
return if time_value.zero? || time_value < MINIMUM_ACCEPTABLE_TIME_VALUE
request_start = Time.at(time_value)
request_start.utc > now ? nil : request_start
rescue StandardError => e
Datadog.logger.debug("[rack] unable to parse request queue headers: #{e}")
nil
end
|