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,122 +0,0 @@
|
|
1
|
-
module TransactionHelpers
|
2
|
-
def uploaded_file
|
3
|
-
if DependencyHelper.rails_present?
|
4
|
-
ActionDispatch::Http::UploadedFile.new(:tempfile => "/tmp")
|
5
|
-
else
|
6
|
-
::Rack::Multipart::UploadedFile.new(File.join(fixtures_dir, "/uploaded_file.txt"))
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def default_namespace
|
11
|
-
Appsignal::Transaction::HTTP_REQUEST
|
12
|
-
end
|
13
|
-
|
14
|
-
def create_transaction(namespace = default_namespace)
|
15
|
-
Appsignal::Transaction.create(namespace)
|
16
|
-
end
|
17
|
-
|
18
|
-
def new_transaction(namespace = default_namespace, ext: nil)
|
19
|
-
Appsignal::Transaction.new(namespace, :ext => ext)
|
20
|
-
end
|
21
|
-
|
22
|
-
def rack_request(env)
|
23
|
-
Rack::Request.new(env)
|
24
|
-
end
|
25
|
-
|
26
|
-
def background_job_transaction
|
27
|
-
new_transaction(Appsignal::Transaction::BACKGROUND_JOB)
|
28
|
-
end
|
29
|
-
|
30
|
-
def http_request_transaction
|
31
|
-
new_transaction(Appsignal::Transaction::HTTP_REQUEST)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Returns the all {Appsignal::Transaction} objects created during this test
|
35
|
-
# run so far.
|
36
|
-
#
|
37
|
-
# @return [Array<Appsignal::Transaction>]
|
38
|
-
def created_transactions
|
39
|
-
Appsignal::Testing.transactions
|
40
|
-
end
|
41
|
-
|
42
|
-
# Returns the last created {Appsignal::Transaction}.
|
43
|
-
#
|
44
|
-
# @return [Appsignal::Transaction]
|
45
|
-
def last_transaction
|
46
|
-
created_transactions.last
|
47
|
-
end
|
48
|
-
|
49
|
-
def current_transaction?
|
50
|
-
Appsignal::Transaction.current?
|
51
|
-
end
|
52
|
-
|
53
|
-
def current_transaction
|
54
|
-
Appsignal::Transaction.current
|
55
|
-
end
|
56
|
-
|
57
|
-
# Set current transaction manually.
|
58
|
-
# Cleared by {clear_current_transaction!}
|
59
|
-
#
|
60
|
-
# When a block is given, the current transaction is automatically unset after
|
61
|
-
# the block.
|
62
|
-
def set_current_transaction(transaction) # rubocop:disable Naming/AccessorMethodName
|
63
|
-
Thread.current[:appsignal_transaction] = transaction
|
64
|
-
yield if block_given?
|
65
|
-
ensure
|
66
|
-
clear_current_transaction! if block_given?
|
67
|
-
end
|
68
|
-
|
69
|
-
# Use when {Appsignal::Transaction.clear_current_transaction!} is stubbed to
|
70
|
-
# clear the current transaction on the current thread.
|
71
|
-
def clear_current_transaction!
|
72
|
-
Thread.current[:appsignal_transaction] = nil
|
73
|
-
end
|
74
|
-
|
75
|
-
# Set the current for the duration of the given block.
|
76
|
-
#
|
77
|
-
# Helper for {set_current_transaction} and {clear_current_transaction!}
|
78
|
-
def with_current_transaction(transaction)
|
79
|
-
set_current_transaction transaction
|
80
|
-
yield
|
81
|
-
ensure
|
82
|
-
clear_current_transaction!
|
83
|
-
end
|
84
|
-
|
85
|
-
# Track the AppSignal transaction JSON when a transaction gets completed
|
86
|
-
# ({Appsignal::Transaction.complete}).
|
87
|
-
#
|
88
|
-
# It will also add sample data to the transaction when it gets completed.
|
89
|
-
# This can be disabled by setting the `sample` option to `false`.
|
90
|
-
#
|
91
|
-
# It will be tracked for every transaction that is started inside the
|
92
|
-
# `keep_transactions` block.
|
93
|
-
#
|
94
|
-
# @example Keep a transaction while also adding sample data
|
95
|
-
# keep_transactions do
|
96
|
-
# transaction = Appsignal::Transaction.new(...)
|
97
|
-
# transaction.complete
|
98
|
-
# transaction.to_h # => Hash with transaction data before it was completed
|
99
|
-
# end
|
100
|
-
#
|
101
|
-
# @example Keep a transaction without adding sample data
|
102
|
-
# keep_transactions :sample => false do
|
103
|
-
# transaction = Appsignal::Transaction.new(...)
|
104
|
-
# transaction.complete
|
105
|
-
# transaction.to_h
|
106
|
-
# # => Hash with transaction data before it was completed with an empty
|
107
|
-
# # Hash for the `sample_data` key.
|
108
|
-
# end
|
109
|
-
#
|
110
|
-
# @yield block to perform while the transactions are tracked.
|
111
|
-
# @param options [Hash]
|
112
|
-
# @option options [Boolean] :sample Whether or not to sample transactions.
|
113
|
-
# @return [Object] returns the block return value.
|
114
|
-
def keep_transactions(options = {})
|
115
|
-
Appsignal::Testing.keep_transactions = true
|
116
|
-
Appsignal::Testing.sample_transactions = options.fetch(:sample, true)
|
117
|
-
yield
|
118
|
-
ensure
|
119
|
-
Appsignal::Testing.keep_transactions = nil
|
120
|
-
Appsignal::Testing.sample_transactions = nil
|
121
|
-
end
|
122
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module WaitForHelper
|
2
|
-
# Wait for a condition to be met
|
3
|
-
#
|
4
|
-
# @example
|
5
|
-
# # Perform threaded operation
|
6
|
-
# wait_for("enough probe calls") { probe.calls >= 2 }
|
7
|
-
# # Assert on result
|
8
|
-
#
|
9
|
-
# @param name [String] The name of the condition to check. Used in the
|
10
|
-
# error when it fails.
|
11
|
-
# @yield Assertion to check.
|
12
|
-
# @yieldreturn [Boolean] True/False value that indicates if the condition
|
13
|
-
# is met.
|
14
|
-
# @raise [StandardError] Raises error if the condition is not met after 5
|
15
|
-
# seconds, 5_000 tries.
|
16
|
-
def wait_for(name)
|
17
|
-
max_wait = 5_000
|
18
|
-
i = 0
|
19
|
-
error = nil
|
20
|
-
while i < max_wait
|
21
|
-
begin
|
22
|
-
result = yield
|
23
|
-
break if result
|
24
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
25
|
-
# Capture error so we know if it exited with an error
|
26
|
-
error = e
|
27
|
-
ensure
|
28
|
-
i += 1
|
29
|
-
sleep 0.001
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
return unless i >= max_wait
|
34
|
-
|
35
|
-
error_message =
|
36
|
-
("\nError: #{error.class}: #{error.message}\n#{error.backtrace.join("\n")}" if error)
|
37
|
-
raise "Waited 5 seconds for #{name} condition, but was not met.#{error_message}"
|
38
|
-
end
|
39
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
RSpec::Matchers.define :contains_log do |level, message|
|
2
|
-
log_level_prefix = level.upcase
|
3
|
-
|
4
|
-
match do |actual|
|
5
|
-
case message
|
6
|
-
when Regexp
|
7
|
-
/\[#{log_level_prefix}\] #{message}/.match?(actual)
|
8
|
-
else
|
9
|
-
expected_log_line = "[#{log_level_prefix}] #{message}"
|
10
|
-
actual.include?(expected_log_line)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
failure_message do |actual|
|
15
|
-
<<~MESSAGE
|
16
|
-
Did not contain log line:
|
17
|
-
Log level: #{log_level_prefix}
|
18
|
-
Message: #{message}
|
19
|
-
|
20
|
-
Received logs:
|
21
|
-
#{actual}
|
22
|
-
MESSAGE
|
23
|
-
end
|
24
|
-
|
25
|
-
diffable
|
26
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
RSpec::Matchers.define :have_colorized_text do |color, text|
|
2
|
-
match do |actual|
|
3
|
-
color_codes = Appsignal::CLI::Helpers::COLOR_CODES
|
4
|
-
reset_color_code = color_codes.fetch(:default)
|
5
|
-
color_code = color_codes.fetch(color)
|
6
|
-
|
7
|
-
@expected = "\e[#{color_code}m#{text}\e[#{reset_color_code}m"
|
8
|
-
expect(actual).to include(@expected)
|
9
|
-
end
|
10
|
-
|
11
|
-
diffable
|
12
|
-
attr_reader :expected
|
13
|
-
end
|
14
|
-
|
15
|
-
COLOR_TAG_MATCHER_REGEX = /\e\[(\d+)m/.freeze
|
16
|
-
RSpec::Matchers.define :have_color_markers do
|
17
|
-
match do |actual|
|
18
|
-
actual =~ COLOR_TAG_MATCHER_REGEX
|
19
|
-
end
|
20
|
-
|
21
|
-
failure_message do
|
22
|
-
"expected that output contains color markers: /\\e[\\d+m/"
|
23
|
-
end
|
24
|
-
|
25
|
-
failure_message_when_negated do
|
26
|
-
"expected that output does not contain color markers: /\\e[\\d+m/"
|
27
|
-
end
|
28
|
-
end
|
@@ -1,200 +0,0 @@
|
|
1
|
-
def define_transaction_metadata_matcher_for(matcher_key, value_key = matcher_key)
|
2
|
-
value_key = value_key.to_s
|
3
|
-
|
4
|
-
RSpec::Matchers.define "have_#{matcher_key}" do |expected_value|
|
5
|
-
match(:notify_expectation_failures => true) do |transaction|
|
6
|
-
actual_value = transaction.to_h[value_key]
|
7
|
-
if expected_value
|
8
|
-
expect(actual_value).to eq(expected_value)
|
9
|
-
else
|
10
|
-
expect(actual_value).to_not be_nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
match_when_negated(:notify_expectation_failures => true) do |transaction|
|
15
|
-
actual_value = transaction.to_h[value_key]
|
16
|
-
if expected_value
|
17
|
-
expect(actual_value).to_not eq(expected_value)
|
18
|
-
else
|
19
|
-
expect(actual_value).to be_nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
define_transaction_metadata_matcher_for(:id)
|
26
|
-
define_transaction_metadata_matcher_for(:namespace)
|
27
|
-
define_transaction_metadata_matcher_for(:action)
|
28
|
-
|
29
|
-
def define_transaction_sample_matcher_for(matcher_key, value_key = matcher_key)
|
30
|
-
value_key = value_key.to_s
|
31
|
-
|
32
|
-
RSpec::Matchers.define "include_#{matcher_key}" do |expected_value|
|
33
|
-
match(:notify_expectation_failures => true) do |transaction|
|
34
|
-
sample_data = transaction.to_h.dig("sample_data", value_key) || {}
|
35
|
-
|
36
|
-
if expected_value
|
37
|
-
expected_value = hash_including(expected_value) if expected_value.is_a?(Hash)
|
38
|
-
expect(sample_data).to match(expected_value)
|
39
|
-
else
|
40
|
-
expect(sample_data).to be_present
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
match_when_negated(:notify_expectation_failures => true) do |transaction|
|
45
|
-
sample_data = transaction.to_h.dig("sample_data", value_key) || {}
|
46
|
-
|
47
|
-
if expected_value
|
48
|
-
expect(sample_data).to_not include(expected_value)
|
49
|
-
else
|
50
|
-
expect(sample_data).to be_empty
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
define_transaction_sample_matcher_for(:sample_metadata, :metadata)
|
57
|
-
define_transaction_sample_matcher_for(:params)
|
58
|
-
define_transaction_sample_matcher_for(:environment)
|
59
|
-
define_transaction_sample_matcher_for(:session_data)
|
60
|
-
define_transaction_sample_matcher_for(:tags)
|
61
|
-
define_transaction_sample_matcher_for(:custom_data)
|
62
|
-
define_transaction_sample_matcher_for(:error_causes)
|
63
|
-
|
64
|
-
RSpec::Matchers.define :be_completed do
|
65
|
-
match(:notify_expectation_failures => true) do |transaction|
|
66
|
-
values_match? transaction.ext._completed?, true
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
RSpec::Matchers.define :have_error do |error_class, error_message, error_backtrace|
|
71
|
-
match(:notify_expectation_failures => true) do |transaction|
|
72
|
-
transaction_error = transaction.to_h["error"]
|
73
|
-
if error_class && error_message
|
74
|
-
expect(transaction_error).to include(
|
75
|
-
"name" => error_class,
|
76
|
-
"message" => error_message,
|
77
|
-
"backtrace" => error_backtrace ? JSON.dump(error_backtrace) : kind_of(String)
|
78
|
-
)
|
79
|
-
else
|
80
|
-
expect(transaction_error).to be_any
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
match_when_negated(:notify_expectation_failures => true) do |transaction|
|
85
|
-
transaction_error = transaction.to_h["error"]
|
86
|
-
if error_class && error_message
|
87
|
-
expect(transaction_error).to_not include(
|
88
|
-
"name" => error_class,
|
89
|
-
"message" => error_message,
|
90
|
-
"backtrace" => kind_of(String)
|
91
|
-
)
|
92
|
-
else
|
93
|
-
expect(transaction_error).to be_nil
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
RSpec::Matchers.define :include_event do |event|
|
99
|
-
match(:notify_expectation_failures => true) do |transaction|
|
100
|
-
events = transaction.to_h["events"]
|
101
|
-
if event
|
102
|
-
expect(events).to include(format_event(event))
|
103
|
-
else
|
104
|
-
expect(events).to be_any
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
match_when_negated(:notify_expectation_failures => true) do |transaction|
|
109
|
-
events = transaction.to_h["events"]
|
110
|
-
if event
|
111
|
-
expect(events).to_not include(format_event(event))
|
112
|
-
else
|
113
|
-
expect(events).to be_empty
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def format_event(event)
|
118
|
-
hash_including({
|
119
|
-
"body" => "",
|
120
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
121
|
-
"count" => 1,
|
122
|
-
"name" => kind_of(String),
|
123
|
-
"title" => ""
|
124
|
-
}.merge(event.transform_keys(&:to_s)))
|
125
|
-
end
|
126
|
-
end
|
127
|
-
RSpec::Matchers.alias_matcher :include_events, :include_event
|
128
|
-
|
129
|
-
RSpec::Matchers.define :include_metadata do |metadata|
|
130
|
-
match(:notify_expectation_failures => true) do |transaction|
|
131
|
-
actual_metadata = transaction.to_h["metadata"]
|
132
|
-
if metadata
|
133
|
-
expect(actual_metadata).to include(metadata)
|
134
|
-
else
|
135
|
-
expect(actual_metadata).to be_any
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
match_when_negated(:notify_expectation_failures => true) do |transaction|
|
140
|
-
actual_metadata = transaction.to_h["metadata"]
|
141
|
-
if metadata
|
142
|
-
expect(actual_metadata).to_not include(metadata)
|
143
|
-
else
|
144
|
-
expect(actual_metadata).to be_empty
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
RSpec::Matchers.define :include_breadcrumb do |action, category, message, metadata, time|
|
150
|
-
match(:notify_expectation_failures => true) do |transaction|
|
151
|
-
breadcrumbs = transaction.to_h.dig("sample_data", "breadcrumbs")
|
152
|
-
if action
|
153
|
-
breadcrumb = format_breadcrumb(action, category, message, metadata, time)
|
154
|
-
expect(breadcrumbs).to include(breadcrumb)
|
155
|
-
else
|
156
|
-
expect(transaction.to_h.dig("sample_data", "breadcrumbs")).to be_any
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
match_when_negated(:notify_expectation_failures => true) do |transaction|
|
161
|
-
breadcrumbs = transaction.to_h.dig("sample_data", "breadcrumbs")
|
162
|
-
if action
|
163
|
-
breadcrumb = format_breadcrumb(action, category, message, metadata, time)
|
164
|
-
expect(breadcrumbs).to_not include(breadcrumb)
|
165
|
-
else
|
166
|
-
expect(breadcrumbs).to_not be_any
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def format_breadcrumb(action, category, message, metadata, time)
|
171
|
-
{
|
172
|
-
"action" => action,
|
173
|
-
"category" => category,
|
174
|
-
"message" => message || "",
|
175
|
-
"metadata" => metadata || {},
|
176
|
-
"time" => time || kind_of(Integer)
|
177
|
-
}
|
178
|
-
end
|
179
|
-
end
|
180
|
-
RSpec::Matchers.alias_matcher :include_breadcrumbs, :include_breadcrumb
|
181
|
-
|
182
|
-
RSpec::Matchers.define :have_queue_start do |queue_start_time|
|
183
|
-
match(:notify_expectation_failures => true) do |transaction|
|
184
|
-
actual_start = transaction.ext.queue_start
|
185
|
-
if queue_start_time
|
186
|
-
expect(actual_start).to eq(queue_start_time)
|
187
|
-
else
|
188
|
-
expect(actual_start).to_not be_nil
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
match_when_negated(:notify_expectation_failures => true) do |transaction|
|
193
|
-
actual_start = transaction.ext.queue_start
|
194
|
-
if queue_start_time
|
195
|
-
expect(actual_start).to_not eq(queue_start_time)
|
196
|
-
else
|
197
|
-
expect(actual_start).to be_nil
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class AppsignalMock
|
2
|
-
attr_reader :gauges
|
3
|
-
|
4
|
-
def initialize(hostname: nil)
|
5
|
-
@hostname = hostname
|
6
|
-
@gauges = []
|
7
|
-
end
|
8
|
-
|
9
|
-
def config
|
10
|
-
options = {}
|
11
|
-
options[:hostname] = @hostname if @hostname
|
12
|
-
ConfigHelpers.build_config(:options => options)
|
13
|
-
end
|
14
|
-
|
15
|
-
def set_gauge(*args)
|
16
|
-
@gauges << args
|
17
|
-
end
|
18
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class FakeGCProfiler
|
2
|
-
attr_accessor :total_time
|
3
|
-
attr_writer :clear_delay
|
4
|
-
|
5
|
-
def initialize(total_time = 0)
|
6
|
-
@total_time = total_time
|
7
|
-
end
|
8
|
-
|
9
|
-
def clear
|
10
|
-
sleep clear_delay
|
11
|
-
@total_time = 0
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def clear_delay
|
17
|
-
@clear_delay ||= 0
|
18
|
-
end
|
19
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module FakeGVLTools
|
2
|
-
def self.reset
|
3
|
-
self::GlobalTimer.monotonic_time = 0
|
4
|
-
self::WaitingThreads.count = 0
|
5
|
-
end
|
6
|
-
|
7
|
-
module GlobalTimer
|
8
|
-
@monotonic_time = 0
|
9
|
-
|
10
|
-
class << self
|
11
|
-
attr_accessor :monotonic_time
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module WaitingThreads
|
16
|
-
@count = 0
|
17
|
-
@enabled = false
|
18
|
-
|
19
|
-
class << self
|
20
|
-
attr_accessor :count
|
21
|
-
attr_writer :enabled
|
22
|
-
|
23
|
-
def enabled?
|
24
|
-
@enabled
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class PumaMock
|
2
|
-
module MiniSSL
|
3
|
-
class SSLError < StandardError
|
4
|
-
def self.to_s
|
5
|
-
"Puma::MiniSSL::SSLError"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class HttpParserError < StandardError
|
11
|
-
def self.to_s
|
12
|
-
"Puma::HttpParserError"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class HttpParserError501 < StandardError
|
17
|
-
def self.to_s
|
18
|
-
"Puma::HttpParserError501"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.stats
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.cli_config
|
26
|
-
@cli_config ||= CliConfig.new
|
27
|
-
end
|
28
|
-
|
29
|
-
class Server
|
30
|
-
end
|
31
|
-
|
32
|
-
module Const
|
33
|
-
VERSION = "6.0.0".freeze
|
34
|
-
end
|
35
|
-
|
36
|
-
class CliConfig
|
37
|
-
attr_accessor :options
|
38
|
-
|
39
|
-
def initialize
|
40
|
-
@options = {}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
RSpec.shared_examples "instrument helper" do
|
2
|
-
around { |example| keep_transactions { example.run } }
|
3
|
-
let(:stub) { double(:method_call => "return value") }
|
4
|
-
|
5
|
-
it "records an event around the given block" do
|
6
|
-
return_value = instrumenter.instrument "name", "title", "body" do
|
7
|
-
stub.method_call
|
8
|
-
end
|
9
|
-
expect(return_value).to eq "return value"
|
10
|
-
|
11
|
-
expect_transaction_to_have_event
|
12
|
-
end
|
13
|
-
|
14
|
-
context "with an error raised in the passed block" do
|
15
|
-
it "records an event around the given block" do
|
16
|
-
expect do
|
17
|
-
instrumenter.instrument "name", "title", "body" do
|
18
|
-
stub.method_call
|
19
|
-
raise ExampleException, "foo"
|
20
|
-
end
|
21
|
-
end.to raise_error(ExampleException, "foo")
|
22
|
-
|
23
|
-
expect_transaction_to_have_event
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "with an error raise in the passed block" do
|
28
|
-
it "records an event around the given block" do
|
29
|
-
expect do
|
30
|
-
instrumenter.instrument "name", "title", "body" do
|
31
|
-
stub.method_call
|
32
|
-
throw :foo
|
33
|
-
end
|
34
|
-
end.to throw_symbol(:foo)
|
35
|
-
|
36
|
-
expect_transaction_to_have_event
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def expect_transaction_to_have_event
|
41
|
-
expect(transaction).to include_event(
|
42
|
-
"name" => "name",
|
43
|
-
"title" => "title",
|
44
|
-
"body" => "body",
|
45
|
-
"body_format" => Appsignal::EventFormatter::DEFAULT
|
46
|
-
)
|
47
|
-
end
|
48
|
-
end
|
File without changes
|