appsignal 4.0.5 → 4.0.7
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/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,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hanami"
|
4
|
-
require "hanami/action"
|
5
|
-
|
6
|
-
module HanamiApp
|
7
|
-
class App < Hanami::App
|
8
|
-
end
|
9
|
-
|
10
|
-
class Routes < Hanami::Routes
|
11
|
-
get "/books", :to => "books.index"
|
12
|
-
end
|
13
|
-
|
14
|
-
module Actions
|
15
|
-
module Books
|
16
|
-
class Index < Hanami::Action
|
17
|
-
def handle(_request, response)
|
18
|
-
response.body = "YOU REQUESTED BOOKS!"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Error < Hanami::Action
|
23
|
-
def handle(_request, _response)
|
24
|
-
raise ExampleException, "exception message"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module ActionMailerHelpers
|
2
|
-
def perform_action_mailer(mailer, method, args = nil)
|
3
|
-
if DependencyHelper.rails_version >= Gem::Version.new("5.2.0")
|
4
|
-
case args
|
5
|
-
when Array
|
6
|
-
mailer.send(method, *args).deliver_later
|
7
|
-
when Hash
|
8
|
-
mailer.with(args).send(method).deliver_later
|
9
|
-
when NilClass
|
10
|
-
mailer.send(method).deliver_later
|
11
|
-
else
|
12
|
-
raise "Unknown scenario for arguments: #{args}"
|
13
|
-
end
|
14
|
-
else
|
15
|
-
# Rails 5.1 and lower
|
16
|
-
mailer_object =
|
17
|
-
if args
|
18
|
-
mailer.send(method, *args)
|
19
|
-
else
|
20
|
-
mailer.send(method)
|
21
|
-
end
|
22
|
-
mailer_object.deliver_later
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module ActiveJobHelpers
|
2
|
-
def active_job_args_wrapper(args: [], params: nil)
|
3
|
-
if DependencyHelper.active_job_wraps_args?
|
4
|
-
wrapped_args = {}
|
5
|
-
|
6
|
-
if params
|
7
|
-
if DependencyHelper.rails7_present?
|
8
|
-
wrapped_args["_aj_ruby2_keywords"] = ["params", "args"]
|
9
|
-
wrapped_args["args"] = []
|
10
|
-
wrapped_args["params"] = {
|
11
|
-
"_aj_symbol_keys" => ["foo"]
|
12
|
-
}.merge(params)
|
13
|
-
else
|
14
|
-
wrapped_args["_aj_symbol_keys"] = ["foo"]
|
15
|
-
wrapped_args.merge!(params)
|
16
|
-
end
|
17
|
-
else
|
18
|
-
wrapped_args["_aj_ruby2_keywords"] = ["args"]
|
19
|
-
wrapped_args["args"] = args
|
20
|
-
end
|
21
|
-
|
22
|
-
[wrapped_args]
|
23
|
-
else
|
24
|
-
params.nil? ? args : args + [params]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module ApiRequestHelper
|
2
|
-
def stub_api_request(config, path, body = nil)
|
3
|
-
options = {
|
4
|
-
:query => {
|
5
|
-
:api_key => config[:push_api_key],
|
6
|
-
:name => config[:name],
|
7
|
-
:environment => config.respond_to?(:env) ? config.env : config[:environment],
|
8
|
-
:hostname => config[:hostname],
|
9
|
-
:gem_version => Appsignal::VERSION
|
10
|
-
},
|
11
|
-
:headers => {
|
12
|
-
"Content-Type" => "application/json; charset=UTF-8"
|
13
|
-
}
|
14
|
-
}
|
15
|
-
body = Appsignal::Utils::JSON.generate(body) if body.is_a? Hash
|
16
|
-
options[:body] = body if body
|
17
|
-
endpoint = config[:endpoint] || Appsignal::Config::DEFAULT_CONFIG[:endpoint]
|
18
|
-
stub_request(:post, "#{endpoint}/1/#{path}").with(options)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require "appsignal/cli/helpers"
|
2
|
-
|
3
|
-
module CLIHelpers
|
4
|
-
def cli
|
5
|
-
Appsignal::CLI
|
6
|
-
end
|
7
|
-
|
8
|
-
def run_cli(command, options = {})
|
9
|
-
cli.run(format_cli_arguments_and_options(command, options))
|
10
|
-
end
|
11
|
-
|
12
|
-
def format_cli_arguments_and_options(command, options = {})
|
13
|
-
[*command].tap do |o|
|
14
|
-
options.each do |key, value|
|
15
|
-
o << (value.nil? ? "--#{key}" : "--#{key}=#{value}")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_cli_input(value)
|
21
|
-
$stdin.puts value
|
22
|
-
end
|
23
|
-
|
24
|
-
def prepare_cli_input
|
25
|
-
# Prepare the input by rewinding the pointer in the StringIO
|
26
|
-
$stdin.rewind
|
27
|
-
end
|
28
|
-
|
29
|
-
def colorize(*args)
|
30
|
-
ColorizeHelper.colorize(*args)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module ColorizeHelper
|
35
|
-
extend Appsignal::CLI::Helpers
|
36
|
-
|
37
|
-
def self.colorize(*_args)
|
38
|
-
super
|
39
|
-
end
|
40
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module ConfigHelpers
|
2
|
-
def project_fixture_path
|
3
|
-
File.expand_path(
|
4
|
-
File.join(File.dirname(__FILE__), "../fixtures/projects/valid")
|
5
|
-
)
|
6
|
-
end
|
7
|
-
module_function :project_fixture_path
|
8
|
-
|
9
|
-
def rails_project_fixture_path
|
10
|
-
File.expand_path(
|
11
|
-
File.join(File.dirname(__FILE__), "../fixtures/projects/valid_with_rails_app")
|
12
|
-
)
|
13
|
-
end
|
14
|
-
module_function :rails_project_fixture_path
|
15
|
-
|
16
|
-
def project_fixture_config(
|
17
|
-
env = "production",
|
18
|
-
options = {},
|
19
|
-
logger = Appsignal.internal_logger
|
20
|
-
)
|
21
|
-
Appsignal::Config.new(
|
22
|
-
project_fixture_path,
|
23
|
-
env,
|
24
|
-
logger
|
25
|
-
).tap do |c|
|
26
|
-
c.merge_dsl_options(options)
|
27
|
-
c.validate
|
28
|
-
end
|
29
|
-
end
|
30
|
-
module_function :project_fixture_config
|
31
|
-
|
32
|
-
def build_config(
|
33
|
-
root_path: project_fixture_path,
|
34
|
-
env: "production",
|
35
|
-
options: {},
|
36
|
-
logger: Appsignal.internal_logger
|
37
|
-
)
|
38
|
-
Appsignal::Config.new(
|
39
|
-
root_path,
|
40
|
-
env,
|
41
|
-
logger
|
42
|
-
).tap do |c|
|
43
|
-
c.merge_dsl_options(options) if options.any?
|
44
|
-
c.validate
|
45
|
-
end
|
46
|
-
end
|
47
|
-
module_function :build_config
|
48
|
-
|
49
|
-
def start_agent(env: "production", options: {}, internal_logger: nil)
|
50
|
-
env = "production" if env == :default
|
51
|
-
env ||= "production"
|
52
|
-
Appsignal.configure(env, :root_path => project_fixture_path) do |config|
|
53
|
-
options.each do |option, value|
|
54
|
-
config.send("#{option}=", value)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
Appsignal.start
|
58
|
-
Appsignal.internal_logger = internal_logger if internal_logger
|
59
|
-
end
|
60
|
-
|
61
|
-
def clear_integration_env_vars!
|
62
|
-
ENV.delete("RAILS_ENV")
|
63
|
-
ENV.delete("RACK_ENV")
|
64
|
-
ENV.delete("PADRINO_ENV")
|
65
|
-
end
|
66
|
-
end
|
@@ -1,150 +0,0 @@
|
|
1
|
-
module DependencyHelper
|
2
|
-
module_function
|
3
|
-
|
4
|
-
def macos?
|
5
|
-
RbConfig::CONFIG["host_os"].include?("darwin")
|
6
|
-
end
|
7
|
-
|
8
|
-
def ruby_version
|
9
|
-
Gem::Version.new(RUBY_VERSION)
|
10
|
-
end
|
11
|
-
|
12
|
-
def ruby_3_1_or_newer?
|
13
|
-
ruby_version >= Gem::Version.new("3.1.0")
|
14
|
-
end
|
15
|
-
|
16
|
-
def ruby_3_2_or_newer?
|
17
|
-
ruby_version >= Gem::Version.new("3.2.0")
|
18
|
-
end
|
19
|
-
|
20
|
-
def running_jruby?
|
21
|
-
Appsignal::System.jruby?
|
22
|
-
end
|
23
|
-
|
24
|
-
def rails_present?
|
25
|
-
dependency_present? "rails"
|
26
|
-
end
|
27
|
-
|
28
|
-
def rails6_present?
|
29
|
-
rails_present? && rails_version >= Gem::Version.new("6.0.0")
|
30
|
-
end
|
31
|
-
|
32
|
-
def rails6_1_present?
|
33
|
-
rails_present? && rails_version >= Gem::Version.new("6.1.0")
|
34
|
-
end
|
35
|
-
|
36
|
-
def rails6_1_5_present?
|
37
|
-
rails_present? && rails_version >= Gem::Version.new("6.1.5")
|
38
|
-
end
|
39
|
-
|
40
|
-
def rails7_present?
|
41
|
-
rails_present? && rails_version >= Gem::Version.new("7.0.0")
|
42
|
-
end
|
43
|
-
|
44
|
-
def rails7_1_present?
|
45
|
-
rails_present? && rails_version >= Gem::Version.new("7.1.0")
|
46
|
-
end
|
47
|
-
|
48
|
-
def active_job_wraps_args?
|
49
|
-
rails7_present? || (ruby_3_1_or_newer? && rails6_1_present? && !rails6_1_5_present?)
|
50
|
-
end
|
51
|
-
|
52
|
-
def rails_version
|
53
|
-
Gem.loaded_specs["rails"].version
|
54
|
-
end
|
55
|
-
|
56
|
-
def sequel_present?
|
57
|
-
dependency_present? "sequel"
|
58
|
-
end
|
59
|
-
|
60
|
-
def resque_present?
|
61
|
-
dependency_present? "resque"
|
62
|
-
end
|
63
|
-
|
64
|
-
def redis_client_present?
|
65
|
-
dependency_present? "redis-client"
|
66
|
-
end
|
67
|
-
|
68
|
-
def hiredis_client_present?
|
69
|
-
dependency_present? "hiredis-client"
|
70
|
-
end
|
71
|
-
|
72
|
-
def redis_present?
|
73
|
-
dependency_present? "redis"
|
74
|
-
end
|
75
|
-
|
76
|
-
def action_cable_present?
|
77
|
-
dependency_present? "actioncable"
|
78
|
-
end
|
79
|
-
|
80
|
-
def action_mailer_present?
|
81
|
-
dependency_present? "actionmailer"
|
82
|
-
end
|
83
|
-
|
84
|
-
def active_job_present?
|
85
|
-
dependency_present? "activejob"
|
86
|
-
end
|
87
|
-
|
88
|
-
def active_support_present?
|
89
|
-
dependency_present? "activesupport"
|
90
|
-
end
|
91
|
-
|
92
|
-
def sinatra_present?
|
93
|
-
dependency_present? "sinatra"
|
94
|
-
end
|
95
|
-
|
96
|
-
def padrino_present?
|
97
|
-
dependency_present? "padrino"
|
98
|
-
end
|
99
|
-
|
100
|
-
def grape_present?
|
101
|
-
dependency_present? "grape"
|
102
|
-
end
|
103
|
-
|
104
|
-
def webmachine_present?
|
105
|
-
dependency_present? "webmachine"
|
106
|
-
end
|
107
|
-
|
108
|
-
def capistrano_present?
|
109
|
-
dependency_present? "capistrano"
|
110
|
-
end
|
111
|
-
|
112
|
-
def capistrano2_present?
|
113
|
-
capistrano_present? &&
|
114
|
-
Gem.loaded_specs["capistrano"].version < Gem::Version.new("3.0")
|
115
|
-
end
|
116
|
-
|
117
|
-
def capistrano3_present?
|
118
|
-
capistrano_present? &&
|
119
|
-
Gem.loaded_specs["capistrano"].version >= Gem::Version.new("3.0")
|
120
|
-
end
|
121
|
-
|
122
|
-
def http_present?
|
123
|
-
dependency_present? "http"
|
124
|
-
end
|
125
|
-
|
126
|
-
def que_present?
|
127
|
-
dependency_present? "que"
|
128
|
-
end
|
129
|
-
|
130
|
-
def hanami_present?
|
131
|
-
dependency_present? "hanami"
|
132
|
-
end
|
133
|
-
|
134
|
-
def hanami2_1_present?
|
135
|
-
hanami_present? &&
|
136
|
-
Gem::Version.new(::Hanami::VERSION) >= Gem::Version.new("2.1.0")
|
137
|
-
end
|
138
|
-
|
139
|
-
def dry_monitor_present?
|
140
|
-
dependency_present? "dry-monitor"
|
141
|
-
end
|
142
|
-
|
143
|
-
def hanami2_present?
|
144
|
-
hanami_present? && Gem.loaded_specs["hanami"].version >= Gem::Version.new("2.0")
|
145
|
-
end
|
146
|
-
|
147
|
-
def dependency_present?(dependency_file)
|
148
|
-
Gem.loaded_specs.key? dependency_file
|
149
|
-
end
|
150
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module DirectoryHelper
|
2
|
-
module_function
|
3
|
-
|
4
|
-
def project_dir
|
5
|
-
@project_dir ||= File.expand_path("..", spec_dir)
|
6
|
-
end
|
7
|
-
|
8
|
-
def spec_dir
|
9
|
-
APPSIGNAL_SPEC_DIR
|
10
|
-
end
|
11
|
-
|
12
|
-
def support_dir
|
13
|
-
@support_dir ||= File.join(spec_dir, "support")
|
14
|
-
end
|
15
|
-
|
16
|
-
def tmp_dir
|
17
|
-
@tmp_dir ||= File.join(spec_dir, "tmp")
|
18
|
-
end
|
19
|
-
|
20
|
-
def fixtures_dir
|
21
|
-
@fixtures_dir ||= File.join(support_dir, "fixtures")
|
22
|
-
end
|
23
|
-
|
24
|
-
def resources_dir
|
25
|
-
@resources_dir ||= File.join(project_dir, "resources")
|
26
|
-
end
|
27
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module EnvHelpers
|
2
|
-
def http_request_env_with_data(args = {})
|
3
|
-
with_queue_start = args.delete(:with_queue_start)
|
4
|
-
path = args.delete(:path) || "/blog"
|
5
|
-
request = Rack::MockRequest.env_for(
|
6
|
-
path,
|
7
|
-
:params => args[:params] || {
|
8
|
-
"controller" => "blog_posts",
|
9
|
-
"action" => "show",
|
10
|
-
"id" => "1"
|
11
|
-
}
|
12
|
-
).merge(
|
13
|
-
:controller => "BlogPostsController",
|
14
|
-
:action => "show",
|
15
|
-
:request_format => "html",
|
16
|
-
:request_method => "GET",
|
17
|
-
:status => "200",
|
18
|
-
:view_runtime => 500,
|
19
|
-
:db_runtime => 500,
|
20
|
-
:metadata => { :key => "value" }
|
21
|
-
).merge(args)
|
22
|
-
|
23
|
-
# Set default queue value
|
24
|
-
if with_queue_start
|
25
|
-
request["HTTP_X_QUEUE_START"] = "t=#{(fixed_time * 1_000).to_i}" # in milliseconds
|
26
|
-
end
|
27
|
-
|
28
|
-
request
|
29
|
-
end
|
30
|
-
|
31
|
-
def background_env_with_data(args = {})
|
32
|
-
{
|
33
|
-
:class => "BackgroundJob",
|
34
|
-
:method => "perform",
|
35
|
-
:priority => 1,
|
36
|
-
:attempts => 0,
|
37
|
-
:queue => "default",
|
38
|
-
:queue_start => fixed_time
|
39
|
-
}.merge(args)
|
40
|
-
end
|
41
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module EnvironmentMetadataHelper
|
2
|
-
def capture_environment_metadata_report_calls
|
3
|
-
allow(Appsignal::Extension).to receive(:set_environment_metadata)
|
4
|
-
.and_call_original
|
5
|
-
end
|
6
|
-
|
7
|
-
def expect_environment_metadata(key, value)
|
8
|
-
expect(Appsignal::Extension).to have_received(:set_environment_metadata)
|
9
|
-
.with(key, value)
|
10
|
-
end
|
11
|
-
|
12
|
-
def expect_not_environment_metadata(key)
|
13
|
-
expect(Appsignal::Extension).to_not have_received(:set_environment_metadata)
|
14
|
-
.with(key, anything)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# This ExampleException is used for throwing Exceptions in specs that are
|
2
|
-
# allowed or expected.
|
3
|
-
#
|
4
|
-
# For example, this error can be thrown to raise an exception in AppSignal's
|
5
|
-
# run, which should stop the program and the appsignal gem, but not crash the
|
6
|
-
# test suite.
|
7
|
-
#
|
8
|
-
# There's also {ExampleStandardError}, use this when you need to test against
|
9
|
-
# StandardError-level Ruby exceptions.
|
10
|
-
#
|
11
|
-
# @see ExampleStandardError
|
12
|
-
class ExampleException < Exception # rubocop:disable Lint/InheritException
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# This ExampleStandardError is used for throwing errors in specs that are
|
2
|
-
# allowed or expected.
|
3
|
-
#
|
4
|
-
# For example, this error can be thrown to raise an exception in AppSignal's
|
5
|
-
# run, which should stop the program and the appsignal gem, but not crash the
|
6
|
-
# test suite.
|
7
|
-
#
|
8
|
-
# There's also {ExampleException}, use this when you need to test against
|
9
|
-
# Exception-level Ruby exceptions.
|
10
|
-
#
|
11
|
-
# @see ExampleException
|
12
|
-
class ExampleStandardError < StandardError
|
13
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module LoaderHelper
|
2
|
-
def load_loader(name)
|
3
|
-
Appsignal.load(name)
|
4
|
-
end
|
5
|
-
|
6
|
-
def start_loader(name)
|
7
|
-
Appsignal::Loaders.instances.fetch(name).on_start
|
8
|
-
end
|
9
|
-
|
10
|
-
def unregister_loader(name)
|
11
|
-
Appsignal::Loaders.unregister(name)
|
12
|
-
end
|
13
|
-
|
14
|
-
def define_loader(name, &block)
|
15
|
-
Appsignal::Testing.registered_loaders << name
|
16
|
-
Class.new(Appsignal::Loaders::Loader) do
|
17
|
-
register name
|
18
|
-
class_eval(&block) if block_given?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module LogHelpers
|
2
|
-
def capture_logs(&block)
|
3
|
-
log = std_stream
|
4
|
-
use_logger_with(log, &block)
|
5
|
-
log_contents(log)
|
6
|
-
end
|
7
|
-
|
8
|
-
def use_logger_with(log)
|
9
|
-
Appsignal.internal_logger = test_logger(log)
|
10
|
-
yield
|
11
|
-
ensure
|
12
|
-
Appsignal.internal_logger = nil
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_logger(log)
|
16
|
-
Appsignal::Utils::IntegrationLogger.new(log).tap do |logger|
|
17
|
-
logger.formatter = logger_formatter
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def logger_formatter
|
22
|
-
proc do |severity, _datetime, _progname, msg|
|
23
|
-
log_line(severity, msg)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def log_line(severity, message)
|
28
|
-
# This format is used in the `contains_log` matcher.
|
29
|
-
"[#{severity}] #{message}\n"
|
30
|
-
end
|
31
|
-
|
32
|
-
def log_contents(log)
|
33
|
-
log.rewind
|
34
|
-
log.read
|
35
|
-
end
|
36
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module RailsHelper
|
2
|
-
def run_appsignal_railtie
|
3
|
-
app = MyApp::Application.new
|
4
|
-
Appsignal::Integrations::Railtie.initializers.each do |initializer|
|
5
|
-
initializer.run(app)
|
6
|
-
end
|
7
|
-
ActiveSupport.run_load_hooks(:after_initialize, app)
|
8
|
-
end
|
9
|
-
|
10
|
-
def with_rails_error_reporter
|
11
|
-
if Rails.respond_to? :error
|
12
|
-
clear_rails_error_reporter!
|
13
|
-
Appsignal::Integrations::Railtie.initialize_error_reporter
|
14
|
-
end
|
15
|
-
yield
|
16
|
-
ensure
|
17
|
-
clear_rails_error_reporter!
|
18
|
-
end
|
19
|
-
|
20
|
-
def clear_rails_error_reporter!
|
21
|
-
return unless Rails.respond_to? :error
|
22
|
-
|
23
|
-
Rails
|
24
|
-
.error
|
25
|
-
.instance_variable_get(:@subscribers)
|
26
|
-
.reject! { |s| s == Appsignal::Integrations::RailsErrorReporterSubscriber }
|
27
|
-
end
|
28
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
module StdStreamsHelper
|
2
|
-
def std_stream
|
3
|
-
Tempfile.new SecureRandom.uuid
|
4
|
-
end
|
5
|
-
|
6
|
-
# Capture STDOUT in a variable
|
7
|
-
#
|
8
|
-
# Given tempfiles are rewinded and unlinked after yield, so no cleanup
|
9
|
-
# required. You can read from the stream using `stdout.read`.
|
10
|
-
#
|
11
|
-
# Usage
|
12
|
-
#
|
13
|
-
# out_stream = Tempfile.new
|
14
|
-
# capture_stdout(out_stream) { do_something }
|
15
|
-
def capture_stdout(stdout)
|
16
|
-
original_stdout = $stdout.dup
|
17
|
-
$stdout.reopen stdout
|
18
|
-
|
19
|
-
yield
|
20
|
-
ensure
|
21
|
-
$stdout.reopen original_stdout
|
22
|
-
stdout.rewind
|
23
|
-
stdout.unlink
|
24
|
-
end
|
25
|
-
|
26
|
-
# Capture STDOUT and STDERR in variables
|
27
|
-
#
|
28
|
-
# Given tempfiles are rewinded and unlinked after yield, so no cleanup
|
29
|
-
# required. You can read from the stream using `stdout.read`.
|
30
|
-
#
|
31
|
-
# Usage
|
32
|
-
#
|
33
|
-
# out_stream = Tempfile.new
|
34
|
-
# err_stream = Tempfile.new
|
35
|
-
# capture_std_streams(out_stream, err_stream) { do_something }
|
36
|
-
def capture_std_streams(stdout, stderr)
|
37
|
-
original_stdout = $stdout.dup
|
38
|
-
$stdout.reopen stdout
|
39
|
-
original_stderr = $stderr.dup
|
40
|
-
$stderr.reopen stderr
|
41
|
-
|
42
|
-
yield
|
43
|
-
ensure
|
44
|
-
$stdout.reopen original_stdout
|
45
|
-
$stderr.reopen original_stderr
|
46
|
-
stdout.rewind
|
47
|
-
stdout.unlink
|
48
|
-
stderr.rewind
|
49
|
-
stderr.unlink
|
50
|
-
end
|
51
|
-
|
52
|
-
# Silence the STDOUT.
|
53
|
-
#
|
54
|
-
# Ignore the STDOUT and don't print it in the test suite's STDOUT.
|
55
|
-
#
|
56
|
-
# If an error is found the output the output is raised as an error, failing
|
57
|
-
# the spec. Warnings and other AppSignal messages are ignored.
|
58
|
-
#
|
59
|
-
# @example
|
60
|
-
# silence { do_something }
|
61
|
-
# # Does nothing
|
62
|
-
#
|
63
|
-
# silence { puts "ERROR!" }
|
64
|
-
# # => Error found in silenced output:
|
65
|
-
# # ERROR!
|
66
|
-
#
|
67
|
-
# @example Ignore certain errors
|
68
|
-
# silence(:allowed => ["my error"]) { puts "my error!" }
|
69
|
-
# # Does nothing
|
70
|
-
#
|
71
|
-
# silence { puts "my error!" }
|
72
|
-
# # => Error found in silenced output:
|
73
|
-
# # my error!
|
74
|
-
def silence(options = {}, &block)
|
75
|
-
stream = Tempfile.new(SecureRandom.uuid)
|
76
|
-
capture_std_streams(stream, stream, &block)
|
77
|
-
ensure
|
78
|
-
output = filter_allowed_errors(stream.read, options.fetch(:allowed, []))
|
79
|
-
raise "Error found in silenced output:\n#{output}" if output =~ /(ERR|Error|error)/
|
80
|
-
end
|
81
|
-
|
82
|
-
def filter_allowed_errors(output, allowed_errors)
|
83
|
-
output.lines.reject do |line|
|
84
|
-
reject = false
|
85
|
-
allowed_errors.each do |error|
|
86
|
-
if line.include?(error)
|
87
|
-
reject = true
|
88
|
-
break
|
89
|
-
end
|
90
|
-
end
|
91
|
-
reject
|
92
|
-
end.join
|
93
|
-
end
|
94
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module TakeAtMostHelper
|
2
|
-
# Assert that it takes at most a certain amount of time to run a block.
|
3
|
-
#
|
4
|
-
# @example
|
5
|
-
# # Assert that it takes at most 1 second to run the block
|
6
|
-
# take_at_most(1) { sleep 0.5 }
|
7
|
-
#
|
8
|
-
# @param time [Integer, Float] The maximum amount of time the block is allowed to
|
9
|
-
# run in seconds.
|
10
|
-
# @yield Block to run.
|
11
|
-
# @raise [StandardError] Raises error if the block takes longer than the
|
12
|
-
# specified time to run.
|
13
|
-
def take_at_most(time)
|
14
|
-
start = Time.now
|
15
|
-
yield
|
16
|
-
elapsed = Time.now - start
|
17
|
-
return if elapsed <= time
|
18
|
-
|
19
|
-
raise "Expected block to take at most #{time} seconds, but took #{elapsed}"
|
20
|
-
end
|
21
|
-
end
|