influxdb-rails 1.0.0.beta3 → 1.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,78 +0,0 @@
1
- require "spec_helper"
2
-
3
- RSpec.describe InfluxDB::Rails do
4
- before do
5
- InfluxDB::Rails.configure do |config|
6
- config.application_name = "my-rails-app"
7
- config.ignored_environments = []
8
- config.time_precision = "ms"
9
- end
10
- end
11
-
12
- describe ".current_timestamp" do
13
- let(:timestamp) { 1_513_009_229_111 }
14
-
15
- it "should return the current timestamp in the configured precision" do
16
- expect(Process).to receive(:clock_gettime)
17
- .with(Process::CLOCK_REALTIME, :millisecond)
18
- .and_return(timestamp)
19
-
20
- expect(InfluxDB::Rails.current_timestamp).to eq(timestamp)
21
- end
22
- end
23
-
24
- describe ".ignorable_exception?" do
25
- it "should be true for exception types specified in the configuration" do
26
- class DummyException < RuntimeError; end
27
- exception = DummyException.new
28
-
29
- InfluxDB::Rails.configure do |config|
30
- config.ignored_exceptions << "DummyException"
31
- end
32
-
33
- expect(InfluxDB::Rails.ignorable_exception?(exception)).to be_truthy
34
- end
35
-
36
- it "should be true for exception types specified in the configuration" do
37
- exception = ActionController::RoutingError.new("foo")
38
- expect(InfluxDB::Rails.ignorable_exception?(exception)).to be_truthy
39
- end
40
-
41
- it "should be false for valid exceptions" do
42
- exception = ZeroDivisionError.new
43
- expect(InfluxDB::Rails.ignorable_exception?(exception)).to be_falsey
44
- end
45
- end
46
-
47
- describe "rescue" do
48
- it "should transmit an exception when passed" do
49
- expect(InfluxDB::Rails.client).to receive(:write_point)
50
-
51
- InfluxDB::Rails.rescue do
52
- raise ArgumentError, "wrong"
53
- end
54
- end
55
-
56
- it "should also raise the exception when in an ignored environment" do
57
- InfluxDB::Rails.configure do |config|
58
- config.ignored_environments = %w[development test]
59
- end
60
-
61
- expect do
62
- InfluxDB::Rails.rescue do
63
- raise ArgumentError, "wrong"
64
- end
65
- end.to raise_error(ArgumentError)
66
- end
67
- end
68
-
69
- describe "rescue_and_reraise" do
70
- it "should transmit an exception when passed" do
71
- expect(InfluxDB::Rails.client).to receive(:write_point)
72
-
73
- expect do
74
- InfluxDB::Rails.rescue_and_reraise { raise ArgumentError, "wrong" }
75
- end.to raise_error(ArgumentError)
76
- end
77
- end
78
- end