Skip to content

Commit 91454e8

Browse files
Remove arbitrary upper bound on queue time
Only validate that queue time is positive - there's no good reason to silently drop high queue time values as they represent legitimate observability data during incidents.
1 parent f8b7188 commit 91454e8

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

lib/metrics/provider/async/http/server.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def calculate_queue_time(header_value)
5353
current_time = Process.clock_gettime(Process::CLOCK_REALTIME)
5454
queue_time = current_time - timestamp
5555

56-
# Sanity check: queue time should be positive and reasonable (< 1 hour)
57-
if queue_time > 0 && queue_time < 3600
56+
# Sanity check: queue time should be positive
57+
if queue_time > 0
5858
return queue_time
5959
end
6060
rescue ArgumentError, TypeError

test/metrics/provider/async/http/server.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,6 @@
129129
server_task.stop
130130
end
131131

132-
it "ignores unreasonable queue times" do
133-
server_task = server.run
134-
bound_endpoint = server_task.wait_until_ready
135-
136-
# Timestamp from 2 hours ago (unreasonable)
137-
request_start = Process.clock_gettime(Process::CLOCK_REALTIME) - 7200
138-
139-
# Should not emit the queue time metric for unreasonable timestamp
140-
expect(Async::HTTP::Server::ASYNC_HTTP_SERVER_REQUEST_QUEUE_TIME).not.to receive(:emit)
141-
142-
client = Async::HTTP::Client.new(bound_endpoint)
143-
headers = [["x-request-start", "t=#{request_start}"]]
144-
response = client.get("/", headers)
145-
146-
expect(response.status).to be == 200
147-
response.finish
148-
149-
client.close
150-
server_task.stop
151-
end
152132
end
153133
end
154134

0 commit comments

Comments
 (0)