rorvswild 1.3.5 → 1.4.0

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: 6fa8ad571e7bfbc2e32974d05a6a59b2b5c97d78
4
- data.tar.gz: 2e776641780937e3f20905ca04f512ff8975e2cb
3
+ metadata.gz: 866713e4d2ad9b6e923ad8c3f79956191003b5b3
4
+ data.tar.gz: 4e9cc4c5fb4aab0b795775ecf169263f5ceec711
5
5
  SHA512:
6
- metadata.gz: 69731604ed10210a7fcc55f1d8e1e87743038065567ab4bb65dc2b17be7657be9dc8fda8758e90988788c76a3cd07ad60b45cdc6d98b6a912bb8f8466d0d1605
7
- data.tar.gz: 87a73a718cfa90314e797b77d30e40c7eb4a8a2cf6e1a03826874e6ccc1c401849e8592d7856e6c8e89cd91892b4954188343ebde66cb6b9fd2f68684c4e621e
6
+ metadata.gz: 6d4b4e2f4e07bb9a60e57a5761ee3bc0673131a259b6feec00df78291eb06d2279da5badced799861eb7c40188daa91c6a3a97a3de0bde3777fbcd0aaa4cc74e
7
+ data.tar.gz: d6a7be8a7e745141cd7681455aadfe695c290bedb73ef1644552684a3f6845037ad66b18932fdf042444802bda498f2f85c247bdd476971f452a478f02e91420
data/README.md CHANGED
@@ -120,15 +120,17 @@ RorVsWild.record_error(exception, {something: "important"})
120
120
  RorVsWild.catch_error(something: "important") { 1 / 0 }
121
121
  ```
122
122
 
123
- #### Ignore exceptions
123
+ #### Ignore endpoints and exceptions
124
124
 
125
- By using the ignored_exceptions parameter you can prevent *RoRvsWild* from recording specific exceptions.
125
+ By using `ignore_actions` you can prevent from tracking specific endpoints. In the same idea you can prevent from recording specific exceptions with the `ignore_exceptions` config.
126
126
 
127
127
  ```yaml
128
128
  # config/rorvswild.yml
129
129
  production:
130
130
  api_key: API_KEY
131
- ignored_exceptions:
131
+ ignore_actions:
132
+ - SecretController#index
133
+ ignore_exceptions:
132
134
  - ActionController::RoutingError
133
135
  - ZeroDivisionError
134
136
  ```
@@ -137,7 +139,8 @@ production:
137
139
  # config/initializers/rorvswild.rb
138
140
  RorVsWild.start(
139
141
  api_key: "API_KEY",
140
- ignored_exceptions: ["ActionController::RoutingError", "ZeroDivisionError"])
142
+ ignore_actions: ["SecretController#index"],
143
+ ignore_exceptions: ["ActionController::RoutingError", "ZeroDivisionError"])
141
144
  ```
142
145
 
143
146
  By default ActionController::RoutingError is ignored in order to not be flooded with 404.
@@ -7,32 +7,33 @@ module RorVsWild
7
7
  def self.default_config
8
8
  {
9
9
  api_url: "https://www.rorvswild.com/api/v1",
10
- ignored_exceptions: [],
10
+ ignore_exceptions: default_ignored_exceptions,
11
+ ignore_actions: [],
11
12
  }
12
13
  end
13
14
 
14
- attr_reader :api_url, :api_key, :app_id, :app_root, :ignored_exceptions
15
+ def self.default_ignored_exceptions
16
+ if defined?(Rails)
17
+ %w[ActionController::RoutingError] + Rails.application.config.action_dispatch.rescue_responses.map { |(key,value)| key }
18
+ else
19
+ []
20
+ end
21
+ end
15
22
 
16
- attr_reader :app_root_regex, :client, :queue
23
+ attr_reader :config, :app_root, :app_root_regex, :client, :queue
17
24
 
18
25
  def initialize(config)
19
- config = self.class.default_config.merge(config)
20
- @ignored_exceptions = config[:ignored_exceptions]
21
- @app_root = config[:app_root]
22
- @client = Client.new(config)
26
+ @config = self.class.default_config.merge(config)
27
+ @client = Client.new(@config)
23
28
  @queue = config[:queue] || Queue.new(client)
24
- cleanup_data
25
-
26
- if defined?(Rails)
27
- @app_root ||= Rails.root.to_s
28
- config = Rails.application.config
29
- @ignored_exceptions ||= %w[ActionController::RoutingError] + config.action_dispatch.rescue_responses.map { |(key,value)| key }
30
- end
31
29
 
30
+ @app_root = config[:app_root]
31
+ @app_root ||= Rails.root.to_s if defined?(Rails)
32
32
  @app_root_regex = app_root ? /\A#{app_root}/ : nil
33
33
 
34
34
  RorVsWild.logger.info("Start RorVsWild #{RorVsWild::VERSION} from #{app_root}")
35
35
  setup_plugins
36
+ cleanup_data
36
37
  end
37
38
 
38
39
  def setup_plugins
@@ -134,6 +135,10 @@ module RorVsWild
134
135
  end
135
136
  end
136
137
 
138
+ def ignored_action?(name)
139
+ config[:ignore_actions].include?(name)
140
+ end
141
+
137
142
  #######################
138
143
  ### Private methods ###
139
144
  #######################
@@ -178,7 +183,7 @@ module RorVsWild
178
183
  end
179
184
 
180
185
  def ignored_exception?(exception)
181
- ignored_exceptions.include?(exception.class.to_s)
186
+ (config[:ignored_exceptions] || config[:ignore_exceptions]).include?(exception.class.to_s)
182
187
  end
183
188
  end
184
189
  end
@@ -19,9 +19,10 @@ module RorVsWild
19
19
  <<YAML
20
20
  production:
21
21
  api_key: #{api_key}
22
- # ignored_exceptions:
23
- # - ActionController::RoutingError
24
- # - UncommentToIgnoreAnyExceptionNameListedHere
22
+ ignore_actions: # Do not track following endpoints
23
+ # - SecretController#index
24
+ ignore_exceptions: # Do not track following exceptions
25
+ # - ActionController::RoutingError
25
26
  YAML
26
27
  end
27
28
  end
@@ -14,8 +14,8 @@ module RorVsWild
14
14
  end
15
15
 
16
16
  def standalone_profiler(env)
17
- html = "<!DOCTYPE html>\n<html><head></head><body></body></html>"
18
- [200, {"Content-Type:" => "text/html; charset=utf-8"}, StringIO.new(inject_into(html))]
17
+ html = inject_into(empty_html_page)
18
+ [200, {"Content-Type:" => "text/html; charset=utf-8"}, StringIO.new(html || empty_html_page)]
19
19
  end
20
20
 
21
21
  def embed_profiler(env)
@@ -44,6 +44,7 @@ module RorVsWild
44
44
  html
45
45
  rescue Encoding::UndefinedConversionError => ex
46
46
  log_incompatible_encoding_warning(ex)
47
+ nil
47
48
  end
48
49
 
49
50
  LOCAL_FOLDER = File.expand_path(File.dirname(__FILE__))
@@ -69,6 +70,10 @@ module RorVsWild
69
70
  files.map { |file| File.read(File.join(directory, file)) }.join("\n")
70
71
  end
71
72
 
73
+ def empty_html_page
74
+ "<!DOCTYPE html>\n<html><head></head><body></body></html>"
75
+ end
76
+
72
77
  def log_incompatible_middleware_warning
73
78
  RorVsWild.logger.warn("RorVsWild::Local cannot be embeded into your HTML page because of compression." +
74
79
  " Try to disable Rack::Deflater in development only." +
@@ -35,8 +35,9 @@ module RorVsWild
35
35
 
36
36
  # Payload: controller, action, params, format, method, path
37
37
  def start(name, id, payload)
38
- name = "#{payload[:controller]}##{payload[:action]}"
39
- RorVsWild.agent.start_request(name: name, path: payload[:path])
38
+ if !RorVsWild.agent.ignored_action?(name = "#{payload[:controller]}##{payload[:action]}")
39
+ RorVsWild.agent.start_request(name: name, path: payload[:path])
40
+ end
40
41
  end
41
42
 
42
43
  def finish(name, id, payload)
@@ -8,11 +8,11 @@ module RorVsWild
8
8
  ::Elasticsearch::Transport::Client.class_eval do
9
9
  alias_method :perform_request_without_rorvswild, :perform_request
10
10
 
11
- def perform_request(method, path, params={}, body=nil)
11
+ def perform_request(*args)
12
12
  RorVsWild::Plugin::NetHttp.ignore do
13
- command = {method: method, path: path, params: params, body: body}.to_json
13
+ command = {method: args[0], path: args[1], params: args[2], body: args[3]}.to_json
14
14
  RorVsWild.agent.measure_section(command, kind: "elasticsearch") do
15
- perform_request_without_rorvswild(method, path, params, body)
15
+ perform_request_without_rorvswild(*args)
16
16
  end
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module RorVsWild
2
- VERSION = "1.3.5".freeze
2
+ VERSION = "1.4.0".freeze
3
3
  end
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: 1.3.5
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-06-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Performances and quality insights for rails developers.
14
14
  email: