appsignal 2.1.0.alpha.3 → 2.1.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +43 -0
  4. data/.rubocop_todo.yml +289 -0
  5. data/.travis.yml +4 -0
  6. data/CHANGELOG.md +11 -1
  7. data/Gemfile +1 -1
  8. data/LICENSE +1 -1
  9. data/appsignal.gemspec +1 -0
  10. data/bin/appsignal +2 -2
  11. data/ext/agent.yml +11 -11
  12. data/ext/extconf.rb +33 -33
  13. data/gemfiles/rails-4.2.gemfile +4 -0
  14. data/gemfiles/resque.gemfile +4 -0
  15. data/lib/appsignal.rb +58 -54
  16. data/lib/appsignal/auth_check.rb +15 -16
  17. data/lib/appsignal/capistrano.rb +4 -4
  18. data/lib/appsignal/cli.rb +28 -28
  19. data/lib/appsignal/cli/diagnose.rb +11 -11
  20. data/lib/appsignal/cli/helpers.rb +1 -1
  21. data/lib/appsignal/cli/install.rb +38 -38
  22. data/lib/appsignal/cli/notify_of_deploy.rb +1 -1
  23. data/lib/appsignal/config.rb +73 -71
  24. data/lib/appsignal/event_formatter.rb +8 -8
  25. data/lib/appsignal/event_formatter/action_view/render_formatter.rb +4 -4
  26. data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +1 -1
  27. data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -1
  28. data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +9 -7
  29. data/lib/appsignal/event_formatter/faraday/request_formatter.rb +1 -1
  30. data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +6 -6
  31. data/lib/appsignal/event_formatter/moped/query_formatter.rb +56 -43
  32. data/lib/appsignal/extension.rb +5 -5
  33. data/lib/appsignal/hooks.rb +28 -26
  34. data/lib/appsignal/hooks/active_support_notifications.rb +2 -2
  35. data/lib/appsignal/hooks/celluloid.rb +1 -1
  36. data/lib/appsignal/hooks/data_mapper.rb +2 -2
  37. data/lib/appsignal/hooks/delayed_job.rb +1 -1
  38. data/lib/appsignal/hooks/mongo_ruby_driver.rb +1 -1
  39. data/lib/appsignal/hooks/net_http.rb +4 -4
  40. data/lib/appsignal/hooks/passenger.rb +2 -2
  41. data/lib/appsignal/hooks/puma.rb +4 -4
  42. data/lib/appsignal/hooks/rake.rb +1 -1
  43. data/lib/appsignal/hooks/redis.rb +1 -1
  44. data/lib/appsignal/hooks/sequel.rb +2 -2
  45. data/lib/appsignal/hooks/shoryuken.rb +8 -8
  46. data/lib/appsignal/hooks/sidekiq.rb +16 -15
  47. data/lib/appsignal/hooks/unicorn.rb +1 -1
  48. data/lib/appsignal/hooks/webmachine.rb +1 -1
  49. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +6 -6
  50. data/lib/appsignal/integrations/data_mapper.rb +2 -3
  51. data/lib/appsignal/integrations/delayed_job_plugin.rb +5 -5
  52. data/lib/appsignal/integrations/mongo_ruby_driver.rb +6 -6
  53. data/lib/appsignal/integrations/padrino.rb +8 -8
  54. data/lib/appsignal/integrations/railtie.rb +5 -5
  55. data/lib/appsignal/integrations/resque.rb +4 -5
  56. data/lib/appsignal/integrations/resque_active_job.rb +3 -6
  57. data/lib/appsignal/integrations/sinatra.rb +2 -2
  58. data/lib/appsignal/integrations/webmachine.rb +2 -3
  59. data/lib/appsignal/js_exception_transaction.rb +10 -10
  60. data/lib/appsignal/marker.rb +3 -3
  61. data/lib/appsignal/rack/generic_instrumentation.rb +10 -9
  62. data/lib/appsignal/rack/js_exception_catcher.rb +7 -6
  63. data/lib/appsignal/rack/rails_instrumentation.rb +9 -8
  64. data/lib/appsignal/rack/sinatra_instrumentation.rb +19 -17
  65. data/lib/appsignal/rack/streaming_listener.rb +9 -8
  66. data/lib/appsignal/system.rb +19 -17
  67. data/lib/appsignal/transaction.rb +97 -40
  68. data/lib/appsignal/transmitter.rb +23 -30
  69. data/lib/appsignal/utils.rb +3 -3
  70. data/lib/appsignal/utils/params_sanitizer.rb +1 -1
  71. data/lib/appsignal/utils/query_params_sanitizer.rb +1 -1
  72. data/lib/appsignal/version.rb +2 -2
  73. data/spec/.rubocop.yml +4 -0
  74. data/spec/lib/appsignal/auth_check_spec.rb +7 -7
  75. data/spec/lib/appsignal/capistrano2_spec.rb +41 -41
  76. data/spec/lib/appsignal/capistrano3_spec.rb +43 -44
  77. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +9 -11
  78. data/spec/lib/appsignal/cli_spec.rb +9 -9
  79. data/spec/lib/appsignal/config_spec.rb +88 -86
  80. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +9 -9
  81. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +4 -4
  82. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +4 -4
  83. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +12 -12
  84. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +4 -4
  85. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +23 -23
  86. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +29 -30
  87. data/spec/lib/appsignal/event_formatter_spec.rb +28 -28
  88. data/spec/lib/appsignal/extension_spec.rb +15 -15
  89. data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +6 -5
  90. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +12 -12
  91. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +34 -34
  92. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +3 -3
  93. data/spec/lib/appsignal/hooks/net_http_spec.rb +10 -10
  94. data/spec/lib/appsignal/hooks/rake_spec.rb +7 -7
  95. data/spec/lib/appsignal/hooks/redis_spec.rb +6 -6
  96. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +21 -22
  97. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +48 -45
  98. data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -2
  99. data/spec/lib/appsignal/hooks_spec.rb +16 -17
  100. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +7 -8
  101. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +19 -19
  102. data/spec/lib/appsignal/integrations/object_spec.rb +3 -3
  103. data/spec/lib/appsignal/integrations/padrino_spec.rb +44 -44
  104. data/spec/lib/appsignal/integrations/railtie_spec.rb +13 -13
  105. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +7 -7
  106. data/spec/lib/appsignal/integrations/resque_spec.rb +8 -8
  107. data/spec/lib/appsignal/integrations/sinatra_spec.rb +7 -7
  108. data/spec/lib/appsignal/integrations/webmachine_spec.rb +15 -15
  109. data/spec/lib/appsignal/js_exception_transaction_spec.rb +23 -23
  110. data/spec/lib/appsignal/marker_spec.rb +8 -8
  111. data/spec/lib/appsignal/minutely_spec.rb +6 -6
  112. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +7 -7
  113. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +13 -13
  114. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +11 -11
  115. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +21 -21
  116. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +36 -36
  117. data/spec/lib/appsignal/system/container_spec.rb +1 -1
  118. data/spec/lib/appsignal/transaction_spec.rb +213 -184
  119. data/spec/lib/appsignal/transmitter_spec.rb +20 -20
  120. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +19 -19
  121. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +41 -41
  122. data/spec/lib/appsignal/utils_spec.rb +41 -37
  123. data/spec/lib/appsignal_spec.rb +150 -142
  124. data/spec/spec_helper.rb +18 -18
  125. data/spec/support/delegate_matcher.rb +6 -6
  126. data/spec/support/helpers/api_request_helper.rb +2 -2
  127. data/spec/support/helpers/config_helpers.rb +3 -3
  128. data/spec/support/helpers/dependency_helper.rb +13 -13
  129. data/spec/support/helpers/directory_helper.rb +5 -5
  130. data/spec/support/helpers/env_helpers.rb +14 -14
  131. data/spec/support/helpers/system_helpers.rb +3 -3
  132. data/spec/support/helpers/transaction_helpers.rb +10 -10
  133. metadata +20 -2
@@ -2,18 +2,19 @@ describe Appsignal::Hooks::SidekiqPlugin do
2
2
  let(:worker) { double }
3
3
  let(:queue) { double }
4
4
  let(:current_transaction) { background_job_transaction }
5
- let(:item) {{
6
- 'class' => 'TestClass',
7
- 'retry_count' => 0,
8
- 'queue' => 'default',
9
- 'enqueued_at' => Time.parse('01-01-2001 10:00:00UTC'),
10
- 'args' => ['Model', 1],
11
- 'extra' => 'data'
12
- }}
5
+ let(:item) do
6
+ {
7
+ "class" => "TestClass",
8
+ "retry_count" => 0,
9
+ "queue" => "default",
10
+ "enqueued_at" => Time.parse("01-01-2001 10:00:00UTC"),
11
+ "args" => ["Model", 1],
12
+ "extra" => "data"
13
+ }
14
+ end
13
15
  let(:plugin) { Appsignal::Hooks::SidekiqPlugin.new }
14
16
 
15
17
  before do
16
- Appsignal.stub(:is_ignored_exception? => false)
17
18
  Appsignal::Transaction.stub(:current => current_transaction)
18
19
  start_agent
19
20
  end
@@ -21,54 +22,56 @@ describe Appsignal::Hooks::SidekiqPlugin do
21
22
  context "with a performance call" do
22
23
  it "should wrap in a transaction with the correct params" do
23
24
  Appsignal.should_receive(:monitor_transaction).with(
24
- 'perform_job.sidekiq',
25
- :class => 'TestClass',
26
- :method => 'perform',
25
+ "perform_job.sidekiq",
26
+ :class => "TestClass",
27
+ :method => "perform",
27
28
  :metadata => {
28
- 'retry_count' => "0",
29
- 'queue' => 'default',
30
- 'extra' => 'data'
29
+ "retry_count" => "0",
30
+ "queue" => "default",
31
+ "extra" => "data"
31
32
  },
32
- :params => ['Model', "1"],
33
- :queue_start => Time.parse('01-01-2001 10:00:00UTC'),
34
- :queue_time => 60000.to_f
33
+ :params => ["Model", "1"],
34
+ :queue_start => Time.parse("01-01-2001 10:00:00UTC"),
35
+ :queue_time => 60_000.to_f
35
36
  )
36
37
  end
37
38
 
38
39
  context "when wrapped by ActiveJob" do
39
- let(:item) {{
40
- "class" => "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper",
41
- "wrapped" => "TestClass",
42
- "queue" => "default",
43
- "args"=> [{
44
- "job_class" => "TestJob",
45
- "job_id" => "23e79d48-6966-40d0-b2d4-f7938463a263",
46
- "queue_name" => "default",
47
- "arguments" => ['Model', 1],
48
- }],
49
- "retry" => true,
50
- "jid" => "efb140489485999d32b5504c",
51
- "created_at" => Time.parse('01-01-2001 10:00:00UTC').to_f,
52
- "enqueued_at" => Time.parse('01-01-2001 10:00:00UTC').to_f
53
- }}
40
+ let(:item) do
41
+ {
42
+ "class" => "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper",
43
+ "wrapped" => "TestClass",
44
+ "queue" => "default",
45
+ "args" => [{
46
+ "job_class" => "TestJob",
47
+ "job_id" => "23e79d48-6966-40d0-b2d4-f7938463a263",
48
+ "queue_name" => "default",
49
+ "arguments" => ["Model", 1]
50
+ }],
51
+ "retry" => true,
52
+ "jid" => "efb140489485999d32b5504c",
53
+ "created_at" => Time.parse("01-01-2001 10:00:00UTC").to_f,
54
+ "enqueued_at" => Time.parse("01-01-2001 10:00:00UTC").to_f
55
+ }
56
+ end
54
57
 
55
58
  it "should wrap in a transaction with the correct params" do
56
59
  Appsignal.should_receive(:monitor_transaction).with(
57
- 'perform_job.sidekiq',
58
- :class => 'TestClass',
59
- :method => 'perform',
60
+ "perform_job.sidekiq",
61
+ :class => "TestClass",
62
+ :method => "perform",
60
63
  :metadata => {
61
- 'queue' => 'default'
64
+ "queue" => "default"
62
65
  },
63
- :params => ['Model', "1"],
64
- :queue_start => Time.parse('01-01-2001 10:00:00UTC').to_f,
65
- :queue_time => 60000.to_f
66
+ :params => ["Model", "1"],
67
+ :queue_start => Time.parse("01-01-2001 10:00:00UTC").to_f,
68
+ :queue_time => 60_000.to_f
66
69
  )
67
70
  end
68
71
  end
69
72
 
70
73
  after do
71
- Timecop.freeze(Time.parse('01-01-2001 10:01:00UTC')) do
74
+ Timecop.freeze(Time.parse("01-01-2001 10:01:00UTC")) do
72
75
  Appsignal::Hooks::SidekiqPlugin.new.call(worker, item, queue) do
73
76
  # nothing
74
77
  end
@@ -85,7 +88,7 @@ describe Appsignal::Hooks::SidekiqPlugin do
85
88
 
86
89
  after do
87
90
  begin
88
- Timecop.freeze(Time.parse('01-01-2001 10:01:00UTC')) do
91
+ Timecop.freeze(Time.parse("01-01-2001 10:01:00UTC")) do
89
92
  Appsignal::Hooks::SidekiqPlugin.new.call(worker, item, queue) do
90
93
  raise error
91
94
  end
@@ -98,13 +101,13 @@ describe Appsignal::Hooks::SidekiqPlugin do
98
101
  describe "#formatted_data" do
99
102
  let(:item) do
100
103
  {
101
- 'foo' => 'bar',
102
- 'class' => 'TestClass',
104
+ "foo" => "bar",
105
+ "class" => "TestClass"
103
106
  }
104
107
  end
105
108
 
106
109
  it "should only add items to the hash that do not appear in JOB_KEYS" do
107
- plugin.formatted_metadata(item).should eq({'foo' => 'bar'})
110
+ plugin.formatted_metadata(item).should eq("foo" => "bar")
108
111
  end
109
112
  end
110
113
  end
@@ -7,8 +7,8 @@ describe Appsignal::Hooks::WebmachineHook do
7
7
  its(:dependencies_present?) { should be_true }
8
8
 
9
9
  it "should include the run alias methods" do
10
- expect( fsm ).to respond_to(:run_with_appsignal)
11
- expect( fsm ).to respond_to(:run_without_appsignal)
10
+ expect(fsm).to respond_to(:run_with_appsignal)
11
+ expect(fsm).to respond_to(:run_without_appsignal)
12
12
  end
13
13
 
14
14
  it "should include the handle_exceptions alias methods" do
@@ -27,7 +27,7 @@ class MockErrorHook < Appsignal::Hooks::Hook
27
27
  end
28
28
 
29
29
  def install
30
- raise 'error'
30
+ raise "error"
31
31
  end
32
32
  end
33
33
 
@@ -88,20 +88,20 @@ describe Appsignal::Hooks::Helpers do
88
88
  end
89
89
 
90
90
  it "should truncate the text to 200 chars max" do
91
- with_helpers.truncate(very_long_text).should eq "#{'a' * 197}..."
91
+ with_helpers.truncate(very_long_text).should eq "#{"a" * 197}..."
92
92
  end
93
93
  end
94
94
 
95
95
  describe "#string_or_inspect" do
96
96
  context "when string" do
97
97
  it "should return the string" do
98
- with_helpers.string_or_inspect('foo').should eq 'foo'
98
+ with_helpers.string_or_inspect("foo").should eq "foo"
99
99
  end
100
100
  end
101
101
 
102
102
  context "when integer" do
103
103
  it "should return the string" do
104
- with_helpers.string_or_inspect(1).should eq '1'
104
+ with_helpers.string_or_inspect(1).should eq "1"
105
105
  end
106
106
  end
107
107
 
@@ -116,12 +116,12 @@ describe Appsignal::Hooks::Helpers do
116
116
 
117
117
  describe "#extract_value" do
118
118
  context "for a hash" do
119
- let(:hash) { {:key => 'value'} }
119
+ let(:hash) { { :key => "value" } }
120
120
 
121
121
  context "when the key exists" do
122
122
  subject { with_helpers.extract_value(hash, :key) }
123
123
 
124
- it { should eq 'value' }
124
+ it { should eq "value" }
125
125
  end
126
126
 
127
127
  context "when the key does not exist" do
@@ -141,12 +141,12 @@ describe Appsignal::Hooks::Helpers do
141
141
  before :all do
142
142
  TestStruct = Struct.new(:key)
143
143
  end
144
- let(:struct) { TestStruct.new('value') }
144
+ let(:struct) { TestStruct.new("value") }
145
145
 
146
146
  context "when the key exists" do
147
147
  subject { with_helpers.extract_value(struct, :key) }
148
148
 
149
- it { should eq 'value' }
149
+ it { should eq "value" }
150
150
  end
151
151
 
152
152
  context "when the key does not exist" do
@@ -163,12 +163,12 @@ describe Appsignal::Hooks::Helpers do
163
163
  end
164
164
 
165
165
  context "for an object" do
166
- let(:object) { double(:existing_method => 'value') }
166
+ let(:object) { double(:existing_method => "value") }
167
167
 
168
168
  context "when the method exists" do
169
169
  subject { with_helpers.extract_value(object, :existing_method) }
170
170
 
171
- it { should eq 'value' }
171
+ it { should eq "value" }
172
172
  end
173
173
 
174
174
  context "when the method does not exist" do
@@ -182,7 +182,6 @@ describe Appsignal::Hooks::Helpers do
182
182
  it { should eq 1 }
183
183
  end
184
184
  end
185
-
186
185
  end
187
186
 
188
187
  context "when we need to call to_s on the value" do
@@ -190,7 +189,7 @@ describe Appsignal::Hooks::Helpers do
190
189
 
191
190
  subject { with_helpers.extract_value(object, :existing_method, nil, true) }
192
191
 
193
- it { should eq '1' }
192
+ it { should eq "1" }
194
193
  end
195
194
  end
196
195
 
@@ -198,19 +197,19 @@ describe Appsignal::Hooks::Helpers do
198
197
  let(:object) { Object.new }
199
198
  let(:args) do
200
199
  [
201
- 'Model',
200
+ "Model",
202
201
  1,
203
202
  object,
204
- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
203
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
205
204
  ]
206
205
  end
207
206
 
208
207
  it "should format the arguments" do
209
208
  with_helpers.format_args(args).should eq([
210
- 'Model',
211
- '1',
209
+ "Model",
210
+ "1",
212
211
  object.inspect,
213
- 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ...'
212
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ..."
214
213
  ])
215
214
  end
216
215
  end
@@ -1,7 +1,6 @@
1
- require 'appsignal/integrations/data_mapper'
1
+ require "appsignal/integrations/data_mapper"
2
2
 
3
3
  describe Appsignal::Hooks::DataMapperLogListener do
4
-
5
4
  module DataMapperLog
6
5
  def log(message)
7
6
  end
@@ -29,9 +28,9 @@ describe Appsignal::Hooks::DataMapperLogListener do
29
28
  before { Appsignal::Transaction.stub(:current) { transaction } }
30
29
 
31
30
  it "should record the log entry in an event" do
32
- expect( transaction ).to receive(:record_event).with(
33
- 'query.data_mapper',
34
- 'DataMapper Query',
31
+ expect(transaction).to receive(:record_event).with(
32
+ "query.data_mapper",
33
+ "DataMapper Query",
35
34
  "SELECT * from users",
36
35
  100,
37
36
  Appsignal::EventFormatter::SQL_BODY_FORMAT
@@ -51,9 +50,9 @@ describe Appsignal::Hooks::DataMapperLogListener do
51
50
  end
52
51
 
53
52
  it "should record the log entry in an event without body" do
54
- expect( transaction ).to receive(:record_event).with(
55
- 'query.data_mapper',
56
- 'DataMapper Query',
53
+ expect(transaction).to receive(:record_event).with(
54
+ "query.data_mapper",
55
+ "DataMapper Query",
57
56
  "",
58
57
  100,
59
58
  Appsignal::EventFormatter::DEFAULT
@@ -1,24 +1,24 @@
1
- require 'appsignal/integrations/mongo_ruby_driver'
1
+ require "appsignal/integrations/mongo_ruby_driver"
2
2
  describe Appsignal::Hooks::MongoMonitorSubscriber do
3
3
  let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
4
4
 
5
5
  context "with transaction" do
6
6
  let!(:transaction) do
7
- Appsignal::Transaction.create('1', 'http_request', {}, {})
7
+ Appsignal::Transaction.create("1", "http_request", {}, {})
8
8
  end
9
9
 
10
10
  describe "#started" do
11
11
  let(:event) do
12
12
  double(
13
13
  :request_id => 1,
14
- :command_name => 'find',
15
- :command => {'foo' => 'bar'}
14
+ :command_name => "find",
15
+ :command => { "foo" => "bar" }
16
16
  )
17
17
  end
18
18
 
19
19
  it "should sanitize command" do
20
20
  Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter
21
- .should receive(:format).with('find', {'foo' => 'bar'})
21
+ .should receive(:format).with("find", "foo" => "bar")
22
22
 
23
23
  subscriber.started(event)
24
24
  end
@@ -26,7 +26,7 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
26
26
  it "should store command on the transaction" do
27
27
  subscriber.started(event)
28
28
 
29
- transaction.store('mongo_driver').should eq({1 => {'foo' => '?'}})
29
+ transaction.store("mongo_driver").should eq(1 => { "foo" => "?" })
30
30
  end
31
31
 
32
32
  it "should start an event in the extension" do
@@ -40,7 +40,7 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
40
40
  let(:event) { double }
41
41
 
42
42
  it "should finish the event" do
43
- subscriber.should receive(:finish).with('SUCCEEDED', event)
43
+ subscriber.should receive(:finish).with("SUCCEEDED", event)
44
44
 
45
45
  subscriber.succeeded(event)
46
46
  end
@@ -50,42 +50,42 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
50
50
  let(:event) { double }
51
51
 
52
52
  it "should finish the event" do
53
- subscriber.should receive(:finish).with('FAILED', event)
53
+ subscriber.should receive(:finish).with("FAILED", event)
54
54
 
55
55
  subscriber.failed(event)
56
56
  end
57
57
  end
58
58
 
59
59
  describe "#finish" do
60
- let(:command) { {'foo' => '?'} }
60
+ let(:command) { { "foo" => "?" } }
61
61
  let(:event) do
62
62
  double(
63
63
  :request_id => 2,
64
64
  :command_name => :find,
65
- :database_name => 'test'
65
+ :database_name => "test"
66
66
  )
67
67
  end
68
68
 
69
69
  before do
70
- store = transaction.store('mongo_driver')
70
+ store = transaction.store("mongo_driver")
71
71
  store[2] = command
72
72
  end
73
73
 
74
74
  it "should get the query from the store" do
75
- transaction.should receive(:store).with('mongo_driver').and_return(command)
75
+ transaction.should receive(:store).with("mongo_driver").and_return(command)
76
76
 
77
- subscriber.finish('SUCCEEDED', event)
77
+ subscriber.finish("SUCCEEDED", event)
78
78
  end
79
79
 
80
80
  it "should finish the transaction in the extension" do
81
81
  transaction.should receive(:finish_event).with(
82
- 'query.mongodb',
83
- 'find | test | SUCCEEDED',
84
- Appsignal::Utils.data_generate({'foo' => '?'}),
82
+ "query.mongodb",
83
+ "find | test | SUCCEEDED",
84
+ Appsignal::Utils.data_generate("foo" => "?"),
85
85
  0
86
86
  )
87
87
 
88
- subscriber.finish('SUCCEEDED', event)
88
+ subscriber.finish("SUCCEEDED", event)
89
89
  end
90
90
  end
91
91
  end
@@ -106,7 +106,7 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
106
106
  it "should not attempt to finish an event" do
107
107
  Appsignal::Extension.should_not receive(:finish_event)
108
108
 
109
- subscriber.finish('SUCCEEDED', double)
109
+ subscriber.finish("SUCCEEDED", double)
110
110
  end
111
111
  end
112
112
 
@@ -123,7 +123,7 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
123
123
  it "should not attempt to finish an event" do
124
124
  Appsignal::Extension.should_not receive(:finish_event)
125
125
 
126
- subscriber.finish('SUCCEEDED', double)
126
+ subscriber.finish("SUCCEEDED", double)
127
127
  end
128
128
  end
129
129
  end
@@ -1,4 +1,4 @@
1
- require 'appsignal/integrations/object'
1
+ require "appsignal/integrations/object"
2
2
 
3
3
  describe Object do
4
4
  describe "#instrument_method" do
@@ -84,7 +84,7 @@ describe Object do
84
84
  def foo
85
85
  1
86
86
  end
87
- appsignal_instrument_method :foo, name: "my_method.group"
87
+ appsignal_instrument_method :foo, :name => "my_method.group"
88
88
  end
89
89
  end
90
90
 
@@ -206,7 +206,7 @@ describe Object do
206
206
  def self.bar
207
207
  2
208
208
  end
209
- appsignal_instrument_class_method :bar, name: "my_method.group"
209
+ appsignal_instrument_class_method :bar, :name => "my_method.group"
210
210
  end
211
211
  end
212
212
 
@@ -1,6 +1,6 @@
1
1
  if DependencyHelper.padrino_present?
2
- describe "Padrino integration" do
3
- require File.expand_path('lib/appsignal/integrations/padrino.rb')
2
+ describe "Padrino integration" do
3
+ require File.expand_path("lib/appsignal/integrations/padrino.rb")
4
4
 
5
5
  class ClassWithRouter
6
6
  include Padrino::Routing
@@ -16,35 +16,35 @@ if DependencyHelper.padrino_present?
16
16
 
17
17
  describe "Appsignal::Integrations::PadrinoPlugin" do
18
18
  it "should start the logger on init" do
19
- expect( Appsignal ).to receive(:start_logger)
19
+ expect(Appsignal).to receive(:start_logger)
20
20
  end
21
21
 
22
22
  it "should start appsignal on init" do
23
- expect( Appsignal ).to receive(:start)
23
+ expect(Appsignal).to receive(:start)
24
24
  end
25
25
 
26
26
  context "when not active" do
27
27
  before { Appsignal.stub(:active? => false) }
28
28
 
29
29
  it "should not add the Listener middleware to the stack" do
30
- expect( Padrino ).to_not receive(:use)
30
+ expect(Padrino).to_not receive(:use)
31
31
  end
32
32
  end
33
33
 
34
34
  context "when APPSIGNAL_APP_ENV ENV var is provided" do
35
- it 'should use this as the environment' do
36
- ENV['APPSIGNAL_APP_ENV'] = 'custom'
35
+ it "should use this as the environment" do
36
+ ENV["APPSIGNAL_APP_ENV"] = "custom"
37
37
 
38
38
  # Reset the plugin to pull down the latest data
39
39
  Appsignal::Integrations::PadrinoPlugin.init
40
40
 
41
- expect(Appsignal.config.env).to eq 'custom'
41
+ expect(Appsignal.config.env).to eq "custom"
42
42
  end
43
43
  end
44
44
 
45
45
  context "when APPSIGNAL_APP_ENV ENV var is not provided" do
46
- it 'should use the Padrino environment' do
47
- ENV['APPSIGNAL_APP_ENV'] = nil
46
+ it "should use the Padrino environment" do
47
+ ENV["APPSIGNAL_APP_ENV"] = nil
48
48
 
49
49
  # Reset the plugin to pull down the latest data
50
50
  Appsignal::Integrations::PadrinoPlugin.init
@@ -60,17 +60,17 @@ if DependencyHelper.padrino_present?
60
60
  let(:base) { double }
61
61
  let(:router) { ClassWithRouter.new }
62
62
  let(:env) { {} }
63
- let(:settings) { double(:name => 'TestApp') }
63
+ let(:settings) { double(:name => "TestApp") }
64
64
 
65
65
  describe "#route!" do
66
66
  let(:request) do
67
67
  double(
68
- :params => {'id' => 1},
69
- :session => {'user_id' => 123},
70
- :request_method => 'GET',
71
- :path => '/users/1',
72
- :controller => 'users',
73
- :action => 'show',
68
+ :params => { "id" => 1 },
69
+ :session => { "user_id" => 123 },
70
+ :request_method => "GET",
71
+ :path => "/users/1",
72
+ :controller => "users",
73
+ :action => "show",
74
74
  :env => {}
75
75
  )
76
76
  end
@@ -81,19 +81,19 @@ if DependencyHelper.padrino_present?
81
81
  :request => request,
82
82
  :env => env,
83
83
  :settings => settings,
84
- :get_payload_action => 'controller#action'
84
+ :get_payload_action => "controller#action"
85
85
  )
86
86
  end
87
87
 
88
88
  context "when Sinatra tells us it's a static file" do
89
- let(:env) { {'sinatra.static_file' => true} }
89
+ let(:env) { { "sinatra.static_file" => true } }
90
90
 
91
91
  it "should call the original method" do
92
- expect( router ).to receive(:route_without_appsignal)
92
+ expect(router).to receive(:route_without_appsignal)
93
93
  end
94
94
 
95
95
  it "should not instrument the request" do
96
- expect( Appsignal ).to_not receive(:instrument)
96
+ expect(Appsignal).to_not receive(:instrument)
97
97
  end
98
98
 
99
99
  after { router.route!(base) }
@@ -103,11 +103,11 @@ if DependencyHelper.padrino_present?
103
103
  before { Appsignal.stub(:active? => false) }
104
104
 
105
105
  it "should call the original method" do
106
- expect( router ).to receive(:route_without_appsignal)
106
+ expect(router).to receive(:route_without_appsignal)
107
107
  end
108
108
 
109
109
  it "should not instrument the request" do
110
- expect( Appsignal ).to_not receive(:instrument)
110
+ expect(Appsignal).to_not receive(:instrument)
111
111
  end
112
112
 
113
113
  after { router.route!(base) }
@@ -115,19 +115,19 @@ if DependencyHelper.padrino_present?
115
115
 
116
116
  context "with a dynamic request" do
117
117
  let(:transaction) do
118
- double(
119
- :set_http_or_background_action => nil,
120
- :set_http_or_background_queue_start => nil,
121
- :set_metadata => nil,
122
- :set_action => nil,
123
- :set_error => nil
124
- )
118
+ double(
119
+ :set_http_or_background_action => nil,
120
+ :set_http_or_background_queue_start => nil,
121
+ :set_metadata => nil,
122
+ :set_action => nil,
123
+ :set_error => nil
124
+ )
125
125
  end
126
126
  before { Appsignal::Transaction.stub(:create => transaction) }
127
127
 
128
128
  context "without an error" do
129
129
  it "should create a transaction" do
130
- expect( Appsignal::Transaction ).to receive(:create).with(
130
+ expect(Appsignal::Transaction).to receive(:create).with(
131
131
  kind_of(String),
132
132
  Appsignal::Transaction::HTTP_REQUEST,
133
133
  request
@@ -135,19 +135,19 @@ if DependencyHelper.padrino_present?
135
135
  end
136
136
 
137
137
  it "should call the original routing method" do
138
- expect( router ).to receive(:route_without_appsignal)
138
+ expect(router).to receive(:route_without_appsignal)
139
139
  end
140
140
 
141
141
  it "should instrument the action" do
142
- expect( Appsignal ).to receive(:instrument).with('process_action.padrino')
142
+ expect(Appsignal).to receive(:instrument).with("process_action.padrino")
143
143
  end
144
144
 
145
145
  it "should set metadata" do
146
- expect( transaction ).to receive(:set_metadata).twice
146
+ expect(transaction).to receive(:set_metadata).twice
147
147
  end
148
148
 
149
149
  it "should set the action on the transaction" do
150
- expect( transaction ).to receive(:set_action).with('controller#action')
150
+ expect(transaction).to receive(:set_action).with("controller#action")
151
151
  end
152
152
 
153
153
  after { router.route!(base) }
@@ -158,7 +158,7 @@ if DependencyHelper.padrino_present?
158
158
  before { router.stub(:route_without_appsignal).and_raise(error) }
159
159
 
160
160
  it "should add the exception to the current transaction" do
161
- expect( transaction ).to receive(:set_error).with(error)
161
+ expect(transaction).to receive(:set_error).with(error)
162
162
 
163
163
  router.route!(base) rescue VerySpecificError
164
164
  end
@@ -167,37 +167,37 @@ if DependencyHelper.padrino_present?
167
167
  end
168
168
 
169
169
  describe "#get_payload_action" do
170
- before { router.stub(:settings => settings) }
170
+ before { router.stub(:settings => settings) }
171
171
 
172
172
  context "when request is nil" do
173
173
  it "should return the site" do
174
- expect( router.get_payload_action(nil) ).to eql('TestApp')
174
+ expect(router.get_payload_action(nil)).to eql("TestApp")
175
175
  end
176
176
  end
177
177
 
178
178
  context "when there's no route object" do
179
- let(:request) { double(:controller => 'Controller', :action => 'action') }
179
+ let(:request) { double(:controller => "Controller", :action => "action") }
180
180
 
181
181
  it "should return the site name, controller and action" do
182
- expect( router.get_payload_action(request) ).to eql('TestApp:Controller#action')
182
+ expect(router.get_payload_action(request)).to eql("TestApp:Controller#action")
183
183
  end
184
184
 
185
185
  context "when there's no action" do
186
- let(:request) { double(:controller => 'Controller', :fullpath => '/action') }
186
+ let(:request) { double(:controller => "Controller", :fullpath => "/action") }
187
187
 
188
188
  it "should return the site name, controller and fullpath" do
189
- expect( router.get_payload_action(request) ).to eql('TestApp:Controller#/action')
189
+ expect(router.get_payload_action(request)).to eql("TestApp:Controller#/action")
190
190
  end
191
191
  end
192
192
  end
193
193
 
194
194
  context "when request has a route object" do
195
195
  let(:request) { double }
196
- let(:route_object) { double(:original_path => '/accounts/edit/:id') }
196
+ let(:route_object) { double(:original_path => "/accounts/edit/:id") }
197
197
  before { request.stub(:route_obj => route_object) }
198
198
 
199
199
  it "should return the original path" do
200
- expect( router.get_payload_action(request) ).to eql('TestApp:/accounts/edit/:id')
200
+ expect(router.get_payload_action(request)).to eql("TestApp:/accounts/edit/:id")
201
201
  end
202
202
  end
203
203
  end