union_station_hooks_rails 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDBmNjQ1YWNkZDdjZjAwOTMzZWQ1NjEyZDBiOGZjYWJhMWYzMmM5Zg==
4
+ ZTI3YjEwNTE3MTBiMWIwNmY3N2MxN2QyNTc2OGI0OGFhZGFkODY3Ng==
5
5
  data.tar.gz: !binary |-
6
- NDEyNzgzMWJjMjdiMWFhNTkyMjUyZWQxNWY1Mzg4NGYwZDgzODE4OA==
6
+ NWVmMzI3NDdlYmEwMzVlMjFiY2Q3ZWI3MzIxNjQzN2JmNDNjZGEyNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDYzNzBiZjk4MmZhY2JhYmJkNGJjM2JiNWZjNWU5NTRkYjRiNmE5ZGY2ZmQw
10
- YmI3YzRhM2YxNzBjZWYzNWVhZmUwNjYzNDUxMTUzOGQ1MTQwMTY0OTI1ZjVj
11
- YTVkMWM4N2IzMTdlOGMzN2UzNjI1NmRjOTBiYzZlZGM1NDlhNmY=
9
+ MDRjNWQ5YjkyZWQ0ZTg5MzEyOTBkMTk0ZDZlZjc3OTRhYTFmMmU2ODllOGYx
10
+ MjU5MmM1N2QzYjM0NGViZjFkMjRiZTAxYmEyNGE3YzZhODdmOWJhM2FkNGVh
11
+ YTBkNjYzMTgyN2Q4Njc0ZTYxMDAyMGYzMWQwNDJkZTAzMzU2N2E=
12
12
  data.tar.gz: !binary |-
13
- MWQ2YzQ2ZWJkNWRiNTRmZDQ1NzE5NjFhZDk5YzRjNTZhMzNkODMwZGM3MzZl
14
- NDA0M2NiYzUyOGU2M2QxNGNkZGFhYmNkYzdmOTExNDY2MTBiZTJiMjFmNzgz
15
- MjI3MTM3OTA4MjlkMzFlOGUzODExMGQ0MGQ4ZTMyYjNjMjYxMGE=
13
+ Y2NiYWY5YzAwNWM4MzQ3MTg3YWQxMWM4MDVkMTM3MDFkYzk3MzZhZjU3N2Nl
14
+ ZjliY2Y2MTQxZjQ4ZTlhYzQ0NmM2ODM1NDA3OGFlYzZlOGI5YWYzZDMyZTgw
15
+ NjI2M2Q2ZmVmNTc3NjU1ZWE4MzkyNjllMjA0NzQ5ZjI4ODU5MTk=
@@ -92,6 +92,9 @@ module UnionStationHooksRails
92
92
  require_lib('initialize')
93
93
  require_lib('active_record_subscriber')
94
94
  require_lib('exception_logger')
95
+ if defined?(ActionView)
96
+ require_lib('action_view_subscriber')
97
+ end
95
98
  if defined?(ActiveSupport::Cache::Store)
96
99
  require_lib('active_support_cache_subscriber')
97
100
  end
@@ -153,12 +156,12 @@ module UnionStationHooksRails
153
156
 
154
157
  # If you update the dependency version here, also update
155
158
  # the version in the gemspec and in the Gemfile.
156
- compatible = UnionStationHooks::MAJOR_VERSION == 1 &&
159
+ compatible = UnionStationHooks::MAJOR_VERSION == 2 &&
157
160
  UnionStationHooks::MINOR_VERSION >= 0
158
161
  if !compatible
159
162
  raise "This version of the union_station_hooks_rails gem " \
160
163
  "(#{VERSION_STRING}) is only compatible with the " \
161
- "union_station_hooks_core gem 1.x.x. However, you have loaded " \
164
+ "union_station_hooks_core gem 2.x.x. However, you have loaded " \
162
165
  "union_station_hooks_core #{UnionStationHooks::VERSION_STRING}"
163
166
  end
164
167
  end
@@ -37,15 +37,6 @@ module UnionStationHooksRails
37
37
  super
38
38
  end
39
39
  end
40
-
41
- def render(*args)
42
- reporter = request.env['union_station_hooks']
43
- return super if !reporter
44
-
45
- reporter.log_view_rendering_block do
46
- super
47
- end
48
- end
49
40
  end
50
41
  end
51
42
 
@@ -0,0 +1,55 @@
1
+ # Union Station - https://www.unionstationapp.com/
2
+ # Copyright (c) 2015 Phusion Holding B.V.
3
+ #
4
+ # "Union Station" and "Passenger" are trademarks of Phusion Holding B.V.
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ # THE SOFTWARE.
23
+
24
+ module UnionStationHooksRails
25
+ class ActionViewSubscriber < ActiveSupport::LogSubscriber
26
+ def render_collection(event)
27
+ log_view_rendering(event)
28
+ end
29
+
30
+ def render_template(event)
31
+ log_view_rendering(event)
32
+ end
33
+
34
+ def render_partial(event)
35
+ log_view_rendering(event)
36
+ end
37
+
38
+ private
39
+
40
+ def log_view_rendering(event)
41
+ reporter = Thread.current[:union_station_hooks]
42
+ return if !reporter
43
+
44
+ UnionStationHooks.call_event_pre_hook(event)
45
+ reporter.log_view_rendering(
46
+ :begin_time => event.time,
47
+ :end_time => UnionStationHooks.now,
48
+ :name => event.payload[:identifier],
49
+ :has_error => event.payload[:exception]
50
+ )
51
+ end
52
+ end
53
+ end
54
+
55
+ UnionStationHooksRails::ActionViewSubscriber.attach_to(:action_view)
@@ -31,7 +31,7 @@ module UnionStationHooksRails
31
31
  UnionStationHooks.call_event_pre_hook(event)
32
32
  reporter.log_database_query(
33
33
  :begin_time => event.time,
34
- :end_time => event.time,
34
+ :end_time => UnionStationHooks.now,
35
35
  :query => event.payload[:sql]
36
36
  )
37
37
  end
@@ -37,8 +37,8 @@
37
37
  # here.
38
38
 
39
39
  {
40
- :major => 1,
40
+ :major => 2,
41
41
  :minor => 0,
42
42
  :tiny => 0,
43
- :string => '1.0.0'
43
+ :string => '2.0.0'
44
44
  }
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  # If you update the dependency version here, also update
22
22
  # the version in Gemfile and union_station_hooks_rails.rb method
23
23
  # `require_and_check_union_station_hooks_core`
24
- s.add_dependency("union_station_hooks_core", "~> 1.0")
24
+ s.add_dependency("union_station_hooks_core", "~> 2.0")
25
25
 
26
26
  s.add_dependency("activesupport", ">= 3.0")
27
27
  s.add_dependency("activemodel", ">= 3.0")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: union_station_hooks_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hongli Lai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: union_station_hooks_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +90,7 @@ files:
90
90
  - README.md
91
91
  - lib/union_station_hooks_rails.rb
92
92
  - lib/union_station_hooks_rails/action_controller_extension.rb
93
+ - lib/union_station_hooks_rails/action_view_subscriber.rb
93
94
  - lib/union_station_hooks_rails/active_record_subscriber.rb
94
95
  - lib/union_station_hooks_rails/active_support_benchmarkable_extension.rb
95
96
  - lib/union_station_hooks_rails/active_support_cache_subscriber.rb