rorvswild 0.0.4 → 0.0.5

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: ba08aa966ce2e82a89df73629d47a656d7616b84
4
- data.tar.gz: 669ffa2a6ba1e8ed508e9ad50b395bedaec0caf2
3
+ metadata.gz: 3a2d2980f4fa6ce04e070b58a75a97ab5e868a46
4
+ data.tar.gz: e6b6663445113ff35fd1d2010f52e20596f9ede5
5
5
  SHA512:
6
- metadata.gz: 4e4d2da8c004d341bc9cd89aedefa78f18126d7da392745a91abd80cf87f81f2c4e73a3a64db0fc775a7cd53dc02ff7aeb706f776d1f45e6c0b146d985eeb0d6
7
- data.tar.gz: 5945c84419fa4691d5eaeb619429b42415b32b065a62179cf50df9b2c453f6c30a52947847c9417b8d028ece5a00899c0fe5ca0bff5adc8179311e95ae94cca5
6
+ metadata.gz: dbb08c554a475c57d39ad6538f2eaf7b9cc8b1fa61898a47447a019f89a0de57ff8f9f9e6e7f9d668ba15ff42bddf9b5bcd7ae2ba7dc5b00990308df9108b67b
7
+ data.tar.gz: 952b87be7349323d78a57633974b77338ba8efc8fff7c06a94ea16508f25985bdf093f097d46bdb8c019ea373ad7c74e6d08e508a3b688dcf69031c9f413992c
data/README.md CHANGED
@@ -1,24 +1,10 @@
1
- # Rorvswild
1
+ # RorVsWild
2
2
 
3
- TODO: Write a gem description
3
+ Simple Ruby on Rails application monitoring for hardcore developers with no time to waste: http://www.rorvswild.com.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'rorvswild'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install rorvswild
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
7
+ Signup to http://www.rorvswild.com.
22
8
 
23
9
  ## Contributing
24
10
 
@@ -1,3 +1,3 @@
1
1
  class Rorvswild
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/rorvswild.rb CHANGED
@@ -27,17 +27,19 @@ module RorVsWild
27
27
  end
28
28
 
29
29
  def setup_callbacks
30
- ApplicationController.rescue_from(StandardError, &method(:after_exception))
31
30
  ActiveSupport::Notifications.subscribe("sql.active_record", &method(:after_sql_query))
32
31
  ActiveSupport::Notifications.subscribe("render_template.action_view", &method(:after_view_rendering))
33
32
  ActiveSupport::Notifications.subscribe("process_action.action_controller", &method(:after_http_request))
34
33
  ActiveSupport::Notifications.subscribe("start_processing.action_controller", &method(:before_http_request))
34
+
35
+ this = self
36
+ ApplicationController.rescue_from(StandardError) { |exception| this.after_exception(exception, self) }
35
37
  end
36
38
 
37
39
  def before_http_request(name, start, finish, id, payload)
38
40
  @request = {controller: payload[:controller], action: payload[:action], path: payload[:path]}
39
41
  @queries = []
40
- @views = []
42
+ @views = {}
41
43
  @error = nil
42
44
  end
43
45
 
@@ -45,7 +47,7 @@ module RorVsWild
45
47
  request[:db_runtime] = (payload[:db_runtime] || 0).round
46
48
  request[:view_runtime] = (payload[:view_runtime] || 0).round
47
49
  request[:other_runtime] = compute_duration(start, finish) - request[:db_runtime] - request[:view_runtime]
48
- request[:params] = params_filter.filter(payload[:params]) if error
50
+ error[:parameters] = filter_sensitive_data(payload[:params]) if error
49
51
  Thread.new { post_request }
50
52
  rescue => exception
51
53
  log_error(exception)
@@ -65,18 +67,29 @@ module RorVsWild
65
67
  end
66
68
 
67
69
  def after_view_rendering(name, start, finish, id, payload)
68
- views << {file: relative_path(payload[:identifier]), runtime: compute_duration(start, finish)} if views
70
+ if views
71
+ if view = views[file = relative_path(payload[:identifier])]
72
+ view[:runtime] += compute_duration(start, finish)
73
+ view[:times] += 1
74
+ else
75
+ views[file] = {file: file, runtime: compute_duration(start, finish), times: 1}
76
+ end
77
+ end
69
78
  end
70
79
 
71
- def after_exception(exception)
72
- file, line = exception.backtrace.first.split(":")
73
- @error = {
74
- exception: exception.class.to_s,
75
- backtrace: exception.backtrace,
76
- message: exception.message,
77
- file: relative_path(file),
78
- line: line.to_i
79
- }
80
+ def after_exception(exception, controller)
81
+ if !exception.is_a?(ActionController::RoutingError)
82
+ file, line = exception.backtrace.first.split(":")
83
+ @error = {
84
+ line: line.to_i,
85
+ file: relative_path(file),
86
+ message: exception.message,
87
+ backtrace: exception.backtrace,
88
+ exception: exception.class.to_s,
89
+ session: controller.session.to_hash,
90
+ environment_variables: filter_sensitive_data(filter_environment_variables(controller.request.env))
91
+ }
92
+ end
80
93
  raise exception
81
94
  end
82
95
 
@@ -95,7 +108,7 @@ module RorVsWild
95
108
  end
96
109
 
97
110
  def slowest_views
98
- views.sort { |h1, h2| h2[:runtime] <=> h1[:runtime] }[0, 25]
111
+ views.values.sort { |h1, h2| h2[:runtime] <=> h1[:runtime] }[0, 25]
99
112
  end
100
113
 
101
114
  def slowest_queries
@@ -130,7 +143,7 @@ module RorVsWild
130
143
  end
131
144
 
132
145
  def compute_duration(start, finish)
133
- ((finish - start) * 1000).round
146
+ ((finish - start) * 1000)
134
147
  end
135
148
 
136
149
  def relative_path(path)
@@ -148,8 +161,13 @@ module RorVsWild
148
161
  end
149
162
  end
150
163
 
151
- def params_filter
152
- @params_filter ||= ActionDispatch::Http::ParameterFilter.new(Rails.application.config.filter_parameters)
164
+ def filter_sensitive_data(hash)
165
+ @sensitive_filter ||= ActionDispatch::Http::ParameterFilter.new(Rails.application.config.filter_parameters)
166
+ @sensitive_filter.filter(hash)
167
+ end
168
+
169
+ def filter_environment_variables(hash)
170
+ hash.clone.keep_if { |key,value| key == key.upcase }
153
171
  end
154
172
 
155
173
  def logger
data/rorvswild.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Rorvswild::VERSION
9
9
  spec.authors = ["Alexis Bernard"]
10
10
  spec.email = ["alexis@bernard.io"]
11
- spec.summary = "RorVsWild tracks response time of Rails applications."
12
- spec.description = "RorVsWild helps to improve the response time, by pointing out any slow request, query and view."
11
+ spec.summary = "Simple Ruby on Rails application monitoring for hardcore developers with no time to waste."
12
+ spec.description = "RorVsWild points bottlenecks of your app and record errors."
13
13
  spec.homepage = "http://www.rorvswild.com"
14
14
  spec.license = "MIT"
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rorvswild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-25 00:00:00.000000000 Z
11
+ date: 2014-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,8 +24,7 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
- description: RorVsWild helps to improve the response time, by pointing out any slow
28
- request, query and view.
27
+ description: RorVsWild points bottlenecks of your app and record errors.
29
28
  email:
30
29
  - alexis@bernard.io
31
30
  executables: []
@@ -63,5 +62,6 @@ rubyforge_project:
63
62
  rubygems_version: 2.2.2
64
63
  signing_key:
65
64
  specification_version: 4
66
- summary: RorVsWild tracks response time of Rails applications.
65
+ summary: Simple Ruby on Rails application monitoring for hardcore developers with
66
+ no time to waste.
67
67
  test_files: []