File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
aws_sdk/test/opentelemetry/patches
net_http/test/opentelemetry/instrumentation/net/http Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 39
39
describe 'Lambda' do
40
40
let ( :service_name ) { 'Lambda' }
41
41
let ( :service_uri ) do
42
- 'https://lambda.us-east-1.amazonaws.com/2015-03-31/functions/ '
42
+ 'https://lambda.us-east-1.amazonaws.com/2015-03-31/functions'
43
43
end
44
44
let ( :client ) do
45
45
Aws ::Lambda ::Client . new (
82
82
83
83
it 'creates spans with all the non-stubbed parameters' do
84
84
skip unless TestHelper . telemetry_plugin? ( service_name )
85
- stub_request ( :get , 'https://lambda.us-east-1.amazonaws.com/2015-03-31/functions/ ' )
85
+ stub_request ( :get , 'https://lambda.us-east-1.amazonaws.com/2015-03-31/functions' )
86
86
87
87
client = Aws ::Lambda ::Client . new (
88
88
telemetry_provider : otel_provider ,
Original file line number Diff line number Diff line change 151
151
end
152
152
153
153
it 'does not create a span on connect when request ignored using a regexp' do
154
+ # this works because http://bazqux.com is reachable site; try http://asdfasdfsef.com will fail
154
155
uri = URI . parse ( 'http://bazqux.com' )
155
156
http = Net ::HTTP . new ( uri . host , uri . port )
156
157
http . send ( :connect )
169
170
it 'creates a span on connect for a non-ignored request' do
170
171
uri = URI . parse ( 'http://example.com' )
171
172
http = Net ::HTTP . new ( uri . host , uri . port )
172
- http . send ( :connect )
173
+
174
+ fake_socket = Object . new
175
+ def fake_socket . setsockopt ( *args ) ; end
176
+ def fake_socket . close ; end
177
+
178
+ # Replace the TCP socket creation with our fake socket
179
+ TCPSocket . stub ( :open , fake_socket ) do
180
+ http . send ( :connect )
181
+ end
182
+
173
183
http . send ( :do_finish )
174
184
_ ( exporter . finished_spans . size ) . must_equal 1
175
185
_ ( span . name ) . must_equal ( 'connect' )
199
209
OpenTelemetry ::Common ::Utilities . untraced do
200
210
uri = URI . parse ( 'http://example.com/body' )
201
211
http = Net ::HTTP . new ( uri . host , uri . port )
212
+
213
+ # Mock the connect
214
+ http . define_singleton_method ( :connect ) { true }
215
+
202
216
http . send ( :connect )
203
217
http . send ( :do_finish )
204
218
end
You can’t perform that action at this time.
0 commit comments