20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/network_resiliency/adapter/mysql.rb', line 20
def connect(_, _, host, *args)
return super unless NetworkResiliency.enabled?(:mysql)
begin
ts = -NetworkResiliency.timestamp
super
rescue Mysql2::Error::TimeoutError => e
raise
ensure
ts += NetworkResiliency.timestamp
NetworkResiliency.record(
adapter: :mysql,
action: :connect,
destination: host,
error: e&.class,
duration: ts,
timeout: query_options[:connect_timeout].to_f * 1_000,
)
end
end
|