Skip to content

Commit 56748ff

Browse files
committed
Add client request tracing.
1 parent 6041cac commit 56748ff

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/async/http/protocol/http1/client.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ def call(request, task: Task.current)
7979
self.close(error)
8080
raise
8181
end
82+
83+
Traces::Provider(self) do
84+
def write_request(...)
85+
Traces.trace("async.http.protocol.http1.client.write_request") do
86+
super
87+
end
88+
end
89+
90+
def read_response(...)
91+
Traces.trace("async.http.protocol.http1.client.read_response") do
92+
super
93+
end
94+
end
95+
end
8296
end
8397
end
8498
end

lib/async/http/protocol/http2/client.rb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,32 @@ def call(request)
3434
@count += 1
3535

3636
response = create_response
37+
write_request(response, request)
38+
read_response(response)
39+
40+
return response
41+
end
42+
43+
def write_request(response, request)
3744
response.send_request(request)
45+
end
46+
47+
def read_response(response)
3848
response.wait
49+
end
50+
51+
Traces::Provider(self) do
52+
def write_request(...)
53+
Traces.trace("async.http.protocol.http2.client.write_request") do
54+
super
55+
end
56+
end
3957

40-
return response
58+
def read_response(...)
59+
Traces.trace("async.http.protocol.http2.client.read_response") do
60+
super
61+
end
62+
end
4163
end
4264
end
4365
end

0 commit comments

Comments
 (0)