influxdb-rails 1.0.0.beta3 → 1.0.0.beta4

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/CHANGELOG.md +12 -10
  4. data/README.md +193 -168
  5. data/influxdb-rails.gemspec +13 -7
  6. data/lib/influxdb/rails/configuration.rb +88 -192
  7. data/lib/influxdb/rails/context.rb +19 -1
  8. data/lib/influxdb/rails/instrumentation.rb +4 -4
  9. data/lib/influxdb/rails/middleware/render_subscriber.rb +7 -0
  10. data/lib/influxdb/rails/middleware/request_subscriber.rb +22 -24
  11. data/lib/influxdb/rails/middleware/simple_subscriber.rb +12 -25
  12. data/lib/influxdb/rails/middleware/sql_subscriber.rb +7 -3
  13. data/lib/influxdb/rails/middleware/subscriber.rb +19 -8
  14. data/lib/influxdb/rails/railtie.rb +29 -32
  15. data/lib/influxdb/rails/version.rb +1 -1
  16. data/lib/influxdb-rails.rb +20 -81
  17. data/lib/rails/generators/influxdb/influxdb_generator.rb +1 -1
  18. data/lib/rails/generators/influxdb/templates/initializer.rb +39 -9
  19. data/sample-dashboard/Dockerfile +25 -0
  20. data/sample-dashboard/README.md +74 -0
  21. data/sample-dashboard/Rakefile +8 -0
  22. data/sample-dashboard/Ruby On Rails Performance (per Request).json +1053 -0
  23. data/sample-dashboard/Ruby On Rails Performance.json +2011 -0
  24. data/sample-dashboard/docker-compose.yml +33 -0
  25. data/sample-dashboard/provisioning/grafana-dashboards.yml +12 -0
  26. data/sample-dashboard/provisioning/grafana-datasource.yml +10 -0
  27. data/sample-dashboard/provisioning/performance-request.json +1053 -0
  28. data/sample-dashboard/provisioning/performance.json +2011 -0
  29. data/spec/integration/metrics_spec.rb +12 -13
  30. data/spec/shared_examples/data.rb +61 -0
  31. data/spec/spec_helper.rb +3 -1
  32. data/spec/support/rails4/app.rb +4 -0
  33. data/spec/support/rails5/app.rb +4 -0
  34. data/spec/unit/configuration_spec.rb +47 -65
  35. data/spec/unit/middleware/render_subscriber_spec.rb +13 -9
  36. data/spec/unit/middleware/request_subscriber_spec.rb +33 -21
  37. data/spec/unit/middleware/sql_subscriber_spec.rb +35 -8
  38. metadata +42 -30
  39. data/lib/influxdb/rails/air_traffic_controller.rb +0 -41
  40. data/lib/influxdb/rails/backtrace.rb +0 -44
  41. data/lib/influxdb/rails/exception_presenter.rb +0 -94
  42. data/lib/influxdb/rails/logger.rb +0 -16
  43. data/lib/influxdb/rails/middleware/hijack_render_exception.rb +0 -16
  44. data/lib/influxdb/rails/middleware/hijack_rescue_action_everywhere.rb +0 -31
  45. data/lib/influxdb/rails/rack.rb +0 -24
  46. data/spec/integration/exceptions_spec.rb +0 -37
  47. data/spec/shared_examples/tags.rb +0 -42
  48. data/spec/unit/backtrace_spec.rb +0 -85
  49. data/spec/unit/exception_presenter_spec.rb +0 -23
  50. data/spec/unit/influxdb_rails_spec.rb +0 -78
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta3
4
+ version: 1.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
- - Dominik Menke
8
- - Todd Persen
7
+ - Christian Bruckmayer
8
+ - Henne Vogelsang
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-07 00:00:00.000000000 Z
12
+ date: 2019-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: influxdb
@@ -87,6 +87,20 @@ dependencies:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
+ - !ruby/object:Gem::Dependency
91
+ name: pry
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
90
104
  - !ruby/object:Gem::Dependency
91
105
  name: rake
92
106
  requirement: !ruby/object:Gem::Requirement
@@ -161,16 +175,16 @@ dependencies:
161
175
  name: sqlite3
162
176
  requirement: !ruby/object:Gem::Requirement
163
177
  requirements:
164
- - - ">="
178
+ - - '='
165
179
  - !ruby/object:Gem::Version
166
- version: '0'
180
+ version: 1.3.13
167
181
  type: :development
168
182
  prerelease: false
169
183
  version_requirements: !ruby/object:Gem::Requirement
170
184
  requirements:
171
- - - ">="
185
+ - - '='
172
186
  - !ruby/object:Gem::Version
173
- version: '0'
187
+ version: 1.3.13
174
188
  - !ruby/object:Gem::Dependency
175
189
  name: tzinfo
176
190
  requirement: !ruby/object:Gem::Requirement
@@ -185,11 +199,10 @@ dependencies:
185
199
  - - ">="
186
200
  - !ruby/object:Gem::Version
187
201
  version: '0'
188
- description: This gem automatically instruments your Ruby on Rails 4.2/5.x applications
189
- using InfluxDB for storage.
202
+ description: This gem instruments your Ruby on Rails application using InfluxDB.
190
203
  email:
191
- - dominik.menke@gmail.com
192
- - todd@influxdb.com
204
+ - christian@bruckmayer.net
205
+ - hvogel@hennevogel.de
193
206
  executables: []
194
207
  extensions: []
195
208
  extra_rdoc_files: []
@@ -210,42 +223,41 @@ files:
210
223
  - gemfiles/Gemfile.rails-5.2.x
211
224
  - influxdb-rails.gemspec
212
225
  - lib/influxdb-rails.rb
213
- - lib/influxdb/rails/air_traffic_controller.rb
214
- - lib/influxdb/rails/backtrace.rb
215
226
  - lib/influxdb/rails/configuration.rb
216
227
  - lib/influxdb/rails/context.rb
217
- - lib/influxdb/rails/exception_presenter.rb
218
228
  - lib/influxdb/rails/instrumentation.rb
219
- - lib/influxdb/rails/logger.rb
220
- - lib/influxdb/rails/middleware/hijack_render_exception.rb
221
- - lib/influxdb/rails/middleware/hijack_rescue_action_everywhere.rb
222
229
  - lib/influxdb/rails/middleware/render_subscriber.rb
223
230
  - lib/influxdb/rails/middleware/request_subscriber.rb
224
231
  - lib/influxdb/rails/middleware/simple_subscriber.rb
225
232
  - lib/influxdb/rails/middleware/sql_subscriber.rb
226
233
  - lib/influxdb/rails/middleware/subscriber.rb
227
- - lib/influxdb/rails/rack.rb
228
234
  - lib/influxdb/rails/railtie.rb
229
235
  - lib/influxdb/rails/sql/normalizer.rb
230
236
  - lib/influxdb/rails/sql/query.rb
231
237
  - lib/influxdb/rails/version.rb
232
238
  - lib/rails/generators/influxdb/influxdb_generator.rb
233
239
  - lib/rails/generators/influxdb/templates/initializer.rb
240
+ - sample-dashboard/Dockerfile
241
+ - sample-dashboard/README.md
242
+ - sample-dashboard/Rakefile
243
+ - sample-dashboard/Ruby On Rails Performance (per Request).json
244
+ - sample-dashboard/Ruby On Rails Performance.json
245
+ - sample-dashboard/docker-compose.yml
246
+ - sample-dashboard/provisioning/grafana-dashboards.yml
247
+ - sample-dashboard/provisioning/grafana-datasource.yml
248
+ - sample-dashboard/provisioning/performance-request.json
249
+ - sample-dashboard/provisioning/performance.json
234
250
  - spec/controllers/widgets_controller_spec.rb
235
- - spec/integration/exceptions_spec.rb
236
251
  - spec/integration/integration_helper.rb
237
252
  - spec/integration/metrics_spec.rb
238
- - spec/shared_examples/tags.rb
253
+ - spec/shared_examples/data.rb
239
254
  - spec/spec_helper.rb
240
255
  - spec/support/rails4/app.rb
241
256
  - spec/support/rails5/app.rb
242
257
  - spec/support/views/widgets/_item.html.erb
243
258
  - spec/support/views/widgets/index.html.erb
244
- - spec/unit/backtrace_spec.rb
245
259
  - spec/unit/configuration_spec.rb
246
260
  - spec/unit/context_spec.rb
247
- - spec/unit/exception_presenter_spec.rb
248
- - spec/unit/influxdb_rails_spec.rb
249
261
  - spec/unit/middleware/render_subscriber_spec.rb
250
262
  - spec/unit/middleware/request_subscriber_spec.rb
251
263
  - spec/unit/middleware/sql_subscriber_spec.rb
@@ -254,7 +266,11 @@ files:
254
266
  homepage: https://influxdata.com
255
267
  licenses:
256
268
  - MIT
257
- metadata: {}
269
+ metadata:
270
+ bug_tracker_uri: https://github.com/influxdata/influxdb-rails/issues
271
+ changelog_uri: https://github.com/influxdata/influxdb-rails/blob/master/CHANGELOG.md
272
+ documentation_uri: https://github.com/influxdata/influxdb-rails/blob/master/README.md
273
+ source_code_uri: https://github.com/influxdata/influxdb-rails
258
274
  post_install_message:
259
275
  rdoc_options: []
260
276
  require_paths:
@@ -276,20 +292,16 @@ specification_version: 4
276
292
  summary: InfluxDB bindings for Ruby on Rails.
277
293
  test_files:
278
294
  - spec/controllers/widgets_controller_spec.rb
279
- - spec/integration/exceptions_spec.rb
280
295
  - spec/integration/integration_helper.rb
281
296
  - spec/integration/metrics_spec.rb
282
- - spec/shared_examples/tags.rb
297
+ - spec/shared_examples/data.rb
283
298
  - spec/spec_helper.rb
284
299
  - spec/support/rails4/app.rb
285
300
  - spec/support/rails5/app.rb
286
301
  - spec/support/views/widgets/_item.html.erb
287
302
  - spec/support/views/widgets/index.html.erb
288
- - spec/unit/backtrace_spec.rb
289
303
  - spec/unit/configuration_spec.rb
290
304
  - spec/unit/context_spec.rb
291
- - spec/unit/exception_presenter_spec.rb
292
- - spec/unit/influxdb_rails_spec.rb
293
305
  - spec/unit/middleware/render_subscriber_spec.rb
294
306
  - spec/unit/middleware/request_subscriber_spec.rb
295
307
  - spec/unit/middleware/sql_subscriber_spec.rb
@@ -1,41 +0,0 @@
1
- module InfluxDB
2
- module Rails
3
- module AirTrafficController # :nodoc:
4
- def influxdb_request_data # rubocop:disable Metrics/MethodLength
5
- {
6
- params: influxdb_filtered_params,
7
- session_data: influxdb_session_data,
8
- controller: params[:controller],
9
- action: params[:action],
10
- request_url: influxdb_request_url,
11
- user_agent: request.env["HTTP_USER_AGENT"],
12
- remote_ip: request.remote_ip,
13
- referer: request.referer,
14
- current_user: (current_user rescue nil),
15
- }
16
- end
17
-
18
- private
19
-
20
- def influxdb_session_data
21
- session.respond_to?(:to_hash) ? session.to_hash : session.data
22
- end
23
-
24
- def influxdb_request_url
25
- url = "#{request.protocol}#{request.host}"
26
- url << ":#{request.port}" unless [80, 443].include?(request.port)
27
- url << request.fullpath
28
- end
29
-
30
- def influxdb_filtered_params
31
- if respond_to?(:filter_parameters)
32
- filter_parameters(unfiltered_params)
33
- elsif defined?(request.filtered_parameters)
34
- request.filtered_parameters
35
- else
36
- params.to_hash.except(:password, :password_confirmation)
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,44 +0,0 @@
1
- module InfluxDB
2
- module Rails
3
- class Backtrace # rubocop:disable Style/Documentation
4
- class Line # rubocop:disable Style/Documentation
5
- FORMAT = /^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$/.freeze
6
-
7
- attr_reader :file
8
- attr_reader :number
9
- attr_reader :method
10
-
11
- def initialize(line)
12
- _, @file, @number, @method = line.match(FORMAT).to_a
13
- end
14
-
15
- def to_s
16
- "#{file}:#{number} in `#{method}'"
17
- end
18
-
19
- def inspect
20
- "<Line: #{to_s}>" # rubocop:disable Lint/StringConversionInInterpolation
21
- end
22
- end
23
-
24
- attr_reader :lines
25
-
26
- def initialize(backtrace)
27
- @lines = Array(backtrace).each.collect do |line|
28
- InfluxDB::Rails.configuration.backtrace_filters.each do |filter|
29
- line = filter.call(line)
30
- end
31
- Line.new(line)
32
- end
33
- end
34
-
35
- def to_a
36
- lines.map(&:to_s)
37
- end
38
-
39
- def inspect
40
- "<Backtrace: " + lines.collect(&:to_s).join(", ") + ">"
41
- end
42
- end
43
- end
44
- end
@@ -1,94 +0,0 @@
1
- require "base64"
2
- require "socket"
3
- require "json"
4
-
5
- module InfluxDB
6
- module Rails
7
- class ExceptionPresenter # rubocop:disable Style/Documentation
8
- attr_reader :exception
9
- attr_reader :backtrace
10
- attr_reader :params
11
- attr_reader :session_data
12
- attr_reader :current_user
13
- attr_reader :controller
14
- attr_reader :action
15
- attr_reader :request_url
16
- attr_reader :referer
17
- attr_reader :remote_ip
18
- attr_reader :user_agent
19
- attr_reader :custom_data
20
-
21
- def initialize(ex, params = {})
22
- ex = ex.continued_exception if ex.respond_to?(:continued_exception)
23
- ex = ex.original_exception if ex.respond_to?(:original_exception)
24
-
25
- @exception = ex.is_a?(String) ? Exception.new(ex) : ex
26
- @backtrace = InfluxDB::Rails::Backtrace.new(@exception.backtrace)
27
- @dimensions = {}
28
- configure_from_params(params)
29
-
30
- @environment_variables = ENV.to_hash || {}
31
- end
32
-
33
- def context # rubocop:disable Metrics/MethodLength
34
- c = {
35
- application_name: InfluxDB::Rails.configuration.application_name,
36
- application_root: InfluxDB::Rails.configuration.application_root,
37
- framework: InfluxDB::Rails.configuration.framework,
38
- framework_version: InfluxDB::Rails.configuration.framework_version,
39
- language: "Ruby",
40
- language_version: "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}",
41
- custom_data: @custom_data,
42
- }
43
-
44
- InfluxDB::Rails.configuration.add_custom_exception_data(self)
45
- c
46
- end
47
-
48
- def dimensions
49
- {
50
- class: @exception.class.to_s,
51
- method: "#{@controller}##{@action}",
52
- filename: File.basename(@backtrace.lines.first.try(:file)),
53
- server: Socket.gethostname,
54
- status: "open",
55
- }.merge(@dimensions)
56
- end
57
-
58
- def values
59
- {
60
- exception_message: @exception.message,
61
- exception_backtrace: JSON.generate(@backtrace.to_a),
62
- }
63
- end
64
-
65
- def request_data
66
- {
67
- params: @params,
68
- session_data: @session_data,
69
- controller: @controller,
70
- action: @action,
71
- request_url: @request_url,
72
- referer: @referer,
73
- remote_ip: @remote_ip,
74
- user_agent: @user_agent,
75
- }
76
- end
77
-
78
- private
79
-
80
- def configure_from_params(params)
81
- @params = params[:params]
82
- @session_data = params[:session_data] || {}
83
- @current_user = params[:current_user]
84
- @controller = params[:controller]
85
- @action = params[:action]
86
- @request_url = params[:request_url]
87
- @user_agent = params[:user_agent]
88
- @referer = params[:referer]
89
- @remote_ip = params[:remote_ip]
90
- @custom_data = params[:custom_data] || {}
91
- end
92
- end
93
- end
94
- end
@@ -1,16 +0,0 @@
1
- module InfluxDB
2
- module Rails
3
- module Logger # rubocop:disable Style/Documentation
4
- PREFIX = "[InfluxDB::Rails] ".freeze
5
-
6
- private
7
-
8
- def log(level, message)
9
- c = InfluxDB::Rails.configuration
10
- return if level != :error && !c.debug?
11
-
12
- c.logger&.send(level, PREFIX + message)
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- module InfluxDB
2
- module Rails
3
- module Middleware
4
- module HijackRenderException # rubocop:disable Style/Documentation
5
- def render_exception(env, ex)
6
- controller = env["action_controller.instance"] || env.controller_instance
7
- request_data = controller.try(:influxdb_request_data) || {}
8
- unless InfluxDB::Rails.configuration.ignore_user_agent?(request_data[:user_agent])
9
- InfluxDB::Rails.report_exception_unless_ignorable(ex, request_data)
10
- end
11
- super
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,31 +0,0 @@
1
- module InfluxDB
2
- module Rails
3
- module Middleware
4
- module HijackRescueActionEverywhere # rubocop:disable Style/Documentation
5
- def self.included(base)
6
- base.send(:alias_method_chain, :rescue_action_in_public, :influxdb)
7
- base.send(:alias_method_chain, :rescue_action_locally, :influxdb)
8
- end
9
-
10
- private
11
-
12
- def rescue_action_in_public_with_influxdb(ex)
13
- handle_exception(ex)
14
- rescue_action_in_public_without_influxdb(ex)
15
- end
16
-
17
- def rescue_action_locally_with_influxdb(ex)
18
- handle_exception(ex)
19
- rescue_action_locally_without_influxdb(ex)
20
- end
21
-
22
- def handle_exception(ex)
23
- request_data = influxdb_request_data || {}
24
- return if InfluxDB::Rails.configuration.ignore_user_agent?(request_data[:user_agent])
25
-
26
- InfluxDB::Rails.report_exception_unless_ignorable(ex, request_data)
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,24 +0,0 @@
1
- module InfluxDB
2
- module Rails
3
- class Rack # rubocop:disable Style/Documentation
4
- def initialize(app)
5
- @app = app
6
- end
7
-
8
- def call(env)
9
- dup._call(env)
10
- end
11
-
12
- def _call(env)
13
- begin
14
- response = @app.call(env)
15
- rescue StandardError => e
16
- InfluxDB::Rails.transmit_unless_ignorable(e, env)
17
- raise(e)
18
- end
19
-
20
- response
21
- end
22
- end
23
- end
24
- end
@@ -1,37 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/integration_helper")
2
-
3
- RSpec.describe "exception handling", type: :request do
4
- before do
5
- InfluxDB::Rails.configure do |config|
6
- config.ignored_environments = %w[development]
7
- config.instrumentation_enabled = false
8
- end
9
- end
10
-
11
- describe "in an action that raises an exception" do
12
- it "should add an exception to the queue" do
13
- expect(InfluxDB::Rails.client).to receive(:write_point)
14
- get "/widgets/new"
15
- end
16
- end
17
-
18
- describe "in an action that does not raise an exception" do
19
- it "should not add anything to the queue" do
20
- expect(InfluxDB::Rails.client).not_to receive(:write_point)
21
- get "/widgets"
22
- end
23
- end
24
-
25
- describe "for an ignored user agent" do
26
- it "should not make an HTTP call to the API" do
27
- expect(InfluxDB::Rails.client).not_to receive(:write_point)
28
-
29
- # note: GoogleBot is ignored by default
30
- if Rails::VERSION::MAJOR >= 5
31
- get "/widgets/new", headers: { "HTTP_USER_AGENT" => "GoogleBot/2.1" }
32
- else
33
- get "/widgets/new", {}, "HTTP_USER_AGENT" => "GoogleBot/2.1"
34
- end
35
- end
36
- end
37
- end
@@ -1,42 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.shared_examples_for "with additional tags" do |series_names|
4
- context "when tags_middleware is overwritten" do
5
- before do
6
- allow(config).to receive(:tags_middleware).and_return(tags_middleware)
7
- end
8
-
9
- let(:tags_middleware) { ->(tags) { tags.merge(static: "value") } }
10
-
11
- it "processes tags throught the middleware" do
12
- tags = data[:tags].merge(static: "value")
13
-
14
- series_names.each do |series_name|
15
- expect_any_instance_of(InfluxDB::Client).to receive(:write_point).with(series_name, include(tags: tags))
16
- end
17
-
18
- subject.call("unused", start, finish, "unused", payload)
19
- end
20
- end
21
-
22
- context "when tags are set in the current context" do
23
- let(:additional_tags) do
24
- { another: :value }
25
- end
26
-
27
- after do
28
- InfluxDB::Rails.current.reset
29
- end
30
-
31
- it "does include the tags" do
32
- InfluxDB::Rails.current.tags = additional_tags
33
- tags = data[:tags].merge(additional_tags)
34
-
35
- series_names.each do |series_name|
36
- expect_any_instance_of(InfluxDB::Client).to receive(:write_point).with(series_name, include(tags: tags))
37
- end
38
-
39
- subject.call("unused", start, finish, "unused", payload)
40
- end
41
- end
42
- end
@@ -1,85 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe InfluxDB::Rails::Backtrace do
4
- before do
5
- @raw_backtrace = [
6
- "/var/www/current/app/models/foo.rb:10:in `bar'",
7
- "/var/www/current/app/models/foo.rb:19:in `baz'",
8
- "/var/www/current/app/models/foo.rb:32:in `<main>'"
9
- ]
10
-
11
- @backtrace = InfluxDB::Rails::Backtrace.new(@raw_backtrace)
12
- end
13
-
14
- it "should accept an exception into the initializer" do
15
- expect(@backtrace.lines).not_to be_empty
16
- expect(@backtrace.lines.count).to eq(3)
17
- end
18
-
19
- it "should correctly parse lines into their elements" do
20
- line = @backtrace.lines.first
21
-
22
- expect(line.file).to eq("/var/www/current/app/models/foo.rb")
23
- expect(line.number).to eq("10")
24
- expect(line.method).to eq("bar")
25
- end
26
-
27
- describe "#to_a" do
28
- it "should return an array of lines" do
29
- expect(@backtrace.to_a.is_a?(Array)).to be_truthy
30
- end
31
- end
32
-
33
- context "nil backtrace" do
34
- before do
35
- @raw_backtrace = nil
36
- @backtrace = InfluxDB::Rails::Backtrace.new(@raw_backtrace)
37
- end
38
-
39
- it "should accept an exception into the initializer" do
40
- expect(@backtrace.lines).to be_empty
41
- expect(@backtrace.lines.count).to eq(0)
42
- end
43
-
44
- describe "#to_a" do
45
- it "should return an array of lines" do
46
- expect(@backtrace.to_a.is_a?(Array)).to be_truthy
47
- end
48
- end
49
- end
50
-
51
- describe "backtrace filters" do
52
- before do
53
- InfluxDB::Rails.configure do |config|
54
- config.application_root = "/var/www/current"
55
- end
56
- end
57
-
58
- it "should apply a single default backtrace filter correctly" do
59
- filtered_backtrace = InfluxDB::Rails::Backtrace.new(@raw_backtrace)
60
-
61
- line = filtered_backtrace.lines.first
62
- expect(line.file).to eq("[APP_ROOT]/app/models/foo.rb")
63
- end
64
-
65
- it "should all default backtrace filters correctly" do
66
- extended_backtrace = @raw_backtrace.dup
67
- extended_backtrace << "#{Gem.path.first}/lib/foo_gem.rb:1:in `blah'"
68
-
69
- filtered_backtrace = InfluxDB::Rails::Backtrace.new(extended_backtrace)
70
- expect(filtered_backtrace.lines.first.file).to eq("[APP_ROOT]/app/models/foo.rb")
71
- expect(filtered_backtrace.lines.last.file).to eq("[GEM_ROOT]/lib/foo_gem.rb")
72
- end
73
-
74
- it "should allow the addition of custom backtrace filters" do
75
- InfluxDB::Rails.configure do |config|
76
- config.backtrace_filters << ->(line) { line.gsub(/foo/, "F00") }
77
- end
78
-
79
- filtered_backtrace = InfluxDB::Rails::Backtrace.new(@raw_backtrace)
80
-
81
- line = filtered_backtrace.lines.first
82
- expect(line.file).to eq("[APP_ROOT]/app/models/F00.rb")
83
- end
84
- end
85
- end
@@ -1,23 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe InfluxDB::Rails::ExceptionPresenter do
4
- before do
5
- begin
6
- 1 / 0
7
- rescue ZeroDivisionError => e
8
- @exception = e
9
- end
10
- end
11
-
12
- describe ".new" do
13
- it "should create a new ExceptionPresenter" do
14
- exception_presenter = InfluxDB::Rails::ExceptionPresenter.new(@exception)
15
- expect(exception_presenter).to be_a(InfluxDB::Rails::ExceptionPresenter)
16
- end
17
-
18
- it "should accept an exception as a parameter" do
19
- exception_presenter = InfluxDB::Rails::ExceptionPresenter.new(@exception)
20
- expect(exception_presenter).not_to be_nil
21
- end
22
- end
23
- end