alacrity-rails 0.0.8 → 0.0.9

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: 6cfa12e649a908631b3fb7e05fadd088fc78af97
4
- data.tar.gz: 111589f6778affdb78dd23fb1e67689b5a04660a
3
+ metadata.gz: 9e0905f6bbd861ebf97783070f3b4161dea9385a
4
+ data.tar.gz: 3e2f3c2231a50201de27ca820205a272a05abdae
5
5
  SHA512:
6
- metadata.gz: 48d6128dc65556f70752c40b210a64661d4a82eb929622cf1b42bacf96106240e76dca332d19f51c2bcad9716065e03c8e90f6e94dd572639387f3cc8ba920d9
7
- data.tar.gz: 2269b07db68683233b1a8a10ca690505f992188a487047287b2d972275676e491c228fc2109f1d9b067a6474d10c4e1fb74db2f5f284f628f2df13de233ee9be
6
+ metadata.gz: 10901c3626bf83314461043e7733ad07198bf7b4fbf9567aea8015b20bc74264e34e421c918239cc8b3e6a6a1e1d38f1cc4aeee30dbd9907063e1c4b6b059aeb
7
+ data.tar.gz: f08182386abb3804c87c6442fee7b0beb3561f97860a20f46d4254c1560690ceca502f09e55e219841dd3f3ed3c1e892d07245427420ff769d33749914228ab8
@@ -17,6 +17,14 @@ module AlacrityRails
17
17
  end
18
18
  end
19
19
 
20
+ def self.store_serializer_metrics(started_at, ended_at, data)
21
+ transaction&.store_serializer_metrics(started_at, ended_at, data)
22
+ end
23
+
24
+ def self.store_template_metrics(started_at, ended_at, data)
25
+ transaction&.store_template_metrics(started_at, ended_at, data)
26
+ end
27
+
20
28
  def self.close_transaction!
21
29
  this_transaction = transaction
22
30
  Thread.new { transmit(this_transaction) }
@@ -17,6 +17,14 @@ module AlacrityRails
17
17
  if defined?(Mongo)
18
18
  Mongo::Monitoring::Global.subscribe(Mongo::Monitoring::COMMAND, AlacrityRails::Probe::MongoDriver.new)
19
19
  end
20
+
21
+ ActiveSupport::Notifications.subscribe 'render.active_model_serializers' do |name, started, finished, unique_id, data|
22
+ AlacrityRails::Client.store_serializer_metrics(started, finished, data)
23
+ end
24
+
25
+ ActiveSupport::Notifications.subscribe 'render_partial.action_view' do |name, started, finished, unique_id, data|
26
+ AlacrityRails::Client.store_template_metrics(started, finished, data)
27
+ end
20
28
  end
21
29
  end
22
30
  end
@@ -27,6 +27,22 @@ module AlacrityRails::Transaction
27
27
  self.status = data[:status]
28
28
  end
29
29
 
30
+ def store_serializer_metrics(started_at, finished_at, data)
31
+ templates << {
32
+ started_at: absolute_time(started_at.to_datetime),
33
+ finished_at: absolute_time(finished_at.to_datetime),
34
+ name: data[:serializer]
35
+ }
36
+ end
37
+
38
+ def store_template_metrics(started_at, finished_at, data)
39
+ templates << {
40
+ started_at: absolute_time(started_at.to_datetime),
41
+ finished_at: absolute_time(finished_at.to_datetime),
42
+ name: data[:identifier]
43
+ }
44
+ end
45
+
30
46
  def as_json(*args)
31
47
  middleware_finished_at = absolute_time(DateTime.now)
32
48
  {
@@ -42,7 +58,8 @@ module AlacrityRails::Transaction
42
58
  format: format,
43
59
  method: method,
44
60
  status: status,
45
- sql_queries: sql_queries
61
+ sql_queries: sql_queries,
62
+ templates: templates
46
63
  }
47
64
  end
48
65
 
@@ -54,6 +71,10 @@ module AlacrityRails::Transaction
54
71
  @sql_queries ||= []
55
72
  end
56
73
 
74
+ def templates
75
+ @templates ||= []
76
+ end
77
+
57
78
  def absolute_time(datetime)
58
79
  datetime.strftime('%Q').to_i
59
80
  end
@@ -1,3 +1,3 @@
1
1
  module AlacrityRails
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alacrity-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alacrity, LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-31 00:00:00.000000000 Z
11
+ date: 2017-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails