@@ -38,31 +38,17 @@ def call(request)
38
38
private
39
39
40
40
# Parse x-request-start header and calculate queue time in seconds.
41
- # Supports multiple formats:
41
+ # Supports formats:
42
42
# - "t=1234567890.123" (nginx format with 't=' prefix)
43
43
# - "1234567890.123" (Unix timestamp in seconds)
44
- # - "1234567890123" (Unix timestamp in milliseconds)
45
44
def calculate_queue_time ( header_value )
46
45
return nil unless header_value
47
46
48
47
# Remove 't=' prefix if present (nginx format)
49
- timestamp_str = header_value . sub ( /^t=/ , "" )
48
+ timestamp_string = header_value . sub ( /^t=/ , "" )
50
49
51
50
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 )
66
52
67
53
current_time = Process . clock_gettime ( Process ::CLOCK_REALTIME )
68
54
queue_time = current_time - timestamp
0 commit comments