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
@@ -1,11 +1,11 @@
1
- require 'fileutils'
1
+ require "fileutils"
2
2
 
3
3
  describe "extension loading and operation" do
4
4
  describe ".agent_config" do
5
5
  subject { Appsignal::Extension.agent_config }
6
6
 
7
- it { should have_key('version') }
8
- it { should have_key('triples') }
7
+ it { should have_key("version") }
8
+ it { should have_key("triples") }
9
9
  end
10
10
 
11
11
  describe ".agent_version" do
@@ -37,30 +37,30 @@ describe "extension loading and operation" do
37
37
  end
38
38
 
39
39
  context "with a transaction" do
40
- subject { Appsignal::Extension.start_transaction('request_id', 'http_request', 0) }
40
+ subject { Appsignal::Extension.start_transaction("request_id", "http_request", 0) }
41
41
 
42
42
  it "should have a start_event method" do
43
43
  subject.start_event(0)
44
44
  end
45
45
 
46
46
  it "should have a finish_event method" do
47
- subject.finish_event('name', 'title', 'body', 0, 0)
47
+ subject.finish_event("name", "title", "body", 0, 0)
48
48
  end
49
49
 
50
50
  it "should have a record_event method" do
51
- subject.record_event('name', 'title', 'body', 1000, 0, 1000)
51
+ subject.record_event("name", "title", "body", 1000, 0, 1000)
52
52
  end
53
53
 
54
54
  it "should have a set_error method" do
55
- subject.set_error('name', 'message', Appsignal::Extension.data_map_new)
55
+ subject.set_error("name", "message", Appsignal::Extension.data_map_new)
56
56
  end
57
57
 
58
58
  it "should have a set_sample_data method" do
59
- subject.set_sample_data('params', Appsignal::Extension.data_map_new)
59
+ subject.set_sample_data("params", Appsignal::Extension.data_map_new)
60
60
  end
61
61
 
62
62
  it "should have a set_action method" do
63
- subject.set_action('value')
63
+ subject.set_action("value")
64
64
  end
65
65
 
66
66
  it "should have a set_queue_start method" do
@@ -68,7 +68,7 @@ describe "extension loading and operation" do
68
68
  end
69
69
 
70
70
  it "should have a set_metadata method" do
71
- subject.set_metadata('key', 'value')
71
+ subject.set_metadata("key", "value")
72
72
  end
73
73
 
74
74
  it "should have a finish method" do
@@ -81,15 +81,15 @@ describe "extension loading and operation" do
81
81
  end
82
82
 
83
83
  it "should have a set_gauge method" do
84
- subject.set_gauge('key', 1.0)
84
+ subject.set_gauge("key", 1.0)
85
85
  end
86
86
 
87
87
  it "should have a increment_counter method" do
88
- subject.increment_counter('key', 1)
88
+ subject.increment_counter("key", 1)
89
89
  end
90
90
 
91
91
  it "should have a add_distribution_value method" do
92
- subject.add_distribution_value('key', 1.0)
92
+ subject.add_distribution_value("key", 1.0)
93
93
  end
94
94
  end
95
95
  end
@@ -109,9 +109,9 @@ describe "extension loading and operation" do
109
109
  end
110
110
 
111
111
  it "should not raise errors when methods are called" do
112
- expect {
112
+ expect do
113
113
  subject.something
114
- }.not_to raise_error
114
+ end.not_to raise_error
115
115
  end
116
116
  end
117
117
  end
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
2
- require_relative '../../support/mocks/fake_gc_profiler'
1
+ require "spec_helper"
2
+ require_relative "../../support/mocks/fake_gc_profiler"
3
3
 
4
4
  describe Appsignal::GarbageCollectionProfiler do
5
5
  let(:internal_profiler) { FakeGCProfiler.new }
@@ -33,8 +33,8 @@ describe Appsignal::GarbageCollectionProfiler do
33
33
  describe "when the total GC time becomes too high" do
34
34
  it "should reset" do
35
35
  profiler = Appsignal::GarbageCollectionProfiler.new
36
- internal_profiler.total_time = 2_147_483_647
37
- expect(profiler.total_time).to eq(0)
36
+ internal_profiler.total_time = 2_147_483_647
37
+ expect(profiler.total_time).to eq(0)
38
38
  end
39
39
  end
40
40
 
@@ -53,7 +53,8 @@ describe Appsignal::GarbageCollectionProfiler do
53
53
 
54
54
  describe "in multiple threads, with a slow GC::Profiler" do
55
55
  it "should not count garbage collection times twice" do
56
- threads, results = [], []
56
+ threads = []
57
+ results = []
57
58
  internal_profiler.clear_delay = 0.001
58
59
  internal_profiler.total_time = 0.12345
59
60
 
@@ -4,7 +4,7 @@ describe Appsignal::Hooks::ActiveSupportNotificationsHook do
4
4
  start_agent
5
5
  end
6
6
  before do
7
- Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
7
+ Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
8
8
  end
9
9
 
10
10
  let(:notifier) { ActiveSupport::Notifications::Fanout.new }
@@ -13,28 +13,28 @@ describe Appsignal::Hooks::ActiveSupportNotificationsHook do
13
13
  its(:dependencies_present?) { should be_true }
14
14
 
15
15
  it "should instrument an AS notifications instrument call with a block" do
16
- expect( Appsignal::Transaction.current ).to receive(:start_event)
16
+ expect(Appsignal::Transaction.current).to receive(:start_event)
17
17
  .at_least(:once)
18
- expect( Appsignal::Transaction.current ).to receive(:finish_event)
18
+ expect(Appsignal::Transaction.current).to receive(:finish_event)
19
19
  .at_least(:once)
20
- .with("sql.active_record", nil, 'SQL', 1)
20
+ .with("sql.active_record", nil, "SQL", 1)
21
21
 
22
- return_value = instrumenter.instrument('sql.active_record', :sql => 'SQL') do
23
- 'value'
22
+ return_value = instrumenter.instrument("sql.active_record", :sql => "SQL") do
23
+ "value"
24
24
  end
25
25
 
26
- expect(return_value).to eq 'value'
26
+ expect(return_value).to eq "value"
27
27
  end
28
28
 
29
29
  it "should not instrument events whose name starts with a bang" do
30
- expect( Appsignal::Transaction.current ).not_to receive(:start_event)
31
- expect( Appsignal::Transaction.current ).not_to receive(:finish_event)
30
+ expect(Appsignal::Transaction.current).not_to receive(:start_event)
31
+ expect(Appsignal::Transaction.current).not_to receive(:finish_event)
32
32
 
33
- return_value = instrumenter.instrument('!sql.active_record', :sql => 'SQL') do
34
- 'value'
33
+ return_value = instrumenter.instrument("!sql.active_record", :sql => "SQL") do
34
+ "value"
35
35
  end
36
36
 
37
- expect(return_value).to eq 'value'
37
+ expect(return_value).to eq "value"
38
38
  end
39
39
  else
40
40
  its(:dependencies_present?) { should be_false }
@@ -25,36 +25,36 @@ describe Appsignal::Hooks::DelayedJobHook do
25
25
 
26
26
  describe ".invoke_with_instrumentation" do
27
27
  let(:plugin) { Appsignal::Hooks::DelayedJobPlugin }
28
- let(:time) { Time.parse('01-01-2001 10:01:00UTC') }
28
+ let(:time) { Time.parse("01-01-2001 10:01:00UTC") }
29
29
  let(:job_data) do
30
30
  {
31
31
  :id => 123,
32
- :name => 'TestClass#perform',
32
+ :name => "TestClass#perform",
33
33
  :priority => 1,
34
34
  :attempts => 1,
35
- :queue => 'default',
35
+ :queue => "default",
36
36
  :created_at => time - 60_000,
37
- :payload_object => double(:args => ['argument']),
37
+ :payload_object => double(:args => ["argument"])
38
38
  }
39
39
  end
40
40
  let(:job) { double(job_data) }
41
- let(:invoked_block) { Proc.new { } }
41
+ let(:invoked_block) { proc {} }
42
42
  let(:error) { StandardError.new }
43
43
 
44
44
  context "with a normal call" do
45
45
  it "should wrap in a transaction with the correct params" do
46
46
  Appsignal.should_receive(:monitor_transaction).with(
47
- 'perform_job.delayed_job',
48
- :class => 'TestClass',
49
- :method => 'perform',
47
+ "perform_job.delayed_job",
48
+ :class => "TestClass",
49
+ :method => "perform",
50
50
  :metadata => {
51
51
  :priority => 1,
52
52
  :attempts => 1,
53
- :queue => 'default',
54
- :id => '123'
53
+ :queue => "default",
54
+ :id => "123"
55
55
  },
56
- :params => ['argument'],
57
- :queue_start => time - 60_000,
56
+ :params => ["argument"],
57
+ :queue_start => time - 60_000
58
58
  )
59
59
 
60
60
  Timecop.freeze(time) do
@@ -66,29 +66,29 @@ describe Appsignal::Hooks::DelayedJobHook do
66
66
  let(:job_data) do
67
67
  {
68
68
  :payload_object => double(
69
- :appsignal_name => 'CustomClass#perform',
70
- :args => ['argument']
69
+ :appsignal_name => "CustomClass#perform",
70
+ :args => ["argument"]
71
71
  ),
72
- :id => '123',
73
- :name => 'TestClass#perform',
72
+ :id => "123",
73
+ :name => "TestClass#perform",
74
74
  :priority => 1,
75
75
  :attempts => 1,
76
- :queue => 'default',
76
+ :queue => "default",
77
77
  :created_at => time - 60_000
78
78
  }
79
79
  end
80
80
  it "should wrap in a transaction with the correct params" do
81
81
  Appsignal.should_receive(:monitor_transaction).with(
82
- 'perform_job.delayed_job',
83
- :class => 'CustomClass',
84
- :method => 'perform',
82
+ "perform_job.delayed_job",
83
+ :class => "CustomClass",
84
+ :method => "perform",
85
85
  :metadata => {
86
86
  :priority => 1,
87
87
  :attempts => 1,
88
- :queue => 'default',
89
- :id => '123'
88
+ :queue => "default",
89
+ :id => "123"
90
90
  },
91
- :params => ['argument'],
91
+ :params => ["argument"],
92
92
  :queue_start => time - 60_000
93
93
  )
94
94
 
@@ -99,27 +99,27 @@ describe Appsignal::Hooks::DelayedJobHook do
99
99
  end
100
100
 
101
101
  if active_job_present?
102
- require 'active_job'
102
+ require "active_job"
103
103
 
104
104
  context "when wrapped by ActiveJob" do
105
105
  before do
106
- job_data[:args] = ['argument']
106
+ job_data[:args] = ["argument"]
107
107
  end
108
108
  let(:job) { ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper.new(job_data) }
109
109
 
110
110
  it "should wrap in a transaction with the correct params" do
111
111
  Appsignal.should_receive(:monitor_transaction).with(
112
- 'perform_job.delayed_job',
113
- :class => 'TestClass',
114
- :method => 'perform',
112
+ "perform_job.delayed_job",
113
+ :class => "TestClass",
114
+ :method => "perform",
115
115
  :metadata => {
116
116
  :priority => 1,
117
117
  :attempts => 1,
118
- :queue => 'default',
119
- :id => '123'
118
+ :queue => "default",
119
+ :id => "123"
120
120
  },
121
- :params => ['argument'],
122
- :queue_start => time - 60_000,
121
+ :params => ["argument"],
122
+ :queue_start => time - 60_000
123
123
  )
124
124
 
125
125
  Timecop.freeze(time) do
@@ -137,9 +137,9 @@ describe Appsignal::Hooks::DelayedJobHook do
137
137
 
138
138
  invoked_block.stub(:call).and_raise(error)
139
139
 
140
- lambda {
140
+ lambda do
141
141
  plugin.invoke_with_instrumentation(job, invoked_block)
142
- }.should raise_error(StandardError)
142
+ end.should raise_error(StandardError)
143
143
  end
144
144
  end
145
145
  end
@@ -1,5 +1,5 @@
1
1
  describe Appsignal::Hooks::MongoRubyDriverHook do
2
- require 'appsignal/integrations/mongo_ruby_driver'
2
+ require "appsignal/integrations/mongo_ruby_driver"
3
3
 
4
4
  context "with mongo ruby driver" do
5
5
  let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
@@ -8,7 +8,7 @@ describe Appsignal::Hooks::MongoRubyDriverHook do
8
8
  before(:all) do
9
9
  module Mongo
10
10
  module Monitoring
11
- COMMAND = 'command'
11
+ COMMAND = "command"
12
12
 
13
13
  class Global
14
14
  def subscribe
@@ -23,7 +23,7 @@ describe Appsignal::Hooks::MongoRubyDriverHook do
23
23
 
24
24
  it "adds a subscriber to Mongo::Monitoring" do
25
25
  Mongo::Monitoring::Global.should receive(:subscribe)
26
- .with('command', subscriber)
26
+ .with("command", subscriber)
27
27
  .at_least(:once)
28
28
 
29
29
  Appsignal::Hooks::MongoRubyDriverHook.new.install
@@ -7,29 +7,29 @@ describe Appsignal::Hooks::NetHttpHook do
7
7
  its(:dependencies_present?) { should be_true }
8
8
 
9
9
  it "should instrument a http request" do
10
- Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
11
- expect( Appsignal::Transaction.current ).to receive(:start_event)
10
+ Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
11
+ expect(Appsignal::Transaction.current).to receive(:start_event)
12
12
  .at_least(:once)
13
- expect( Appsignal::Transaction.current ).to receive(:finish_event)
13
+ expect(Appsignal::Transaction.current).to receive(:finish_event)
14
14
  .at_least(:once)
15
15
  .with("request.net_http", "GET http://www.google.com", nil, 0)
16
16
 
17
- stub_request(:any, 'http://www.google.com/')
17
+ stub_request(:any, "http://www.google.com/")
18
18
 
19
- Net::HTTP.get_response(URI.parse('http://www.google.com'))
19
+ Net::HTTP.get_response(URI.parse("http://www.google.com"))
20
20
  end
21
21
 
22
22
  it "should instrument a https request" do
23
- Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
24
- expect( Appsignal::Transaction.current ).to receive(:start_event)
23
+ Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
24
+ expect(Appsignal::Transaction.current).to receive(:start_event)
25
25
  .at_least(:once)
26
- expect( Appsignal::Transaction.current ).to receive(:finish_event)
26
+ expect(Appsignal::Transaction.current).to receive(:finish_event)
27
27
  .at_least(:once)
28
28
  .with("request.net_http", "GET https://www.google.com", nil, 0)
29
29
 
30
- stub_request(:any, 'https://www.google.com/')
30
+ stub_request(:any, "https://www.google.com/")
31
31
 
32
- uri = URI.parse('https://www.google.com')
32
+ uri = URI.parse("https://www.google.com")
33
33
  http = Net::HTTP.new(uri.host, uri.port)
34
34
  http.use_ssl = true
35
35
  http.get(uri.request_uri)
@@ -1,7 +1,7 @@
1
- require 'rake'
1
+ require "rake"
2
2
 
3
3
  describe Appsignal::Hooks::RakeHook do
4
- let(:task) { Rake::Task.new('task:name', Rake::Application.new) }
4
+ let(:task) { Rake::Task.new("task:name", Rake::Application.new) }
5
5
  before(:all) do
6
6
  Appsignal.config = project_fixture_config
7
7
  expect(Appsignal.active?).to be_true
@@ -15,10 +15,10 @@ describe Appsignal::Hooks::RakeHook do
15
15
  end
16
16
 
17
17
  it "calls the original task" do
18
- expect(task).to receive(:execute_without_appsignal).with('foo')
18
+ expect(task).to receive(:execute_without_appsignal).with("foo")
19
19
  end
20
20
 
21
- after { task.execute('foo') }
21
+ after { task.execute("foo") }
22
22
  end
23
23
 
24
24
  context "with error" do
@@ -35,7 +35,7 @@ describe Appsignal::Hooks::RakeHook do
35
35
  end
36
36
 
37
37
  it "sets the action" do
38
- expect(transaction).to receive(:set_action).with('task:name')
38
+ expect(transaction).to receive(:set_action).with("task:name")
39
39
  end
40
40
 
41
41
  it "sets the error" do
@@ -44,11 +44,11 @@ describe Appsignal::Hooks::RakeHook do
44
44
 
45
45
  it "completes the transaction and stops" do
46
46
  expect(transaction).to receive(:complete).ordered
47
- expect(Appsignal).to receive(:stop).with('rake').ordered
47
+ expect(Appsignal).to receive(:stop).with("rake").ordered
48
48
  end
49
49
 
50
50
  after do
51
- expect { task.execute('foo') }.to raise_error VerySpecificError
51
+ expect { task.execute("foo") }.to raise_error VerySpecificError
52
52
  end
53
53
  end
54
54
  end
@@ -8,11 +8,11 @@ describe Appsignal::Hooks::RedisHook do
8
8
  before :all do
9
9
  class Redis
10
10
  class Client
11
- def process(commands, &block)
11
+ def process(_commands)
12
12
  1
13
13
  end
14
14
  end
15
- VERSION = '1.0'
15
+ VERSION = "1.0"
16
16
  end
17
17
  end
18
18
 
@@ -26,12 +26,12 @@ describe Appsignal::Hooks::RedisHook do
26
26
  its(:dependencies_present?) { should be_true }
27
27
 
28
28
  it "should instrument a redis call" do
29
- Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
30
- expect( Appsignal::Transaction.current ).to receive(:start_event)
29
+ Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
30
+ expect(Appsignal::Transaction.current).to receive(:start_event)
31
31
  .at_least(:once)
32
- expect( Appsignal::Transaction.current ).to receive(:finish_event)
32
+ expect(Appsignal::Transaction.current).to receive(:finish_event)
33
33
  .at_least(:once)
34
- .with('query.redis', nil, nil, 0)
34
+ .with("query.redis", nil, nil, 0)
35
35
 
36
36
  client = Redis::Client.new
37
37
 
@@ -3,43 +3,42 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
3
3
 
4
4
  let(:worker_instance) { double }
5
5
  let(:queue) { double }
6
- let(:sqs_msg) {
7
- double(:attributes => {})
8
- }
9
- let(:body) {{}}
6
+ let(:sqs_msg) { double(:attributes => {}) }
7
+ let(:body) { {} }
10
8
 
11
9
  before do
12
- Appsignal.stub(:is_ignored_exception? => false)
13
10
  Appsignal::Transaction.stub(:current => current_transaction)
14
11
  start_agent
15
12
  end
16
13
 
17
14
  context "with a performance call" do
18
- let(:queue) { 'some-funky-queue-name' }
19
- let(:sqs_msg) {
20
- double(:attributes => { 'SentTimestamp' => Time.parse('1976-11-18 0:00:00UTC').to_i * 1000 })
21
- }
22
- let(:body) {{
23
- 'job_class' => 'TestClass',
24
- 'arguments' => ['Model', "1"],
25
- }}
15
+ let(:queue) { "some-funky-queue-name" }
16
+ let(:sqs_msg) do
17
+ double(:attributes => { "SentTimestamp" => Time.parse("1976-11-18 0:00:00UTC").to_i * 1000 })
18
+ end
19
+ let(:body) do
20
+ {
21
+ "job_class" => "TestClass",
22
+ "arguments" => ["Model", "1"]
23
+ }
24
+ end
26
25
 
27
26
  it "should wrap in a transaction with the correct params" do
28
27
  Appsignal.should_receive(:monitor_transaction).with(
29
- 'perform_job.shoryuken',
30
- :class => 'TestClass',
31
- :method => 'perform',
28
+ "perform_job.shoryuken",
29
+ :class => "TestClass",
30
+ :method => "perform",
32
31
  :metadata => {
33
- :queue => 'some-funky-queue-name',
34
- 'SentTimestamp' => 217123200000
32
+ :queue => "some-funky-queue-name",
33
+ "SentTimestamp" => 217_123_200_000
35
34
  },
36
- :params => ['Model', "1"],
37
- :queue_start => Time.parse('1976-11-18 0:00:00UTC').utc
35
+ :params => ["Model", "1"],
36
+ :queue_start => Time.parse("1976-11-18 0:00:00UTC").utc
38
37
  )
39
38
  end
40
39
 
41
40
  after do
42
- Timecop.freeze(Time.parse('01-01-2001 10:01:00UTC')) do
41
+ Timecop.freeze(Time.parse("01-01-2001 10:01:00UTC")) do
43
42
  Appsignal::Hooks::ShoryukenMiddleware.new.call(worker_instance, queue, sqs_msg, body) do
44
43
  # nothing
45
44
  end
@@ -56,7 +55,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
56
55
 
57
56
  after do
58
57
  begin
59
- Timecop.freeze(Time.parse('01-01-2001 10:01:00UTC')) do
58
+ Timecop.freeze(Time.parse("01-01-2001 10:01:00UTC")) do
60
59
  Appsignal::Hooks::ShoryukenMiddleware.new.call(worker_instance, queue, sqs_msg, body) do
61
60
  raise error
62
61
  end