Skip to content

Commit c6307cf

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

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
require_relative "connection"
77

8+
require "traces/provider"
9+
810
module Async
911
module HTTP
1012
module Protocol
@@ -79,6 +81,20 @@ def call(request, task: Task.current)
7981
self.close(error)
8082
raise
8183
end
84+
85+
Traces::Provider(self) do
86+
def write_request(...)
87+
Traces.trace("async.http.protocol.http1.client.write_request") do
88+
super
89+
end
90+
end
91+
92+
def read_response(...)
93+
Traces.trace("async.http.protocol.http1.client.read_response") do
94+
super
95+
end
96+
end
97+
end
8298
end
8399
end
84100
end

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require_relative "connection"
77
require_relative "response"
88

9+
require "traces/provider"
910
require "protocol/http2/client"
1011

1112
module Async
@@ -34,10 +35,32 @@ def call(request)
3435
@count += 1
3536

3637
response = create_response
38+
write_request(response, request)
39+
read_response(response)
40+
41+
return response
42+
end
43+
44+
def write_request(response, request)
3745
response.send_request(request)
46+
end
47+
48+
def read_response(response)
3849
response.wait
50+
end
51+
52+
Traces::Provider(self) do
53+
def write_request(...)
54+
Traces.trace("async.http.protocol.http2.client.write_request") do
55+
super
56+
end
57+
end
3958

40-
return response
59+
def read_response(...)
60+
Traces.trace("async.http.protocol.http2.client.read_response") do
61+
super
62+
end
63+
end
4164
end
4265
end
4366
end

0 commit comments

Comments
 (0)