puma_metrics_engine 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/puma_metrics_engine/queue_time_tracker.rb +19 -4
- data/lib/puma_metrics_engine/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 32e8e883e66e79ca9d1ed80ee21f5b0b880241f0157e325b21c7b679d9ffa56f
|
|
4
|
+
data.tar.gz: de06e4bed7924f401382ad5e852936cc16bbb699e7c98569957d8a7dae203cf9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d51049bfb157f4641cf41499ddd3c1769f7ffa8e13b0dba731124e748cfa2b80cfefb445ca7ecdc1fe06ba00aa31a137f7bc7978d84f962cb4ac413515a5bb7f
|
|
7
|
+
data.tar.gz: d2d192c9ceda0d7eed4de38ec1a2cce70f36d468cf3dc9de345cb7b3929fd4cd93df1b8fbda1d7deeb11546af6dea4cf0910291238ccb98393d9227572065599
|
|
@@ -57,7 +57,7 @@ module PumaMetricsEngine
|
|
|
57
57
|
|
|
58
58
|
def extract_request_start_time(env)
|
|
59
59
|
# Try X-Request-Start header (common in nginx, HAProxy, etc.)
|
|
60
|
-
# Format: "t=1234567890.123" or "1234567890.123" or Unix timestamp in microseconds
|
|
60
|
+
# Format: "t=1234567890.123" or "1234567890.123" or Unix timestamp in milliseconds/microseconds
|
|
61
61
|
header_value = env["HTTP_X_REQUEST_START"] || env["X-Request-Start"]
|
|
62
62
|
|
|
63
63
|
return nil unless header_value
|
|
@@ -75,10 +75,25 @@ module PumaMetricsEngine
|
|
|
75
75
|
|
|
76
76
|
timestamp = timestamp_str.to_f
|
|
77
77
|
|
|
78
|
-
#
|
|
79
|
-
#
|
|
78
|
+
# Detect timestamp format based on magnitude:
|
|
79
|
+
# - 10 digits or less: seconds (e.g., 1764410986)
|
|
80
|
+
# - 11-13 digits: milliseconds (e.g., 1764410986245)
|
|
81
|
+
# - 14+ digits: microseconds (e.g., 1764410986245000)
|
|
80
82
|
if timestamp > 4_102_444_800 # Year 2100 in seconds
|
|
81
|
-
|
|
83
|
+
# Count digits in integer part to determine format
|
|
84
|
+
integer_part = timestamp.to_i.to_s
|
|
85
|
+
digit_count = integer_part.length
|
|
86
|
+
|
|
87
|
+
if digit_count <= 10
|
|
88
|
+
# Already in seconds
|
|
89
|
+
timestamp
|
|
90
|
+
elsif digit_count <= 13
|
|
91
|
+
# Milliseconds - convert to seconds
|
|
92
|
+
timestamp = timestamp / 1_000.0
|
|
93
|
+
else
|
|
94
|
+
# Microseconds - convert to seconds
|
|
95
|
+
timestamp = timestamp / 1_000_000.0
|
|
96
|
+
end
|
|
82
97
|
end
|
|
83
98
|
|
|
84
99
|
timestamp
|