appsignal 4.0.6-java → 4.0.8-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Rakefile +9 -9
- data/appsignal.gemspec +22 -1
- data/ext/agent.rb +27 -27
- data/lib/appsignal/check_in.rb +1 -1
- data/lib/appsignal/config.rb +1 -3
- data/lib/appsignal/integrations/resque.rb +1 -6
- data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +10 -8
- metadata +2 -192
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- data/.github/ISSUE_TEMPLATE/chore.md +0 -14
- data/.github/workflows/ci.yml +0 -3285
- 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-1.gemfile +0 -5
- data/gemfiles/que-2.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 -210
- data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -557
- 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 -187
- 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 -414
- 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 -2115
- 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 -179
- 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 -60
- 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 -155
- 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 -203
- data/support/bundler_wrapper +0 -12
- data/support/install_deps +0 -33
@@ -1,345 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::ActionCableHook do
|
2
|
-
if DependencyHelper.action_cable_present?
|
3
|
-
context "with ActionCable" do
|
4
|
-
require "action_cable/engine"
|
5
|
-
# Require test helper to test with ConnectionStub
|
6
|
-
require "action_cable/channel/test_case" if DependencyHelper.rails6_present?
|
7
|
-
|
8
|
-
describe ".dependencies_present?" do
|
9
|
-
subject { described_class.new.dependencies_present? }
|
10
|
-
|
11
|
-
it "returns true" do
|
12
|
-
is_expected.to be_truthy
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe ActionCable::Channel::Base do
|
17
|
-
let(:channel) do
|
18
|
-
Class.new(ActionCable::Channel::Base) do
|
19
|
-
def speak(_data)
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.to_s
|
23
|
-
"MyChannel"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
let(:log) { StringIO.new }
|
28
|
-
let(:server) do
|
29
|
-
ActionCable::Server::Base.new.tap do |s|
|
30
|
-
s.config.logger = ActiveSupport::Logger.new(log)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
let(:env) do
|
34
|
-
http_request_env_with_data(
|
35
|
-
"action_dispatch.request_id" => request_id,
|
36
|
-
:params => params,
|
37
|
-
:with_queue_start => true
|
38
|
-
)
|
39
|
-
end
|
40
|
-
let(:connection) { ActionCable::Connection::Base.new(server, env) }
|
41
|
-
let(:identifier) { { :channel => "MyChannel" }.to_json }
|
42
|
-
let(:params) { {} }
|
43
|
-
let(:request_id) { SecureRandom.uuid }
|
44
|
-
let(:instance) { channel.new(connection, identifier, params) }
|
45
|
-
before do
|
46
|
-
start_agent
|
47
|
-
|
48
|
-
# Stub transmit call for subscribe/unsubscribe tests
|
49
|
-
allow(connection).to receive(:websocket)
|
50
|
-
.and_return(instance_double("ActionCable::Connection::WebSocket", :transmit => nil))
|
51
|
-
end
|
52
|
-
around { |example| keep_transactions { example.run } }
|
53
|
-
|
54
|
-
describe "#perform_action" do
|
55
|
-
it "creates a transaction for an action" do
|
56
|
-
instance.perform_action("message" => "foo", "action" => "speak")
|
57
|
-
|
58
|
-
transaction = last_transaction
|
59
|
-
expect(transaction).to have_id
|
60
|
-
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
61
|
-
expect(transaction).to have_action("MyChannel#speak")
|
62
|
-
expect(transaction).to_not have_error
|
63
|
-
expect(transaction).to include_metadata(
|
64
|
-
"method" => "websocket",
|
65
|
-
"path" => "/blog"
|
66
|
-
)
|
67
|
-
expect(transaction).to include_event(
|
68
|
-
"body" => "",
|
69
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
70
|
-
"count" => 1,
|
71
|
-
"name" => "perform_action.action_cable",
|
72
|
-
"title" => ""
|
73
|
-
)
|
74
|
-
expect(transaction).to include_params(
|
75
|
-
"action" => "speak",
|
76
|
-
"message" => "foo"
|
77
|
-
)
|
78
|
-
expect(transaction).to include_tags("request_id" => request_id)
|
79
|
-
expect(transaction).to_not have_queue_start
|
80
|
-
expect(transaction).to be_completed
|
81
|
-
end
|
82
|
-
|
83
|
-
context "without request_id (standalone server)" do
|
84
|
-
let(:request_id) { nil }
|
85
|
-
|
86
|
-
it "sets a generated request ID" do
|
87
|
-
# Subscribe action, sets the request_id
|
88
|
-
instance.subscribe_to_channel
|
89
|
-
|
90
|
-
instance.perform_action("message" => "foo", "action" => "speak")
|
91
|
-
expect(last_transaction).to include_tags("request_id" => kind_of(String))
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context "with an error in the action" do
|
96
|
-
let(:channel) do
|
97
|
-
Class.new(ActionCable::Channel::Base) do
|
98
|
-
def speak(_data)
|
99
|
-
raise ExampleException, "oh no!"
|
100
|
-
end
|
101
|
-
|
102
|
-
def self.to_s
|
103
|
-
"MyChannel"
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
it "registers an error on the transaction" do
|
109
|
-
expect do
|
110
|
-
instance.perform_action("message" => "foo", "action" => "speak")
|
111
|
-
end.to raise_error(ExampleException)
|
112
|
-
|
113
|
-
transaction = last_transaction
|
114
|
-
expect(transaction).to have_id
|
115
|
-
expect(transaction).to have_action("MyChannel#speak")
|
116
|
-
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
117
|
-
expect(transaction).to have_error("ExampleException", "oh no!")
|
118
|
-
expect(transaction).to include_metadata(
|
119
|
-
"method" => "websocket",
|
120
|
-
"path" => "/blog"
|
121
|
-
)
|
122
|
-
expect(transaction).to include_params(
|
123
|
-
"action" => "speak",
|
124
|
-
"message" => "foo"
|
125
|
-
)
|
126
|
-
expect(transaction).to_not have_queue_start
|
127
|
-
expect(transaction).to be_completed
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe "subscribe callback" do
|
133
|
-
let(:params) { { "internal" => true } }
|
134
|
-
|
135
|
-
it "creates a transaction for a subscription" do
|
136
|
-
instance.subscribe_to_channel
|
137
|
-
|
138
|
-
transaction = last_transaction
|
139
|
-
expect(transaction).to have_id
|
140
|
-
expect(transaction).to have_action("MyChannel#subscribed")
|
141
|
-
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
142
|
-
expect(transaction).to_not have_error
|
143
|
-
expect(transaction).to include_metadata(
|
144
|
-
"method" => "websocket",
|
145
|
-
"path" => "/blog"
|
146
|
-
)
|
147
|
-
expect(transaction).to include_params("internal" => "true")
|
148
|
-
expect(transaction).to include_event(
|
149
|
-
"body" => "",
|
150
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
151
|
-
"count" => 1,
|
152
|
-
"name" => "subscribed.action_cable",
|
153
|
-
"title" => ""
|
154
|
-
)
|
155
|
-
expect(transaction).to include_tags("request_id" => request_id)
|
156
|
-
expect(transaction).to_not have_queue_start
|
157
|
-
expect(transaction).to be_completed
|
158
|
-
end
|
159
|
-
|
160
|
-
context "without request_id (standalone server)" do
|
161
|
-
let(:request_id) { nil }
|
162
|
-
before { instance.subscribe_to_channel }
|
163
|
-
|
164
|
-
it "sets a generated request ID" do
|
165
|
-
expect(last_transaction).to include_tags("request_id" => kind_of(String))
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
context "with an error in the callback" do
|
170
|
-
let(:channel) do
|
171
|
-
Class.new(ActionCable::Channel::Base) do
|
172
|
-
def subscribed
|
173
|
-
raise ExampleException, "oh no!"
|
174
|
-
end
|
175
|
-
|
176
|
-
def self.to_s
|
177
|
-
"MyChannel"
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
it "registers an error on the transaction" do
|
183
|
-
expect do
|
184
|
-
instance.subscribe_to_channel
|
185
|
-
end.to raise_error(ExampleException)
|
186
|
-
|
187
|
-
transaction = last_transaction
|
188
|
-
expect(transaction).to have_id
|
189
|
-
expect(transaction).to have_action("MyChannel#subscribed")
|
190
|
-
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
191
|
-
expect(transaction).to have_error("ExampleException", "oh no!")
|
192
|
-
expect(transaction).to include_metadata(
|
193
|
-
"method" => "websocket",
|
194
|
-
"path" => "/blog"
|
195
|
-
)
|
196
|
-
expect(transaction).to include_params("internal" => "true")
|
197
|
-
expect(transaction).to_not have_queue_start
|
198
|
-
expect(transaction).to be_completed
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
if DependencyHelper.rails6_present?
|
203
|
-
context "with ConnectionStub" do
|
204
|
-
let(:connection) { ActionCable::Channel::ConnectionStub.new }
|
205
|
-
|
206
|
-
it "does not fail on missing `#env` method on `ConnectionStub`" do
|
207
|
-
instance.subscribe_to_channel
|
208
|
-
|
209
|
-
transaction = last_transaction
|
210
|
-
expect(transaction).to have_id
|
211
|
-
expect(transaction).to have_action("MyChannel#subscribed")
|
212
|
-
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
213
|
-
expect(transaction).to_not have_error
|
214
|
-
expect(transaction).to include_metadata(
|
215
|
-
"method" => "websocket",
|
216
|
-
"path" => "" # No path as the ConnectionStub doesn't have the real request env
|
217
|
-
)
|
218
|
-
expect(transaction).to_not include_params
|
219
|
-
expect(transaction).to include_event(
|
220
|
-
"body" => "",
|
221
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
222
|
-
"count" => 1,
|
223
|
-
"name" => "subscribed.action_cable",
|
224
|
-
"title" => ""
|
225
|
-
)
|
226
|
-
expect(transaction).to_not have_queue_start
|
227
|
-
expect(transaction).to be_completed
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
describe "unsubscribe callback" do
|
234
|
-
let(:params) { { "internal" => true } }
|
235
|
-
|
236
|
-
it "creates a transaction for a subscription" do
|
237
|
-
instance.unsubscribe_from_channel
|
238
|
-
|
239
|
-
transaction = last_transaction
|
240
|
-
expect(transaction).to have_id
|
241
|
-
expect(transaction).to have_action("MyChannel#unsubscribed")
|
242
|
-
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
243
|
-
expect(transaction).to_not have_error
|
244
|
-
expect(transaction).to include_metadata(
|
245
|
-
"method" => "websocket",
|
246
|
-
"path" => "/blog"
|
247
|
-
)
|
248
|
-
expect(transaction).to include_params("internal" => "true")
|
249
|
-
expect(transaction).to include_event(
|
250
|
-
"body" => "",
|
251
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
252
|
-
"count" => 1,
|
253
|
-
"name" => "unsubscribed.action_cable",
|
254
|
-
"title" => ""
|
255
|
-
)
|
256
|
-
expect(transaction).to_not have_queue_start
|
257
|
-
expect(transaction).to be_completed
|
258
|
-
end
|
259
|
-
|
260
|
-
context "without request_id (standalone server)" do
|
261
|
-
let(:request_id) { nil }
|
262
|
-
before { instance.unsubscribe_from_channel }
|
263
|
-
|
264
|
-
it "sets a generated request ID" do
|
265
|
-
expect(last_transaction).to include_tags("request_id" => kind_of(String))
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
context "with an error in the callback" do
|
270
|
-
let(:channel) do
|
271
|
-
Class.new(ActionCable::Channel::Base) do
|
272
|
-
def unsubscribed
|
273
|
-
raise ExampleException, "oh no!"
|
274
|
-
end
|
275
|
-
|
276
|
-
def self.to_s
|
277
|
-
"MyChannel"
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
it "registers an error on the transaction" do
|
283
|
-
expect do
|
284
|
-
instance.unsubscribe_from_channel
|
285
|
-
end.to raise_error(ExampleException)
|
286
|
-
|
287
|
-
transaction = last_transaction
|
288
|
-
expect(transaction).to have_id
|
289
|
-
expect(transaction).to have_action("MyChannel#unsubscribed")
|
290
|
-
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
291
|
-
expect(transaction).to have_error("ExampleException", "oh no!")
|
292
|
-
expect(transaction).to include_metadata(
|
293
|
-
"method" => "websocket",
|
294
|
-
"path" => "/blog"
|
295
|
-
)
|
296
|
-
expect(transaction).to include_params("internal" => "true")
|
297
|
-
expect(transaction).to_not have_queue_start
|
298
|
-
expect(transaction).to be_completed
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
if DependencyHelper.rails6_present?
|
303
|
-
context "with ConnectionStub" do
|
304
|
-
let(:connection) { ActionCable::Channel::ConnectionStub.new }
|
305
|
-
|
306
|
-
it "does not fail on missing `#env` method on `ConnectionStub`" do
|
307
|
-
instance.unsubscribe_from_channel
|
308
|
-
|
309
|
-
transaction = last_transaction
|
310
|
-
expect(transaction).to have_id
|
311
|
-
expect(transaction).to have_action("MyChannel#unsubscribed")
|
312
|
-
expect(transaction).to have_namespace(Appsignal::Transaction::ACTION_CABLE)
|
313
|
-
expect(transaction).to_not have_error
|
314
|
-
expect(transaction).to include_metadata(
|
315
|
-
"method" => "websocket",
|
316
|
-
"path" => "" # No path as the ConnectionStub doesn't have the real request env
|
317
|
-
)
|
318
|
-
expect(transaction).to_not include_params
|
319
|
-
expect(transaction).to include_event(
|
320
|
-
"body" => "",
|
321
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
322
|
-
"count" => 1,
|
323
|
-
"name" => "unsubscribed.action_cable",
|
324
|
-
"title" => ""
|
325
|
-
)
|
326
|
-
expect(transaction).to_not have_queue_start
|
327
|
-
expect(transaction).to be_completed
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
end
|
334
|
-
else
|
335
|
-
context "without ActionCable" do
|
336
|
-
describe ".dependencies_present?" do
|
337
|
-
subject { described_class.new.dependencies_present? }
|
338
|
-
|
339
|
-
it "returns false" do
|
340
|
-
is_expected.to be_falsy
|
341
|
-
end
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
describe Appsignal::Hooks::ActionMailerHook do
|
2
|
-
if DependencyHelper.action_mailer_present? &&
|
3
|
-
DependencyHelper.rails_version >= Gem::Version.new("4.0.0")
|
4
|
-
context "with ActionMailer" do
|
5
|
-
require "action_mailer"
|
6
|
-
|
7
|
-
class UserMailer < ActionMailer::Base
|
8
|
-
default :from => "test@example.com"
|
9
|
-
|
10
|
-
def welcome
|
11
|
-
mail(:to => "test@example.com", :subject => "ActionMailer test",
|
12
|
-
:content_type => "text/html") do |format|
|
13
|
-
format.html { render :html => "This is a test" }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
UserMailer.delivery_method = :test
|
18
|
-
|
19
|
-
describe ".dependencies_present?" do
|
20
|
-
subject { described_class.new.dependencies_present? }
|
21
|
-
|
22
|
-
it "returns true" do
|
23
|
-
is_expected.to be_truthy
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe ".install" do
|
28
|
-
before do
|
29
|
-
start_agent
|
30
|
-
expect(Appsignal.active?).to be_truthy
|
31
|
-
end
|
32
|
-
|
33
|
-
it "is subscribed to 'process.action_mailer' and processes instrumentation" do
|
34
|
-
expect(Appsignal).to receive(:increment_counter).with(
|
35
|
-
:action_mailer_process,
|
36
|
-
1,
|
37
|
-
:mailer => "UserMailer", :action => :welcome
|
38
|
-
)
|
39
|
-
|
40
|
-
UserMailer.welcome.deliver_now
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
else
|
45
|
-
context "without ActionMailer" do
|
46
|
-
describe ".dependencies_present?" do
|
47
|
-
subject { described_class.new.dependencies_present? }
|
48
|
-
|
49
|
-
it "returns false" do
|
50
|
-
is_expected.to be_falsy
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
shared_examples "activesupport finish_with_state override" do
|
2
|
-
let(:instrumenter) { as.instrumenter }
|
3
|
-
|
4
|
-
it "instruments an ActiveSupport::Notifications.start/finish event with payload on finish" do
|
5
|
-
listeners_state = instrumenter.start("sql.active_record", {})
|
6
|
-
instrumenter.finish_with_state(listeners_state, "sql.active_record", :sql => "SQL")
|
7
|
-
|
8
|
-
expect(transaction).to include_event(
|
9
|
-
"body" => "SQL",
|
10
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
11
|
-
"count" => 1,
|
12
|
-
"name" => "sql.active_record",
|
13
|
-
"title" => ""
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "does not instrument events whose name starts with a bang" do
|
18
|
-
listeners_state = instrumenter.start("!sql.active_record", {})
|
19
|
-
instrumenter.finish_with_state(listeners_state, "!sql.active_record", :sql => "SQL")
|
20
|
-
|
21
|
-
expect(transaction).to_not include_events
|
22
|
-
end
|
23
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
shared_examples "activesupport instrument override" do
|
2
|
-
it "instruments an ActiveSupport::Notifications.instrument event" do
|
3
|
-
return_value = as.instrument("sql.active_record", :sql => "SQL") do
|
4
|
-
"value"
|
5
|
-
end
|
6
|
-
|
7
|
-
expect(return_value).to eq "value"
|
8
|
-
expect(transaction).to include_event(
|
9
|
-
"body" => "SQL",
|
10
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
11
|
-
"count" => 1,
|
12
|
-
"name" => "sql.active_record",
|
13
|
-
"title" => ""
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "instruments an ActiveSupport::Notifications.instrument event with no registered formatter" do
|
18
|
-
return_value = as.instrument("no-registered.formatter", :key => "something") do
|
19
|
-
"value"
|
20
|
-
end
|
21
|
-
|
22
|
-
expect(return_value).to eq "value"
|
23
|
-
expect(transaction).to include_event(
|
24
|
-
"body" => "",
|
25
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
26
|
-
"count" => 1,
|
27
|
-
"name" => "no-registered.formatter",
|
28
|
-
"title" => ""
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "converts non-string names to strings" do
|
33
|
-
as.instrument(:not_a_string) {} # rubocop:disable Lint/EmptyBlock
|
34
|
-
expect(transaction).to include_event(
|
35
|
-
"body" => "",
|
36
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
37
|
-
"count" => 1,
|
38
|
-
"name" => "not_a_string",
|
39
|
-
"title" => ""
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "does not instrument events whose name starts with a bang" do
|
44
|
-
return_value = as.instrument("!sql.active_record", :sql => "SQL") do
|
45
|
-
"value"
|
46
|
-
end
|
47
|
-
|
48
|
-
expect(return_value).to eq "value"
|
49
|
-
|
50
|
-
expect(transaction).to_not include_events
|
51
|
-
end
|
52
|
-
|
53
|
-
context "when an error is raised in an instrumented block" do
|
54
|
-
it "instruments an ActiveSupport::Notifications.instrument event" do
|
55
|
-
expect do
|
56
|
-
as.instrument("sql.active_record", :sql => "SQL") do
|
57
|
-
raise ExampleException, "foo"
|
58
|
-
end
|
59
|
-
end.to raise_error(ExampleException, "foo")
|
60
|
-
|
61
|
-
expect(transaction).to include_event(
|
62
|
-
"body" => "SQL",
|
63
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
64
|
-
"count" => 1,
|
65
|
-
"name" => "sql.active_record",
|
66
|
-
"title" => ""
|
67
|
-
)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "when a message is thrown in an instrumented block" do
|
72
|
-
it "instruments an ActiveSupport::Notifications.instrument event" do
|
73
|
-
expect do
|
74
|
-
as.instrument("sql.active_record", :sql => "SQL") do
|
75
|
-
throw :foo
|
76
|
-
end
|
77
|
-
end.to throw_symbol(:foo)
|
78
|
-
|
79
|
-
expect(transaction).to include_event(
|
80
|
-
"body" => "SQL",
|
81
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
82
|
-
"count" => 1,
|
83
|
-
"name" => "sql.active_record",
|
84
|
-
"title" => ""
|
85
|
-
)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "when a transaction is completed in an instrumented block" do
|
90
|
-
it "does not complete the ActiveSupport::Notifications.instrument event" do
|
91
|
-
as.instrument("sql.active_record", :sql => "SQL") do
|
92
|
-
Appsignal::Transaction.complete_current!
|
93
|
-
end
|
94
|
-
|
95
|
-
expect(transaction).to_not include_events
|
96
|
-
expect(transaction).to be_completed
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
shared_examples "activesupport start finish override" do
|
2
|
-
let(:instrumenter) { as.instrumenter }
|
3
|
-
|
4
|
-
it "instruments start/finish events with payload on start ignores payload" do
|
5
|
-
instrumenter.start("sql.active_record", :sql => "SQL")
|
6
|
-
instrumenter.finish("sql.active_record", {})
|
7
|
-
|
8
|
-
expect(transaction).to include_event(
|
9
|
-
"body" => "",
|
10
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
11
|
-
"count" => 1,
|
12
|
-
"name" => "sql.active_record",
|
13
|
-
"title" => ""
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "instruments an ActiveSupport::Notifications.start/finish event with payload on finish" do
|
18
|
-
instrumenter.start("sql.active_record", {})
|
19
|
-
instrumenter.finish("sql.active_record", :sql => "SQL")
|
20
|
-
|
21
|
-
expect(transaction).to include_event(
|
22
|
-
"body" => "SQL",
|
23
|
-
"body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
|
24
|
-
"count" => 1,
|
25
|
-
"name" => "sql.active_record",
|
26
|
-
"title" => ""
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "does not instrument events whose name starts with a bang" do
|
31
|
-
instrumenter.start("!sql.active_record", {})
|
32
|
-
instrumenter.finish("!sql.active_record", {})
|
33
|
-
|
34
|
-
expect(transaction).to_not include_events
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when a transaction is completed in an instrumented block" do
|
38
|
-
it "does not complete the ActiveSupport::Notifications.instrument event" do
|
39
|
-
instrumenter.start("sql.active_record", {})
|
40
|
-
Appsignal::Transaction.complete_current!
|
41
|
-
instrumenter.finish("sql.active_record", {})
|
42
|
-
|
43
|
-
expect(transaction).to_not include_events
|
44
|
-
expect(transaction).to be_completed
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative "active_support_notifications/instrument_shared_examples"
|
2
|
-
|
3
|
-
describe Appsignal::Hooks::ActiveSupportNotificationsHook do
|
4
|
-
if active_support_present?
|
5
|
-
let(:notifier) { ActiveSupport::Notifications::Fanout.new }
|
6
|
-
let(:as) { ActiveSupport::Notifications }
|
7
|
-
let(:transaction) { http_request_transaction }
|
8
|
-
before do
|
9
|
-
start_agent
|
10
|
-
set_current_transaction(transaction)
|
11
|
-
as.notifier = notifier
|
12
|
-
end
|
13
|
-
around { |example| keep_transactions { example.run } }
|
14
|
-
|
15
|
-
describe "#dependencies_present?" do
|
16
|
-
subject { described_class.new.dependencies_present? }
|
17
|
-
|
18
|
-
it { is_expected.to be_truthy }
|
19
|
-
end
|
20
|
-
|
21
|
-
it_behaves_like "activesupport instrument override"
|
22
|
-
|
23
|
-
if defined?(::ActiveSupport::Notifications::Fanout::Handle)
|
24
|
-
require_relative "active_support_notifications/start_finish_shared_examples"
|
25
|
-
|
26
|
-
it_behaves_like "activesupport start finish override"
|
27
|
-
end
|
28
|
-
|
29
|
-
if ::ActiveSupport::Notifications::Instrumenter.method_defined?(:start)
|
30
|
-
require_relative "active_support_notifications/start_finish_shared_examples"
|
31
|
-
|
32
|
-
it_behaves_like "activesupport start finish override"
|
33
|
-
end
|
34
|
-
|
35
|
-
if ::ActiveSupport::Notifications::Instrumenter.method_defined?(:finish_with_state)
|
36
|
-
require_relative "active_support_notifications/finish_with_state_shared_examples"
|
37
|
-
|
38
|
-
it_behaves_like "activesupport finish_with_state override"
|
39
|
-
end
|
40
|
-
else
|
41
|
-
describe "#dependencies_present?" do
|
42
|
-
subject { described_class.new.dependencies_present? }
|
43
|
-
|
44
|
-
it { is_expected.to be_falsy }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|