@@ -38,31 +38,17 @@ def call(request)
3838 private
3939
4040 # Parse x-request-start header and calculate queue time in seconds.
41- # Supports multiple formats:
41+ # Supports formats:
4242 # - "t=1234567890.123" (nginx format with 't=' prefix)
4343 # - "1234567890.123" (Unix timestamp in seconds)
44- # - "1234567890123" (Unix timestamp in milliseconds)
4544 def calculate_queue_time ( header_value )
4645 return nil unless header_value
4746
4847 # Remove 't=' prefix if present (nginx format)
49- timestamp_str = header_value . sub ( /^t=/ , "" )
48+ timestamp_string = header_value . sub ( /^t=/ , "" )
5049
5150 begin
52- timestamp = Float ( timestamp_str )
53-
54- # If timestamp is very large, it's likely in milliseconds or microseconds
55- # Convert to seconds if necessary
56- if timestamp > 10_000_000_000
57- # Likely milliseconds (13 digits) or microseconds (16 digits)
58- if timestamp > 10_000_000_000_000
59- # Microseconds (16 digits)
60- timestamp = timestamp / 1_000_000.0
61- else
62- # Milliseconds (13 digits)
63- timestamp = timestamp / 1000.0
64- end
65- end
51+ timestamp = Float ( timestamp_string )
6652
6753 current_time = Process . clock_gettime ( Process ::CLOCK_REALTIME )
6854 queue_time = current_time - timestamp
0 commit comments