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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3968ffd0e1a310ad3a6b04ee5982e004ae974ca0
4
- data.tar.gz: f0f0e5a8aad60433a9566180108b52ffa30c64c1
3
+ metadata.gz: 827a7829337053744028ad86912540d8206f0799
4
+ data.tar.gz: 4299a493da2c76dc4a3b64a5ab554516d307c830
5
5
  SHA512:
6
- metadata.gz: 4ee36f7677e143f6f44bef3335f76d95ca80d23ad558414fbbb33670e3b1df76b5e089cf7c40cb2e94022d06ce3f771404d0c905cda97594f0edac3389b6adca
7
- data.tar.gz: 8a290bc13d0760c7bce88c45d7f5a674590be024a359313e9aa9b8b5d09afd3de8e5a69c80317e3ee1576f5ffa2ae3cbd442bef7994e68c209330b182ec4fbad
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 = Time.now
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
- statement_elapsed: ((finished_at - started_at) * 1000).to_i,
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 = ((finished_at - started_at) * 1000).to_i
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: ((Time.now - middleware_started_at) * 1000).to_i,
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
@@ -1,3 +1,3 @@
1
1
  module AlacrityRails
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alacrity-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alacrity, LLC