alacrity-rails 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alacrity-rails/transaction/web_transaction.rb +12 -4
- data/lib/alacrity-rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 827a7829337053744028ad86912540d8206f0799
|
4
|
+
data.tar.gz: 4299a493da2c76dc4a3b64a5ab554516d307c830
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d8d6e5953cc59819c130dbb76fb2590127857632c4dcb10c30b08c793cac231a466aff6faf64f22c01b2588fa4ac674a7cd88e8e299cc9d5624ee010ee7a776
|
7
|
+
data.tar.gz: 93a6661b8c65733873cfcf585538933b8ea939c6fc84a9d674ae483cb30f2f6be81913afb68ad25f3945270bf25524d4f71966b0a4ee4f1a15b8c8ea3ef45963
|
@@ -4,21 +4,22 @@ module AlacrityRails::Transaction
|
|
4
4
|
:method, :status, :view_runtime, :db_runtime, :framework_elapsed
|
5
5
|
|
6
6
|
def initialize(env={})
|
7
|
-
self.middleware_started_at =
|
7
|
+
self.middleware_started_at = absolute_time(DateTime.now)
|
8
8
|
self.url = ["#{env['rack.url_scheme']}://", env['HTTP_HOST'], env['REQUEST_PATH']].compact.join
|
9
9
|
self.method = env['REQUEST_METHOD']
|
10
10
|
end
|
11
11
|
|
12
12
|
def store_database_metrics(started_at, finished_at, data)
|
13
13
|
sql_queries << {
|
14
|
-
|
14
|
+
started_at: absolute_time(started_at.to_datetime),
|
15
|
+
finished_at: absolute_time(finished_at.to_datetime),
|
15
16
|
name: data[:name],
|
16
17
|
sql: data[:sql]
|
17
18
|
}
|
18
19
|
end
|
19
20
|
|
20
21
|
def store_request_metrics(started_at, finished_at, data)
|
21
|
-
self.framework_elapsed = (
|
22
|
+
self.framework_elapsed = absolute_time(finished_at.to_datetime) - absolute_time(started_at.to_datetime)
|
22
23
|
self.controller = data[:controller]
|
23
24
|
self.action = data[:action]
|
24
25
|
self.format = data[:format]
|
@@ -28,12 +29,15 @@ module AlacrityRails::Transaction
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def as_json(*args)
|
32
|
+
middleware_finished_at = absolute_time(DateTime.now)
|
31
33
|
{
|
32
34
|
environment: AlacrityRails::ServerConfig.environment,
|
33
35
|
url: url,
|
34
36
|
controller: controller,
|
35
37
|
action: action,
|
36
|
-
middleware_elapsed:
|
38
|
+
middleware_elapsed: middleware_finished_at - middleware_started_at,
|
39
|
+
middleware_started_at: middleware_started_at,
|
40
|
+
middleware_finished_at: middleware_finished_at,
|
37
41
|
framework_elapsed: framework_elapsed,
|
38
42
|
format: format,
|
39
43
|
method: method,
|
@@ -51,5 +55,9 @@ module AlacrityRails::Transaction
|
|
51
55
|
def sql_queries
|
52
56
|
@sql_queries ||= []
|
53
57
|
end
|
58
|
+
|
59
|
+
def absolute_time(datetime)
|
60
|
+
datetime.strftime('%Q').to_i
|
61
|
+
end
|
54
62
|
end
|
55
63
|
end
|