appsignal 4.0.5 → 4.0.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Rakefile +9 -9
- data/appsignal.gemspec +22 -1
- data/build_matrix.yml +2 -1
- data/ext/agent.rb +27 -27
- data/lib/appsignal/check_in/scheduler.rb +3 -4
- data/lib/appsignal/check_in.rb +1 -1
- data/lib/appsignal/config.rb +1 -3
- data/lib/appsignal/integrations/que.rb +8 -2
- data/lib/appsignal/integrations/resque.rb +1 -6
- data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
- data/lib/appsignal/version.rb +1 -1
- metadata +2 -191
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- data/.github/ISSUE_TEMPLATE/chore.md +0 -14
- data/.github/workflows/ci.yml +0 -3150
- data/.github/workflows/create_release_from_tag.yml +0 -62
- data/.gitignore +0 -35
- data/.gitmodules +0 -3
- data/.rspec +0 -4
- data/.yardopts +0 -8
- data/benchmark.rake +0 -139
- data/gemfiles/capistrano2.gemfile +0 -6
- data/gemfiles/capistrano3.gemfile +0 -7
- data/gemfiles/dry-monitor.gemfile +0 -5
- data/gemfiles/grape.gemfile +0 -5
- data/gemfiles/hanami-2.0.gemfile +0 -7
- data/gemfiles/hanami-2.1.gemfile +0 -7
- data/gemfiles/http5.gemfile +0 -5
- data/gemfiles/no_dependencies.gemfile +0 -10
- data/gemfiles/padrino.gemfile +0 -7
- data/gemfiles/psych-3.gemfile +0 -5
- data/gemfiles/psych-4.gemfile +0 -5
- data/gemfiles/que.gemfile +0 -5
- data/gemfiles/rails-6.0.gemfile +0 -10
- data/gemfiles/rails-6.1.gemfile +0 -11
- data/gemfiles/rails-7.0.gemfile +0 -11
- data/gemfiles/rails-7.1.gemfile +0 -11
- data/gemfiles/rails-7.2.gemfile +0 -11
- data/gemfiles/redis-4.gemfile +0 -5
- data/gemfiles/redis-5.gemfile +0 -6
- data/gemfiles/resque-2.gemfile +0 -6
- data/gemfiles/sequel.gemfile +0 -10
- data/gemfiles/sinatra.gemfile +0 -5
- data/gemfiles/webmachine1.gemfile +0 -7
- data/gemfiles/webmachine2.gemfile +0 -6
- data/mono.yml +0 -16
- data/spec/.rubocop.yml +0 -7
- data/spec/lib/appsignal/auth_check_spec.rb +0 -84
- data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
- data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
- data/spec/lib/appsignal/check_in/cron_spec.rb +0 -202
- data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -443
- data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
- data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
- data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
- data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
- data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
- data/spec/lib/appsignal/cli/install_spec.rb +0 -848
- data/spec/lib/appsignal/cli_spec.rb +0 -56
- data/spec/lib/appsignal/config_spec.rb +0 -1380
- data/spec/lib/appsignal/demo_spec.rb +0 -83
- data/spec/lib/appsignal/environment_spec.rb +0 -190
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
- data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
- data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
- data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
- data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
- data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
- data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
- data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
- data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
- data/spec/lib/appsignal/extension_spec.rb +0 -178
- data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
- data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
- data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
- data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
- data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
- data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
- data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
- data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
- data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
- data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
- data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
- data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
- data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
- data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
- data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
- data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
- data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
- data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
- data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
- data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
- data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
- data/spec/lib/appsignal/hooks_spec.rb +0 -124
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
- data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
- data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
- data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
- data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
- data/spec/lib/appsignal/integrations/que_spec.rb +0 -152
- data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
- data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
- data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
- data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
- data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
- data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
- data/spec/lib/appsignal/loaders_spec.rb +0 -144
- data/spec/lib/appsignal/logger_spec.rb +0 -205
- data/spec/lib/appsignal/marker_spec.rb +0 -51
- data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
- data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
- data/spec/lib/appsignal/probes_spec.rb +0 -411
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
- data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
- data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
- data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
- data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
- data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
- data/spec/lib/appsignal/rack_spec.rb +0 -243
- data/spec/lib/appsignal/sample_data_spec.rb +0 -238
- data/spec/lib/appsignal/span_spec.rb +0 -141
- data/spec/lib/appsignal/system_spec.rb +0 -126
- data/spec/lib/appsignal/transaction_spec.rb +0 -2111
- data/spec/lib/appsignal/transmitter_spec.rb +0 -198
- data/spec/lib/appsignal/utils/data_spec.rb +0 -166
- data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
- data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
- data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
- data/spec/lib/appsignal/utils/json_spec.rb +0 -44
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
- data/spec/lib/appsignal_spec.rb +0 -1919
- data/spec/lib/puma/appsignal_spec.rb +0 -334
- data/spec/spec_helper.rb +0 -173
- data/spec/support/fixtures/generated_config.yml +0 -24
- data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
- data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
- data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
- data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
- data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
- data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
- data/spec/support/fixtures/uploaded_file.txt +0 -0
- data/spec/support/hanami/hanami_app.rb +0 -29
- data/spec/support/helpers/action_mailer_helpers.rb +0 -25
- data/spec/support/helpers/activejob_helpers.rb +0 -27
- data/spec/support/helpers/api_request_helper.rb +0 -20
- data/spec/support/helpers/cli_helpers.rb +0 -40
- data/spec/support/helpers/config_helpers.rb +0 -66
- data/spec/support/helpers/dependency_helper.rb +0 -150
- data/spec/support/helpers/directory_helper.rb +0 -27
- data/spec/support/helpers/env_helpers.rb +0 -41
- data/spec/support/helpers/environment_metdata_helper.rb +0 -16
- data/spec/support/helpers/example_exception.rb +0 -13
- data/spec/support/helpers/example_standard_error.rb +0 -13
- data/spec/support/helpers/loader_helper.rb +0 -21
- data/spec/support/helpers/log_helpers.rb +0 -36
- data/spec/support/helpers/rails_helper.rb +0 -28
- data/spec/support/helpers/std_streams_helper.rb +0 -94
- data/spec/support/helpers/system_helpers.rb +0 -8
- data/spec/support/helpers/take_at_most_helper.rb +0 -21
- data/spec/support/helpers/time_helpers.rb +0 -11
- data/spec/support/helpers/transaction_helpers.rb +0 -122
- data/spec/support/helpers/wait_for_helper.rb +0 -39
- data/spec/support/matchers/contains_log.rb +0 -26
- data/spec/support/matchers/have_colorized_text.rb +0 -28
- data/spec/support/matchers/transaction.rb +0 -200
- data/spec/support/mocks/appsignal_mock.rb +0 -18
- data/spec/support/mocks/dummy_app.rb +0 -20
- data/spec/support/mocks/fake_gc_profiler.rb +0 -19
- data/spec/support/mocks/fake_gvl_tools.rb +0 -28
- data/spec/support/mocks/hash_like.rb +0 -10
- data/spec/support/mocks/mock_probe.rb +0 -13
- data/spec/support/mocks/puma_mock.rb +0 -43
- data/spec/support/shared_examples/instrument.rb +0 -48
- data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
- data/spec/support/stubs/delayed_job.rb +0 -0
- data/spec/support/stubs/sidekiq/api.rb +0 -4
- data/spec/support/testing.rb +0 -194
- data/support/bundler_wrapper +0 -12
- data/support/install_deps +0 -33
@@ -1,650 +0,0 @@
|
|
1
|
-
if DependencyHelper.active_job_present?
|
2
|
-
require "active_job"
|
3
|
-
require "action_mailer"
|
4
|
-
|
5
|
-
describe Appsignal::Hooks::ActiveJobHook do
|
6
|
-
describe "#dependencies_present?" do
|
7
|
-
subject { described_class.new.dependencies_present? }
|
8
|
-
|
9
|
-
context "when ActiveJob constant is found" do
|
10
|
-
before { stub_const "ActiveJob", Class.new }
|
11
|
-
|
12
|
-
it { is_expected.to be_truthy }
|
13
|
-
end
|
14
|
-
|
15
|
-
context "when ActiveJob constant is not found" do
|
16
|
-
before { hide_const "ActiveJob" }
|
17
|
-
|
18
|
-
it { is_expected.to be_falsy }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#install" do
|
23
|
-
it "extends ActiveJob::Base with the AppSignal ActiveJob plugin" do
|
24
|
-
start_agent
|
25
|
-
|
26
|
-
path, _line_number = ActiveJob::Base.method(:execute).source_location
|
27
|
-
expect(path).to end_with("/lib/appsignal/hooks/active_job.rb")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe Appsignal::Hooks::ActiveJobHook::ActiveJobClassInstrumentation do
|
33
|
-
include ActiveJobHelpers
|
34
|
-
let(:time) { Time.parse("2001-01-01 10:00:00UTC") }
|
35
|
-
let(:namespace) { Appsignal::Transaction::BACKGROUND_JOB }
|
36
|
-
let(:queue) { "default" }
|
37
|
-
let(:parameterized_given_args) do
|
38
|
-
{
|
39
|
-
:foo => "Foo",
|
40
|
-
"bar" => "Bar",
|
41
|
-
"baz" => { "1" => "foo" }
|
42
|
-
}
|
43
|
-
end
|
44
|
-
let(:method_given_args) do
|
45
|
-
[
|
46
|
-
"foo",
|
47
|
-
parameterized_given_args
|
48
|
-
]
|
49
|
-
end
|
50
|
-
let(:parameterized_expected_args) do
|
51
|
-
{
|
52
|
-
"_aj_symbol_keys" => ["foo"],
|
53
|
-
"foo" => "Foo",
|
54
|
-
"bar" => "Bar",
|
55
|
-
"baz" => {
|
56
|
-
"_aj_symbol_keys" => [],
|
57
|
-
"1" => "foo"
|
58
|
-
}
|
59
|
-
}
|
60
|
-
end
|
61
|
-
let(:method_expected_args) do
|
62
|
-
[
|
63
|
-
"foo",
|
64
|
-
parameterized_expected_args
|
65
|
-
]
|
66
|
-
end
|
67
|
-
let(:expected_perform_events) do
|
68
|
-
if DependencyHelper.rails7_present?
|
69
|
-
["perform.active_job", "perform_start.active_job"]
|
70
|
-
else
|
71
|
-
["perform_start.active_job", "perform.active_job"]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
let(:options) { {} }
|
75
|
-
before do
|
76
|
-
ActiveJob::Base.queue_adapter = :inline
|
77
|
-
|
78
|
-
start_agent(:options => options)
|
79
|
-
class ActiveJobTestJob < ActiveJob::Base
|
80
|
-
def perform(*_args)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
class ActiveJobErrorTestJob < ActiveJob::Base
|
85
|
-
def perform
|
86
|
-
raise "uh oh"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
class ActiveJobErrorWithRetryTestJob < ActiveJob::Base
|
91
|
-
retry_on StandardError, :wait => 0.seconds, :attempts => 2
|
92
|
-
|
93
|
-
def perform
|
94
|
-
raise "uh oh"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
class ActiveJobCustomQueueTestJob < ActiveJob::Base
|
99
|
-
queue_as :custom_queue
|
100
|
-
|
101
|
-
def perform(*_args)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
around { |example| keep_transactions { example.run } }
|
106
|
-
after do
|
107
|
-
Object.send(:remove_const, :ActiveJobTestJob)
|
108
|
-
Object.send(:remove_const, :ActiveJobErrorTestJob)
|
109
|
-
Object.send(:remove_const, :ActiveJobErrorWithRetryTestJob)
|
110
|
-
Object.send(:remove_const, :ActiveJobCustomQueueTestJob)
|
111
|
-
end
|
112
|
-
|
113
|
-
it "reports the name from the ActiveJob integration" do
|
114
|
-
tags = { :queue => queue }
|
115
|
-
expect(Appsignal).to receive(:increment_counter)
|
116
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
117
|
-
|
118
|
-
queue_job(ActiveJobTestJob)
|
119
|
-
|
120
|
-
transaction = last_transaction
|
121
|
-
expect(transaction).to have_namespace(namespace)
|
122
|
-
expect(transaction).to have_action("ActiveJobTestJob#perform")
|
123
|
-
expect(transaction).to_not have_error
|
124
|
-
expect(transaction).to_not include_metadata
|
125
|
-
expect(transaction).to include_params([])
|
126
|
-
expect(transaction).to include_tags(
|
127
|
-
"active_job_id" => kind_of(String),
|
128
|
-
"request_id" => kind_of(String),
|
129
|
-
"queue" => queue,
|
130
|
-
"executions" => 1
|
131
|
-
)
|
132
|
-
events = transaction.to_h["events"]
|
133
|
-
.sort_by { |e| e["start"] }
|
134
|
-
.map { |event| event["name"] }
|
135
|
-
expect(events).to eq(expected_perform_events)
|
136
|
-
end
|
137
|
-
|
138
|
-
context "with custom queue" do
|
139
|
-
it "reports the custom queue as tag on the transaction" do
|
140
|
-
tags = { :queue => "custom_queue" }
|
141
|
-
expect(Appsignal).to receive(:increment_counter)
|
142
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
143
|
-
queue_job(ActiveJobCustomQueueTestJob)
|
144
|
-
|
145
|
-
expect(last_transaction).to include_tags("queue" => "custom_queue")
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
if DependencyHelper.rails_version >= Gem::Version.new("5.0.0")
|
150
|
-
context "with priority" do
|
151
|
-
before do
|
152
|
-
class ActiveJobPriorityTestJob < ActiveJob::Base
|
153
|
-
queue_with_priority 10
|
154
|
-
|
155
|
-
def perform(*_args)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
after do
|
160
|
-
Object.send(:remove_const, :ActiveJobPriorityTestJob)
|
161
|
-
end
|
162
|
-
|
163
|
-
it "reports the priority as tag on the transaction" do
|
164
|
-
tags = { :queue => queue }
|
165
|
-
expect(Appsignal).to receive(:increment_counter)
|
166
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
167
|
-
expect(Appsignal).to receive(:increment_counter)
|
168
|
-
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
169
|
-
:status => :processed))
|
170
|
-
|
171
|
-
queue_job(ActiveJobPriorityTestJob)
|
172
|
-
|
173
|
-
expect(last_transaction).to include_tags("queue" => queue, "priority" => 10)
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
context "with error" do
|
179
|
-
it "reports the error on the transaction from the ActiveRecord integration" do
|
180
|
-
allow(Appsignal).to receive(:increment_counter) # Other calls we're testing in another test
|
181
|
-
tags = { :queue => queue }
|
182
|
-
expect(Appsignal).to receive(:increment_counter)
|
183
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :failed))
|
184
|
-
expect(Appsignal).to receive(:increment_counter)
|
185
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
186
|
-
|
187
|
-
expect do
|
188
|
-
queue_job(ActiveJobErrorTestJob)
|
189
|
-
end.to raise_error(RuntimeError, "uh oh")
|
190
|
-
|
191
|
-
transaction = last_transaction
|
192
|
-
expect(transaction).to have_namespace(namespace)
|
193
|
-
expect(transaction).to have_action("ActiveJobErrorTestJob#perform")
|
194
|
-
expect(transaction).to have_error("RuntimeError", "uh oh")
|
195
|
-
expect(transaction).to_not include_metadata
|
196
|
-
expect(transaction).to include_params([])
|
197
|
-
expect(transaction).to include_tags(
|
198
|
-
"active_job_id" => kind_of(String),
|
199
|
-
"request_id" => kind_of(String),
|
200
|
-
"queue" => queue,
|
201
|
-
"executions" => 1
|
202
|
-
)
|
203
|
-
|
204
|
-
events = transaction.to_h["events"]
|
205
|
-
.sort_by { |e| e["start"] }
|
206
|
-
.map { |event| event["name"] }
|
207
|
-
expect(events).to eq(expected_perform_events)
|
208
|
-
end
|
209
|
-
|
210
|
-
context "with activejob_report_errors set to none" do
|
211
|
-
let(:options) { { :activejob_report_errors => "none" } }
|
212
|
-
|
213
|
-
it "does not report the error" do
|
214
|
-
allow(Appsignal).to receive(:increment_counter)
|
215
|
-
tags = { :queue => queue }
|
216
|
-
expect(Appsignal).to receive(:increment_counter)
|
217
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :failed))
|
218
|
-
|
219
|
-
expect do
|
220
|
-
queue_job(ActiveJobErrorTestJob)
|
221
|
-
end.to raise_error(RuntimeError, "uh oh")
|
222
|
-
|
223
|
-
expect(last_transaction).to_not have_error
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
if DependencyHelper.rails_version >= Gem::Version.new("7.1.0")
|
228
|
-
context "with activejob_report_errors set to discard" do
|
229
|
-
let(:options) { { :activejob_report_errors => "discard" } }
|
230
|
-
|
231
|
-
it "does not report error on first failure" do
|
232
|
-
with_test_adapter do
|
233
|
-
# Prevent the job from being instantly retried so we can test
|
234
|
-
# what happens before it's retried
|
235
|
-
allow_any_instance_of(ActiveJobErrorWithRetryTestJob).to receive(:retry_job)
|
236
|
-
|
237
|
-
queue_job(ActiveJobErrorWithRetryTestJob)
|
238
|
-
end
|
239
|
-
|
240
|
-
transaction = last_transaction
|
241
|
-
expect(transaction).to_not have_error
|
242
|
-
expect(transaction).to include_tags("executions" => 1)
|
243
|
-
end
|
244
|
-
|
245
|
-
it "reports error when discarding the job" do
|
246
|
-
allow(Appsignal).to receive(:increment_counter)
|
247
|
-
tags = { :queue => queue }
|
248
|
-
expect(Appsignal).to receive(:increment_counter)
|
249
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :failed))
|
250
|
-
|
251
|
-
with_test_adapter do
|
252
|
-
expect do
|
253
|
-
queue_job(ActiveJobErrorWithRetryTestJob)
|
254
|
-
end.to raise_error(RuntimeError, "uh oh")
|
255
|
-
end
|
256
|
-
|
257
|
-
transaction = last_transaction
|
258
|
-
expect(transaction).to have_error("RuntimeError", "uh oh")
|
259
|
-
expect(transaction).to include_tags("executions" => 2)
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
if DependencyHelper.rails_version >= Gem::Version.new("5.0.0")
|
265
|
-
context "with priority" do
|
266
|
-
before do
|
267
|
-
class ActiveJobErrorPriorityTestJob < ActiveJob::Base
|
268
|
-
queue_with_priority 10
|
269
|
-
|
270
|
-
def perform(*_args)
|
271
|
-
raise "uh oh"
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
after do
|
276
|
-
Object.send(:remove_const, :ActiveJobErrorPriorityTestJob)
|
277
|
-
end
|
278
|
-
|
279
|
-
it "reports the priority as tag on the transaction" do
|
280
|
-
tags = { :queue => queue }
|
281
|
-
expect(Appsignal).to receive(:increment_counter)
|
282
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
|
283
|
-
expect(Appsignal).to receive(:increment_counter)
|
284
|
-
.with("active_job_queue_job_count", 1, tags.merge(:status => :failed))
|
285
|
-
expect(Appsignal).to receive(:increment_counter)
|
286
|
-
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
287
|
-
:status => :processed))
|
288
|
-
expect(Appsignal).to receive(:increment_counter)
|
289
|
-
.with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
|
290
|
-
:status => :failed))
|
291
|
-
|
292
|
-
expect do
|
293
|
-
queue_job(ActiveJobErrorPriorityTestJob)
|
294
|
-
end.to raise_error(RuntimeError, "uh oh")
|
295
|
-
|
296
|
-
expect(last_transaction).to include_tags("queue" => queue, "priority" => 10)
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
context "with retries" do
|
303
|
-
it "reports the number of retries as executions" do
|
304
|
-
with_test_adapter do
|
305
|
-
expect do
|
306
|
-
queue_job(ActiveJobErrorWithRetryTestJob)
|
307
|
-
end.to raise_error(RuntimeError, "uh oh")
|
308
|
-
end
|
309
|
-
|
310
|
-
expect(last_transaction).to include_tags("executions" => 2)
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
context "when wrapped in another transaction" do
|
315
|
-
it "does not create a new transaction or close the currently open one" do
|
316
|
-
current_transaction = background_job_transaction
|
317
|
-
set_current_transaction current_transaction
|
318
|
-
|
319
|
-
queue_job(ActiveJobTestJob)
|
320
|
-
|
321
|
-
expect(created_transactions.count).to eql(1)
|
322
|
-
|
323
|
-
transaction = current_transaction
|
324
|
-
expect(transaction).to_not be_completed
|
325
|
-
transaction._sample
|
326
|
-
# It does set data on the transaction
|
327
|
-
expect(transaction).to have_namespace(namespace)
|
328
|
-
expect(transaction).to have_id(current_transaction.transaction_id)
|
329
|
-
expect(transaction).to have_action("ActiveJobTestJob#perform")
|
330
|
-
expect(transaction).to_not have_error
|
331
|
-
expect(transaction).to_not include_metadata
|
332
|
-
expect(transaction).to include_params([])
|
333
|
-
expect(transaction).to include_tags(
|
334
|
-
"active_job_id" => kind_of(String),
|
335
|
-
"request_id" => kind_of(String),
|
336
|
-
"queue" => queue,
|
337
|
-
"executions" => 1
|
338
|
-
)
|
339
|
-
|
340
|
-
events = transaction.to_h["events"]
|
341
|
-
.reject { |e| e["name"] == "enqueue.active_job" }
|
342
|
-
.sort_by { |e| e["start"] }
|
343
|
-
.map { |event| event["name"] }
|
344
|
-
expect(events).to eq(expected_perform_events)
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
|
-
context "with params" do
|
349
|
-
let(:options) { { :filter_parameters => ["foo"] } }
|
350
|
-
|
351
|
-
it "filters the configured params" do
|
352
|
-
queue_job(ActiveJobTestJob, method_given_args)
|
353
|
-
|
354
|
-
transaction = last_transaction
|
355
|
-
transaction_hash = transaction.to_h
|
356
|
-
expect(transaction_hash["sample_data"]["params"]).to include(
|
357
|
-
[
|
358
|
-
"foo",
|
359
|
-
{
|
360
|
-
"_aj_symbol_keys" => ["foo"],
|
361
|
-
"foo" => "[FILTERED]",
|
362
|
-
"bar" => "Bar",
|
363
|
-
"baz" => { "_aj_symbol_keys" => [], "1" => "foo" }
|
364
|
-
}
|
365
|
-
]
|
366
|
-
)
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
|
-
context "with provider_job_id",
|
371
|
-
:skip => DependencyHelper.rails_version < Gem::Version.new("5.0.0") do
|
372
|
-
before do
|
373
|
-
module ActiveJob
|
374
|
-
module QueueAdapters
|
375
|
-
# Adapter used in our test suite to add provider data to the job
|
376
|
-
# data, as is done by Rails provided ActiveJob adapters.
|
377
|
-
#
|
378
|
-
# This implementation is based on the
|
379
|
-
# `ActiveJob::QueueAdapters::InlineAdapter`.
|
380
|
-
class AppsignalTestAdapter < InlineAdapter
|
381
|
-
def enqueue(job)
|
382
|
-
Base.execute(job.serialize.merge("provider_job_id" => "my_provider_job_id"))
|
383
|
-
end
|
384
|
-
end
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
class ProviderWrappedActiveJobTestJob < ActiveJob::Base
|
389
|
-
self.queue_adapter = :appsignal_test
|
390
|
-
|
391
|
-
def perform(*_args)
|
392
|
-
end
|
393
|
-
end
|
394
|
-
end
|
395
|
-
after do
|
396
|
-
ActiveJob::QueueAdapters.send(:remove_const, :AppsignalTestAdapter)
|
397
|
-
Object.send(:remove_const, :ProviderWrappedActiveJobTestJob)
|
398
|
-
end
|
399
|
-
|
400
|
-
it "sets provider_job_id as tag" do
|
401
|
-
queue_job(ProviderWrappedActiveJobTestJob)
|
402
|
-
|
403
|
-
expect(last_transaction).to include_tags(
|
404
|
-
"provider_job_id" => "my_provider_job_id"
|
405
|
-
)
|
406
|
-
end
|
407
|
-
end
|
408
|
-
|
409
|
-
context "with enqueued_at",
|
410
|
-
:skip => DependencyHelper.rails_version < Gem::Version.new("6.0.0") do
|
411
|
-
before do
|
412
|
-
module ActiveJob
|
413
|
-
module QueueAdapters
|
414
|
-
# Adapter used in our test suite to add provider data to the job
|
415
|
-
# data, as is done by Rails provided ActiveJob adapters.
|
416
|
-
#
|
417
|
-
# This implementation is based on the
|
418
|
-
# `ActiveJob::QueueAdapters::InlineAdapter`.
|
419
|
-
class AppsignalTestAdapter < InlineAdapter
|
420
|
-
def enqueue(job)
|
421
|
-
Base.execute(job.serialize.merge("enqueued_at" => "2020-10-10T10:10:10Z"))
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
class ProviderWrappedActiveJobTestJob < ActiveJob::Base
|
428
|
-
self.queue_adapter = :appsignal_test
|
429
|
-
|
430
|
-
def perform(*_args)
|
431
|
-
end
|
432
|
-
end
|
433
|
-
end
|
434
|
-
after do
|
435
|
-
ActiveJob::QueueAdapters.send(:remove_const, :AppsignalTestAdapter)
|
436
|
-
Object.send(:remove_const, :ProviderWrappedActiveJobTestJob)
|
437
|
-
end
|
438
|
-
|
439
|
-
it "sets queue time on transaction" do
|
440
|
-
queue_job(ProviderWrappedActiveJobTestJob)
|
441
|
-
|
442
|
-
queue_time = Time.parse("2020-10-10T10:10:10Z")
|
443
|
-
expect(last_transaction).to have_queue_start((queue_time.to_f * 1_000).to_i)
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
context "with ActionMailer job" do
|
448
|
-
include ActionMailerHelpers
|
449
|
-
|
450
|
-
before do
|
451
|
-
class ActionMailerTestJob < ActionMailer::Base
|
452
|
-
def welcome(_first_arg = nil, _second_arg = nil)
|
453
|
-
end
|
454
|
-
end
|
455
|
-
end
|
456
|
-
after do
|
457
|
-
Object.send(:remove_const, :ActionMailerTestJob)
|
458
|
-
end
|
459
|
-
|
460
|
-
context "without params" do
|
461
|
-
it "sets the Action mailer data on the transaction" do
|
462
|
-
perform_mailer(ActionMailerTestJob, :welcome)
|
463
|
-
|
464
|
-
transaction = last_transaction
|
465
|
-
expect(transaction).to have_action("ActionMailerTestJob#welcome")
|
466
|
-
expect(transaction).to include_params(
|
467
|
-
["ActionMailerTestJob", "welcome", "deliver_now"] + active_job_args_wrapper
|
468
|
-
)
|
469
|
-
expect(transaction).to include_tags(
|
470
|
-
"active_job_id" => kind_of(String),
|
471
|
-
"request_id" => kind_of(String),
|
472
|
-
"queue" => "mailers",
|
473
|
-
"executions" => 1
|
474
|
-
)
|
475
|
-
end
|
476
|
-
end
|
477
|
-
|
478
|
-
context "with multiple arguments" do
|
479
|
-
it "sets the arguments on the transaction" do
|
480
|
-
perform_mailer(ActionMailerTestJob, :welcome, method_given_args)
|
481
|
-
|
482
|
-
transaction = last_transaction
|
483
|
-
expect(transaction).to have_action("ActionMailerTestJob#welcome")
|
484
|
-
expect(transaction).to include_params(
|
485
|
-
["ActionMailerTestJob", "welcome",
|
486
|
-
"deliver_now"] + active_job_args_wrapper(:args => method_expected_args)
|
487
|
-
)
|
488
|
-
expect(transaction).to include_tags(
|
489
|
-
"active_job_id" => kind_of(String),
|
490
|
-
"request_id" => kind_of(String),
|
491
|
-
"queue" => "mailers",
|
492
|
-
"executions" => 1
|
493
|
-
)
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
if DependencyHelper.rails_version >= Gem::Version.new("5.2.0")
|
498
|
-
context "with parameterized arguments" do
|
499
|
-
it "sets the arguments on the transaction" do
|
500
|
-
perform_mailer(ActionMailerTestJob, :welcome, parameterized_given_args)
|
501
|
-
|
502
|
-
transaction = last_transaction
|
503
|
-
expect(transaction).to have_action("ActionMailerTestJob#welcome")
|
504
|
-
expect(transaction).to include_params(
|
505
|
-
[
|
506
|
-
"ActionMailerTestJob",
|
507
|
-
"welcome",
|
508
|
-
"deliver_now"
|
509
|
-
] + active_job_args_wrapper(:params => parameterized_expected_args)
|
510
|
-
)
|
511
|
-
expect(transaction).to include_tags(
|
512
|
-
"active_job_id" => kind_of(String),
|
513
|
-
"request_id" => kind_of(String),
|
514
|
-
"queue" => "mailers",
|
515
|
-
"executions" => 1
|
516
|
-
)
|
517
|
-
end
|
518
|
-
end
|
519
|
-
end
|
520
|
-
end
|
521
|
-
|
522
|
-
if DependencyHelper.rails_version >= Gem::Version.new("6.0.0")
|
523
|
-
context "with ActionMailer MailDeliveryJob job" do
|
524
|
-
include ActionMailerHelpers
|
525
|
-
|
526
|
-
before do
|
527
|
-
class ActionMailerTestMailDeliveryJob < ActionMailer::Base
|
528
|
-
self.delivery_job = ActionMailer::MailDeliveryJob
|
529
|
-
|
530
|
-
def welcome(*_args)
|
531
|
-
end
|
532
|
-
end
|
533
|
-
end
|
534
|
-
after do
|
535
|
-
Object.send(:remove_const, :ActionMailerTestMailDeliveryJob)
|
536
|
-
end
|
537
|
-
|
538
|
-
it "sets the Action mailer data on the transaction" do
|
539
|
-
perform_mailer(ActionMailerTestMailDeliveryJob, :welcome)
|
540
|
-
|
541
|
-
transaction = last_transaction
|
542
|
-
expect(transaction).to have_action("ActionMailerTestMailDeliveryJob#welcome")
|
543
|
-
expect(transaction).to include_params(
|
544
|
-
[
|
545
|
-
"ActionMailerTestMailDeliveryJob",
|
546
|
-
"welcome",
|
547
|
-
"deliver_now",
|
548
|
-
{ active_job_internal_key => ["args"], "args" => [] }
|
549
|
-
]
|
550
|
-
)
|
551
|
-
expect(transaction).to include_tags(
|
552
|
-
"active_job_id" => kind_of(String),
|
553
|
-
"request_id" => kind_of(String),
|
554
|
-
"queue" => "mailers",
|
555
|
-
"executions" => 1
|
556
|
-
)
|
557
|
-
end
|
558
|
-
|
559
|
-
context "with method arguments" do
|
560
|
-
it "sets the Action mailer data on the transaction" do
|
561
|
-
perform_mailer(ActionMailerTestMailDeliveryJob, :welcome, method_given_args)
|
562
|
-
|
563
|
-
transaction = last_transaction
|
564
|
-
expect(transaction).to have_action("ActionMailerTestMailDeliveryJob#welcome")
|
565
|
-
expect(transaction).to include_params(
|
566
|
-
[
|
567
|
-
"ActionMailerTestMailDeliveryJob",
|
568
|
-
"welcome",
|
569
|
-
"deliver_now",
|
570
|
-
{
|
571
|
-
active_job_internal_key => ["args"],
|
572
|
-
"args" => method_expected_args
|
573
|
-
}
|
574
|
-
]
|
575
|
-
)
|
576
|
-
expect(transaction).to include_tags(
|
577
|
-
"active_job_id" => kind_of(String),
|
578
|
-
"request_id" => kind_of(String),
|
579
|
-
"queue" => "mailers",
|
580
|
-
"executions" => 1
|
581
|
-
)
|
582
|
-
end
|
583
|
-
end
|
584
|
-
|
585
|
-
context "with parameterized arguments" do
|
586
|
-
it "sets the Action mailer data on the transaction" do
|
587
|
-
perform_mailer(ActionMailerTestMailDeliveryJob, :welcome, parameterized_given_args)
|
588
|
-
|
589
|
-
transaction = last_transaction
|
590
|
-
expect(transaction).to have_action("ActionMailerTestMailDeliveryJob#welcome")
|
591
|
-
expect(transaction).to include_params(
|
592
|
-
[
|
593
|
-
"ActionMailerTestMailDeliveryJob",
|
594
|
-
"welcome",
|
595
|
-
"deliver_now",
|
596
|
-
{
|
597
|
-
active_job_internal_key => ["params", "args"],
|
598
|
-
"args" => [],
|
599
|
-
"params" => parameterized_expected_args
|
600
|
-
}
|
601
|
-
]
|
602
|
-
)
|
603
|
-
expect(transaction).to include_tags(
|
604
|
-
"active_job_id" => kind_of(String),
|
605
|
-
"request_id" => kind_of(String),
|
606
|
-
"queue" => "mailers",
|
607
|
-
"executions" => 1
|
608
|
-
)
|
609
|
-
end
|
610
|
-
end
|
611
|
-
end
|
612
|
-
end
|
613
|
-
|
614
|
-
def with_test_adapter
|
615
|
-
ActiveJob::Base.queue_adapter = :test
|
616
|
-
ActiveJob::Base.queue_adapter.performed_jobs.clear
|
617
|
-
ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
|
618
|
-
ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true
|
619
|
-
yield
|
620
|
-
ensure
|
621
|
-
ActiveJob::Base.queue_adapter = :inline # Restore to default
|
622
|
-
end
|
623
|
-
|
624
|
-
def perform_active_job(&block)
|
625
|
-
Timecop.freeze(time, &block)
|
626
|
-
end
|
627
|
-
|
628
|
-
def queue_job(job_class, args = nil)
|
629
|
-
perform_active_job do
|
630
|
-
if args
|
631
|
-
job_class.perform_later(args)
|
632
|
-
else
|
633
|
-
job_class.perform_later
|
634
|
-
end
|
635
|
-
end
|
636
|
-
end
|
637
|
-
|
638
|
-
def perform_mailer(mailer, method, args = nil)
|
639
|
-
perform_active_job { perform_action_mailer(mailer, method, args) }
|
640
|
-
end
|
641
|
-
|
642
|
-
def active_job_internal_key
|
643
|
-
if DependencyHelper.ruby_version >= Gem::Version.new("2.7.0")
|
644
|
-
"_aj_ruby2_keywords"
|
645
|
-
else
|
646
|
-
"_aj_symbol_keys"
|
647
|
-
end
|
648
|
-
end
|
649
|
-
end
|
650
|
-
end
|