appsignal 2.11.10 → 3.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/.semaphore/semaphore.yml +161 -70
- data/CHANGELOG.md +5 -18
- data/Rakefile +3 -13
- data/appsignal.gemspec +2 -24
- data/build_matrix.yml +20 -22
- data/gemfiles/capistrano2.gemfile +1 -0
- data/gemfiles/capistrano3.gemfile +1 -0
- data/gemfiles/grape.gemfile +1 -0
- data/gemfiles/no_dependencies.gemfile +1 -4
- data/gemfiles/rails-3.2.gemfile +0 -2
- data/gemfiles/rails-4.2.gemfile +0 -6
- data/gemfiles/resque-2.gemfile +4 -0
- data/gemfiles/sequel-435.gemfile +1 -0
- data/gemfiles/sequel.gemfile +1 -0
- data/gemfiles/sinatra.gemfile +1 -0
- data/lib/appsignal/auth_check.rb +2 -8
- data/lib/appsignal/cli.rb +1 -23
- data/lib/appsignal/config.rb +0 -24
- data/lib/appsignal/event_formatter.rb +0 -25
- data/lib/appsignal/extension.rb +0 -50
- data/lib/appsignal/hooks/action_cable.rb +5 -44
- data/lib/appsignal/hooks/active_support_notifications.rb +7 -86
- data/lib/appsignal/hooks/celluloid.rb +5 -9
- data/lib/appsignal/hooks/net_http.rb +2 -12
- data/lib/appsignal/hooks/puma.rb +3 -5
- data/lib/appsignal/hooks/que.rb +1 -1
- data/lib/appsignal/hooks/rake.rb +2 -24
- data/lib/appsignal/hooks/redis.rb +2 -13
- data/lib/appsignal/hooks/resque.rb +2 -43
- data/lib/appsignal/hooks/sidekiq.rb +1 -5
- data/lib/appsignal/hooks/unicorn.rb +3 -24
- data/lib/appsignal/hooks/webmachine.rb +1 -7
- data/lib/appsignal/hooks.rb +0 -23
- data/lib/appsignal/integrations/action_cable.rb +34 -0
- data/lib/appsignal/integrations/active_support_notifications.rb +77 -0
- data/lib/appsignal/integrations/net_http.rb +16 -0
- data/lib/appsignal/integrations/object.rb +61 -4
- data/lib/appsignal/integrations/padrino.rb +5 -7
- data/lib/appsignal/integrations/que.rb +26 -33
- data/lib/appsignal/integrations/railtie.rb +1 -4
- data/lib/appsignal/integrations/rake.rb +26 -2
- data/lib/appsignal/integrations/redis.rb +17 -0
- data/lib/appsignal/integrations/resque.rb +39 -10
- data/lib/appsignal/integrations/unicorn.rb +28 -0
- data/lib/appsignal/integrations/webmachine.rb +22 -24
- data/lib/appsignal/minutely.rb +0 -18
- data/lib/appsignal/transaction.rb +1 -1
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +1 -27
- data/spec/lib/appsignal/auth_check_spec.rb +1 -24
- data/spec/lib/appsignal/cli_spec.rb +1 -1
- data/spec/lib/appsignal/config_spec.rb +0 -66
- data/spec/lib/appsignal/event_formatter_spec.rb +0 -37
- data/spec/lib/appsignal/extension_install_failure_spec.rb +7 -0
- data/spec/lib/appsignal/extension_spec.rb +9 -43
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -88
- data/spec/lib/appsignal/hooks/celluloid_spec.rb +6 -1
- data/spec/lib/appsignal/hooks/rake_spec.rb +1 -2
- data/spec/lib/appsignal/hooks/redis_spec.rb +50 -15
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +7 -61
- data/spec/lib/appsignal/hooks/unicorn_spec.rb +14 -3
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -13
- data/spec/lib/appsignal/hooks_spec.rb +0 -57
- data/spec/lib/appsignal/integrations/object_spec.rb +4 -95
- data/spec/lib/appsignal/integrations/padrino_spec.rb +2 -3
- data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -45
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +26 -8
- data/spec/lib/appsignal/minutely_spec.rb +0 -19
- data/spec/lib/appsignal/transaction_spec.rb +1 -31
- data/spec/lib/appsignal/transmitter_spec.rb +1 -1
- data/spec/lib/appsignal/utils/data_spec.rb +87 -133
- data/spec/lib/appsignal_spec.rb +0 -69
- data/spec/lib/puma/appsignal_spec.rb +0 -28
- data/spec/spec_helper.rb +1 -37
- data/spec/support/testing.rb +1 -11
- data/support/install_deps +0 -4
- metadata +10 -23
- data/lib/appsignal/cli/notify_of_deploy.rb +0 -131
- data/lib/appsignal/integrations/object_ruby_19.rb +0 -37
- data/lib/appsignal/integrations/object_ruby_modern.rb +0 -41
- data/lib/appsignal/integrations/resque_active_job.rb +0 -19
- data/lib/appsignal/js_exception_transaction.rb +0 -56
- data/lib/appsignal/rack/js_exception_catcher.rb +0 -80
- data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +0 -180
- data/spec/lib/appsignal/integrations/object_19_spec.rb +0 -266
- data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +0 -28
- data/spec/lib/appsignal/integrations/resque_spec.rb +0 -28
- data/spec/lib/appsignal/js_exception_transaction_spec.rb +0 -128
- data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +0 -170
data/gemfiles/grape.gemfile
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
if ruby_version < Gem::Version.new("2.3.0")
|
5
|
-
gem 'rack', '~> 1.6'
|
6
|
-
end
|
3
|
+
gem 'rack', '~> 1.6'
|
7
4
|
|
8
5
|
ruby_version = Gem::Version.new(RUBY_VERSION)
|
9
6
|
if ruby_version < Gem::Version.new("2.0.0")
|
data/gemfiles/rails-3.2.gemfile
CHANGED
data/gemfiles/rails-4.2.gemfile
CHANGED
@@ -13,11 +13,5 @@ end
|
|
13
13
|
if ruby_version < Gem::Version.new("2.1.0")
|
14
14
|
gem 'nokogiri', '~> 1.6.0'
|
15
15
|
end
|
16
|
-
if ruby_version < Gem::Version.new("2.5.0")
|
17
|
-
gem 'sprockets', '~> 3.7.2'
|
18
|
-
end
|
19
|
-
|
20
|
-
gem "minitest", "5.12.0"
|
21
|
-
gem "connection_pool", "2.2.3"
|
22
16
|
|
23
17
|
gemspec :path => '../'
|
data/gemfiles/resque-2.gemfile
CHANGED
data/gemfiles/sequel-435.gemfile
CHANGED
data/gemfiles/sequel.gemfile
CHANGED
data/gemfiles/sinatra.gemfile
CHANGED
data/lib/appsignal/auth_check.rb
CHANGED
@@ -20,16 +20,10 @@ module Appsignal
|
|
20
20
|
# https://push.appsignal.com/1/auth
|
21
21
|
ACTION = "auth".freeze
|
22
22
|
|
23
|
-
attr_reader :config
|
23
|
+
attr_reader :config
|
24
24
|
|
25
|
-
def initialize(config
|
25
|
+
def initialize(config)
|
26
26
|
@config = config
|
27
|
-
if logger # rubocop:disable Style/GuardClause
|
28
|
-
Appsignal::Utils::DeprecationMessage.message \
|
29
|
-
"`Appsignal::AuthCheck.new`'s `logger` argument will be removed " \
|
30
|
-
"in the next major version. Please configure the logger " \
|
31
|
-
"using `Appsignal.logger`."
|
32
|
-
end
|
33
27
|
end
|
34
28
|
|
35
29
|
# Perform push api validation request and return response status code.
|
data/lib/appsignal/cli.rb
CHANGED
@@ -7,12 +7,11 @@ require "appsignal/cli/helpers"
|
|
7
7
|
require "appsignal/cli/demo"
|
8
8
|
require "appsignal/cli/diagnose"
|
9
9
|
require "appsignal/cli/install"
|
10
|
-
require "appsignal/cli/notify_of_deploy"
|
11
10
|
|
12
11
|
module Appsignal
|
13
12
|
# @api private
|
14
13
|
class CLI
|
15
|
-
AVAILABLE_COMMANDS = %w[demo diagnose install
|
14
|
+
AVAILABLE_COMMANDS = %w[demo diagnose install].freeze
|
16
15
|
|
17
16
|
class << self
|
18
17
|
attr_accessor :options
|
@@ -33,8 +32,6 @@ module Appsignal
|
|
33
32
|
Appsignal::CLI::Diagnose.run(options)
|
34
33
|
when :install
|
35
34
|
Appsignal::CLI::Install.run(argv.shift, options)
|
36
|
-
when :notify_of_deploy
|
37
|
-
Appsignal::CLI::NotifyOfDeploy.run(options)
|
38
35
|
end
|
39
36
|
else
|
40
37
|
puts "Command '#{command}' does not exist, run appsignal -h to "\
|
@@ -93,25 +90,6 @@ module Appsignal
|
|
93
90
|
o.on "--[no-]color", "Colorize the output of the diagnose command" do |arg|
|
94
91
|
options[:color] = arg
|
95
92
|
end
|
96
|
-
end,
|
97
|
-
"notify_of_deploy" => OptionParser.new do |o|
|
98
|
-
o.banner = "Usage: appsignal notify_of_deploy [options]"
|
99
|
-
|
100
|
-
o.on "--revision=<revision>", "The revision you're deploying" do |arg|
|
101
|
-
options[:revision] = arg
|
102
|
-
end
|
103
|
-
|
104
|
-
o.on "--user=<user>", "The name of the user that's deploying" do |arg|
|
105
|
-
options[:user] = arg
|
106
|
-
end
|
107
|
-
|
108
|
-
o.on "--environment=<app_env>", "The environment you're deploying to" do |arg|
|
109
|
-
options[:environment] = arg
|
110
|
-
end
|
111
|
-
|
112
|
-
o.on "--name=<name>", "The name of the app (optional)" do |arg|
|
113
|
-
options[:name] = arg
|
114
|
-
end
|
115
93
|
end
|
116
94
|
}
|
117
95
|
end
|
data/lib/appsignal/config.rb
CHANGED
@@ -32,8 +32,6 @@ module Appsignal
|
|
32
32
|
:instrument_redis => true,
|
33
33
|
:instrument_sequel => true,
|
34
34
|
:skip_session_data => false,
|
35
|
-
:enable_frontend_error_catching => false,
|
36
|
-
:frontend_error_catching_path => "/appsignal_error_catcher",
|
37
35
|
:enable_allocation_tracking => true,
|
38
36
|
:enable_gc_instrumentation => false,
|
39
37
|
:enable_host_metrics => true,
|
@@ -49,7 +47,6 @@ module Appsignal
|
|
49
47
|
"APPSIGNAL_PUSH_API_KEY" => :push_api_key,
|
50
48
|
"APPSIGNAL_APP_NAME" => :name,
|
51
49
|
"APPSIGNAL_PUSH_API_ENDPOINT" => :endpoint,
|
52
|
-
"APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH" => :frontend_error_catching_path,
|
53
50
|
"APPSIGNAL_DEBUG" => :debug,
|
54
51
|
"APPSIGNAL_LOG" => :log,
|
55
52
|
"APPSIGNAL_LOG_PATH" => :log_path,
|
@@ -57,7 +54,6 @@ module Appsignal
|
|
57
54
|
"APPSIGNAL_INSTRUMENT_REDIS" => :instrument_redis,
|
58
55
|
"APPSIGNAL_INSTRUMENT_SEQUEL" => :instrument_sequel,
|
59
56
|
"APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
|
60
|
-
"APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING" => :enable_frontend_error_catching,
|
61
57
|
"APPSIGNAL_IGNORE_ACTIONS" => :ignore_actions,
|
62
58
|
"APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
|
63
59
|
"APPSIGNAL_IGNORE_NAMESPACES" => :ignore_namespaces,
|
@@ -86,7 +82,6 @@ module Appsignal
|
|
86
82
|
APPSIGNAL_APP_NAME
|
87
83
|
APPSIGNAL_CA_FILE_PATH
|
88
84
|
APPSIGNAL_DNS_SERVERS
|
89
|
-
APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH
|
90
85
|
APPSIGNAL_HOSTNAME
|
91
86
|
APPSIGNAL_HTTP_PROXY
|
92
87
|
APPSIGNAL_LOG
|
@@ -102,7 +97,6 @@ module Appsignal
|
|
102
97
|
APPSIGNAL_ACTIVE
|
103
98
|
APPSIGNAL_DEBUG
|
104
99
|
APPSIGNAL_ENABLE_ALLOCATION_TRACKING
|
105
|
-
APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING
|
106
100
|
APPSIGNAL_ENABLE_GC_INSTRUMENTATION
|
107
101
|
APPSIGNAL_ENABLE_HOST_METRICS
|
108
102
|
APPSIGNAL_ENABLE_MINUTELY_PROBES
|
@@ -126,12 +120,6 @@ module Appsignal
|
|
126
120
|
APPSIGNAL_REQUEST_HEADERS
|
127
121
|
].freeze
|
128
122
|
|
129
|
-
# Mapping of old and deprecated AppSignal configuration keys
|
130
|
-
DEPRECATED_CONFIG_KEY_MAPPING = {
|
131
|
-
:api_key => :push_api_key,
|
132
|
-
:ignore_exceptions => :ignore_errors
|
133
|
-
}.freeze
|
134
|
-
|
135
123
|
# @attribute [r] system_config
|
136
124
|
# Config detected on the system level.
|
137
125
|
# Used in diagnose report.
|
@@ -376,18 +364,6 @@ module Appsignal
|
|
376
364
|
# Used by {#load_from_disk}. No compatibility for env variables or initial config currently.
|
377
365
|
def maintain_backwards_compatibility(configuration)
|
378
366
|
configuration.tap do |config|
|
379
|
-
DEPRECATED_CONFIG_KEY_MAPPING.each do |old_key, new_key|
|
380
|
-
old_config_value = config.delete(old_key)
|
381
|
-
next unless old_config_value
|
382
|
-
deprecation_message \
|
383
|
-
"Old configuration key found. Please update the "\
|
384
|
-
"'#{old_key}' to '#{new_key}'.",
|
385
|
-
logger
|
386
|
-
|
387
|
-
next if config[new_key] # Skip if new key is already in use
|
388
|
-
config[new_key] = old_config_value
|
389
|
-
end
|
390
|
-
|
391
367
|
if config.include?(:working_dir_path)
|
392
368
|
deprecation_message \
|
393
369
|
"'working_dir_path' is deprecated, please use " \
|
@@ -20,20 +20,11 @@ module Appsignal
|
|
20
20
|
@formatters ||= {}
|
21
21
|
end
|
22
22
|
|
23
|
-
def deprecated_formatter_classes
|
24
|
-
@deprecated_formatter_classes ||= {}
|
25
|
-
end
|
26
|
-
|
27
23
|
def formatter_classes
|
28
24
|
@formatter_classes ||= {}
|
29
25
|
end
|
30
26
|
|
31
27
|
def register(name, formatter = nil)
|
32
|
-
unless formatter
|
33
|
-
register_deprecated_formatter(name)
|
34
|
-
return
|
35
|
-
end
|
36
|
-
|
37
28
|
if registered?(name, formatter)
|
38
29
|
logger.warn(
|
39
30
|
"Formatter for '#{name}' already registered, not registering "\
|
@@ -45,12 +36,6 @@ module Appsignal
|
|
45
36
|
initialize_formatter name, formatter
|
46
37
|
end
|
47
38
|
|
48
|
-
def initialize_deprecated_formatters
|
49
|
-
deprecated_formatter_classes.each do |name, formatter|
|
50
|
-
register(name, formatter)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
39
|
def unregister(name, formatter = self)
|
55
40
|
return unless formatter_classes[name] == formatter
|
56
41
|
|
@@ -86,16 +71,6 @@ module Appsignal
|
|
86
71
|
logger.error("'#{ex.message}' when initializing #{name} event formatter")
|
87
72
|
end
|
88
73
|
|
89
|
-
def register_deprecated_formatter(name)
|
90
|
-
deprecation_message \
|
91
|
-
"Formatter for '#{name}' is using a deprecated registration " \
|
92
|
-
"method. This event formatter will not be loaded. " \
|
93
|
-
"Please update the formatter according to the documentation at: " \
|
94
|
-
"https://docs.appsignal.com/ruby/instrumentation/event-formatters.html"
|
95
|
-
|
96
|
-
EventFormatter.deprecated_formatter_classes[name] = self
|
97
|
-
end
|
98
|
-
|
99
74
|
def logger
|
100
75
|
Appsignal.logger
|
101
76
|
end
|
data/lib/appsignal/extension.rb
CHANGED
@@ -40,16 +40,6 @@ module Appsignal
|
|
40
40
|
def method_missing(m, *args, &block)
|
41
41
|
super if Appsignal.testing?
|
42
42
|
end
|
43
|
-
|
44
|
-
unless Appsignal.extension_loaded?
|
45
|
-
def data_map_new
|
46
|
-
Appsignal::Extension::MockData.new
|
47
|
-
end
|
48
|
-
|
49
|
-
def data_array_new
|
50
|
-
Appsignal::Extension::MockData.new
|
51
|
-
end
|
52
|
-
end
|
53
43
|
end
|
54
44
|
|
55
45
|
if Appsignal::System.jruby?
|
@@ -72,45 +62,5 @@ module Appsignal
|
|
72
62
|
"#<#{self.class.name}:#{object_id} #{self}>"
|
73
63
|
end
|
74
64
|
end
|
75
|
-
|
76
|
-
# Mock of the {Data} class. This mock is used when the extension cannot be
|
77
|
-
# loaded. This mock listens to all method calls and does nothing, and
|
78
|
-
# prevents NoMethodErrors from being raised.
|
79
|
-
#
|
80
|
-
# Disabled in testing so we can make sure that we don't miss an extension
|
81
|
-
# function implementation.
|
82
|
-
#
|
83
|
-
# This class inherits from the {Data} class so that it passes type checks.
|
84
|
-
class MockData < Data
|
85
|
-
def initialize(*_args)
|
86
|
-
# JRuby extension requirement, as it sends a pointer to the Data object
|
87
|
-
# when creating it
|
88
|
-
end
|
89
|
-
|
90
|
-
def method_missing(_method, *_args, &_block)
|
91
|
-
super if Appsignal.testing?
|
92
|
-
end
|
93
|
-
|
94
|
-
def to_s
|
95
|
-
"{}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Mock of the {Transaction} class. This mock is used when the extension
|
100
|
-
# cannot be loaded. This mock listens to all method calls and does nothing,
|
101
|
-
# and prevents NoMethodErrors from being raised.
|
102
|
-
#
|
103
|
-
# Disabled in testing so we can make sure that we don't miss an extension
|
104
|
-
# function implementation.
|
105
|
-
class MockTransaction
|
106
|
-
def initialize(*_args)
|
107
|
-
# JRuby extension requirement, as it sends a pointer to the Transaction
|
108
|
-
# object when creating it
|
109
|
-
end
|
110
|
-
|
111
|
-
def method_missing(_method, *_args, &_block)
|
112
|
-
super if Appsignal.testing?
|
113
|
-
end
|
114
|
-
end
|
115
65
|
end
|
116
66
|
end
|
@@ -14,53 +14,18 @@ module Appsignal
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def install
|
17
|
-
|
17
|
+
require "appsignal/integrations/action_cable"
|
18
|
+
ActionCable::Channel::Base.send(:prepend, Appsignal::Integrations::ActionCableIntegration)
|
19
|
+
|
18
20
|
install_callbacks
|
19
21
|
end
|
20
22
|
|
21
23
|
private
|
22
24
|
|
23
|
-
def patch_perform_action
|
24
|
-
ActionCable::Channel::Base.class_eval do
|
25
|
-
alias_method :original_perform_action, :perform_action
|
26
|
-
|
27
|
-
def perform_action(*args, &block)
|
28
|
-
# The request is only the original websocket request
|
29
|
-
env = connection.env
|
30
|
-
request = ActionDispatch::Request.new(env)
|
31
|
-
env[Appsignal::Hooks::ActionCableHook::REQUEST_ID] ||=
|
32
|
-
request.request_id || SecureRandom.uuid
|
33
|
-
|
34
|
-
transaction = Appsignal::Transaction.create(
|
35
|
-
env[Appsignal::Hooks::ActionCableHook::REQUEST_ID],
|
36
|
-
Appsignal::Transaction::ACTION_CABLE,
|
37
|
-
request
|
38
|
-
)
|
39
|
-
|
40
|
-
begin
|
41
|
-
original_perform_action(*args, &block)
|
42
|
-
rescue Exception => exception # rubocop:disable Lint/RescueException
|
43
|
-
transaction.set_error(exception)
|
44
|
-
raise exception
|
45
|
-
ensure
|
46
|
-
transaction.params = args.first
|
47
|
-
transaction.set_action_if_nil("#{self.class}##{args.first["action"]}")
|
48
|
-
transaction.set_metadata("path", request.path)
|
49
|
-
transaction.set_metadata("method", "websocket")
|
50
|
-
Appsignal::Transaction.complete_current!
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
25
|
def install_callbacks
|
57
26
|
ActionCable::Channel::Base.set_callback :subscribe, :around, :prepend => true do |channel, inner|
|
58
27
|
# The request is only the original websocket request
|
59
|
-
|
60
|
-
# #env is not available on the Rails ConnectionStub class used in the
|
61
|
-
# Rails app test suite. If we call `#env` it causes an error to occur
|
62
|
-
# in apps' test suites.
|
63
|
-
env = connection.respond_to?(:env) ? connection.env : {}
|
28
|
+
env = channel.connection.env
|
64
29
|
request = ActionDispatch::Request.new(env)
|
65
30
|
env[Appsignal::Hooks::ActionCableHook::REQUEST_ID] ||=
|
66
31
|
request.request_id || SecureRandom.uuid
|
@@ -88,11 +53,7 @@ module Appsignal
|
|
88
53
|
|
89
54
|
ActionCable::Channel::Base.set_callback :unsubscribe, :around, :prepend => true do |channel, inner|
|
90
55
|
# The request is only the original websocket request
|
91
|
-
|
92
|
-
# #env is not available on the Rails ConnectionStub class used in the
|
93
|
-
# Rails app test suite. If we call `#env` it causes an error to occur
|
94
|
-
# in apps' test suites.
|
95
|
-
env = connection.respond_to?(:env) ? connection.env : {}
|
56
|
+
env = channel.connection.env
|
96
57
|
request = ActionDispatch::Request.new(env)
|
97
58
|
env[Appsignal::Hooks::ActionCableHook::REQUEST_ID] ||=
|
98
59
|
request.request_id || SecureRandom.uuid
|
@@ -6,8 +6,6 @@ module Appsignal
|
|
6
6
|
class ActiveSupportNotificationsHook < Appsignal::Hooks::Hook
|
7
7
|
register :active_support_notifications
|
8
8
|
|
9
|
-
BANG = "!".freeze
|
10
|
-
|
11
9
|
def dependencies_present?
|
12
10
|
defined?(::ActiveSupport::Notifications::Instrumenter)
|
13
11
|
end
|
@@ -23,100 +21,23 @@ module Appsignal
|
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
24
|
+
require "appsignal/integrations/active_support_notifications"
|
26
25
|
instrumenter = ::ActiveSupport::Notifications::Instrumenter
|
27
|
-
|
26
|
+
parent_integration_module = Appsignal::Integrations::ActiveSupportNotificationsIntegration
|
28
27
|
if instrumenter.method_defined?(:start) && instrumenter.method_defined?(:finish)
|
29
|
-
|
28
|
+
install_module(parent_integration_module::StartFinishIntegration)
|
30
29
|
else
|
31
|
-
|
30
|
+
install_module(parent_integration_module::InstrumentIntegration)
|
32
31
|
end
|
33
32
|
|
34
33
|
# rubocop:disable Style/GuardClause
|
35
34
|
if instrumenter.method_defined?(:finish_with_state)
|
36
|
-
|
35
|
+
install_module(parent_integration_module::FinishStateIntegration)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
def
|
41
|
-
::ActiveSupport::Notifications::Instrumenter.
|
42
|
-
alias instrument_without_appsignal instrument
|
43
|
-
|
44
|
-
def instrument(name, payload = {}, &block)
|
45
|
-
# Events that start with a bang are internal to Rails
|
46
|
-
instrument_this = name[0] != BANG
|
47
|
-
|
48
|
-
Appsignal::Transaction.current.start_event if instrument_this
|
49
|
-
|
50
|
-
instrument_without_appsignal(name, payload, &block)
|
51
|
-
ensure
|
52
|
-
if instrument_this
|
53
|
-
title, body, body_format = Appsignal::EventFormatter.format(name, payload)
|
54
|
-
Appsignal::Transaction.current.finish_event(
|
55
|
-
name.to_s,
|
56
|
-
title,
|
57
|
-
body,
|
58
|
-
body_format
|
59
|
-
)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def install_start_finish
|
66
|
-
::ActiveSupport::Notifications::Instrumenter.class_eval do
|
67
|
-
alias start_without_appsignal start
|
68
|
-
|
69
|
-
def start(name, payload = {})
|
70
|
-
# Events that start with a bang are internal to Rails
|
71
|
-
instrument_this = name[0] != BANG
|
72
|
-
|
73
|
-
Appsignal::Transaction.current.start_event if instrument_this
|
74
|
-
|
75
|
-
start_without_appsignal(name, payload)
|
76
|
-
end
|
77
|
-
|
78
|
-
alias finish_without_appsignal finish
|
79
|
-
|
80
|
-
def finish(name, payload = {})
|
81
|
-
# Events that start with a bang are internal to Rails
|
82
|
-
instrument_this = name[0] != BANG
|
83
|
-
|
84
|
-
if instrument_this
|
85
|
-
title, body, body_format = Appsignal::EventFormatter.format(name, payload)
|
86
|
-
Appsignal::Transaction.current.finish_event(
|
87
|
-
name.to_s,
|
88
|
-
title,
|
89
|
-
body,
|
90
|
-
body_format
|
91
|
-
)
|
92
|
-
end
|
93
|
-
|
94
|
-
finish_without_appsignal(name, payload)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def install_finish_with_state
|
100
|
-
::ActiveSupport::Notifications::Instrumenter.class_eval do
|
101
|
-
alias finish_with_state_without_appsignal finish_with_state
|
102
|
-
|
103
|
-
def finish_with_state(listeners_state, name, payload = {})
|
104
|
-
# Events that start with a bang are internal to Rails
|
105
|
-
instrument_this = name[0] != BANG
|
106
|
-
|
107
|
-
if instrument_this
|
108
|
-
title, body, body_format = Appsignal::EventFormatter.format(name, payload)
|
109
|
-
Appsignal::Transaction.current.finish_event(
|
110
|
-
name.to_s,
|
111
|
-
title,
|
112
|
-
body,
|
113
|
-
body_format
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
finish_with_state_without_appsignal(listeners_state, name, payload)
|
118
|
-
end
|
119
|
-
end
|
39
|
+
def install_module(mod)
|
40
|
+
::ActiveSupport::Notifications::Instrumenter.send(:prepend, mod)
|
120
41
|
end
|
121
42
|
end
|
122
43
|
end
|
@@ -16,16 +16,12 @@ module Appsignal
|
|
16
16
|
# down Celluloid so we're sure our thread does not aggravate this situation.
|
17
17
|
# This way we also make sure any outstanding transactions get flushed.
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def shutdown
|
24
|
-
Appsignal.stop("celluloid")
|
25
|
-
shutdown_without_appsignal
|
26
|
-
end
|
19
|
+
Celluloid.singleton_class.send(:prepend, Module.new do
|
20
|
+
def shutdown
|
21
|
+
Appsignal.stop("celluloid")
|
22
|
+
super
|
27
23
|
end
|
28
|
-
end
|
24
|
+
end)
|
29
25
|
end
|
30
26
|
end
|
31
27
|
end
|
@@ -13,18 +13,8 @@ module Appsignal
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def install
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def request(request, body = nil, &block)
|
20
|
-
Appsignal.instrument(
|
21
|
-
"request.net_http",
|
22
|
-
"#{request.method} #{use_ssl? ? "https" : "http"}://#{request["host"] || address}"
|
23
|
-
) do
|
24
|
-
request_without_appsignal(request, body, &block)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
16
|
+
require "appsignal/integrations/net_http"
|
17
|
+
Net::HTTP.send(:prepend, Appsignal::Integrations::NetHttpIntegration)
|
28
18
|
|
29
19
|
Appsignal::Environment.report_enabled("net_http")
|
30
20
|
end
|
data/lib/appsignal/hooks/puma.rb
CHANGED
@@ -29,14 +29,12 @@ module Appsignal
|
|
29
29
|
|
30
30
|
return unless defined?(::Puma::Cluster)
|
31
31
|
# For clustered mode with multiple workers
|
32
|
-
::Puma::Cluster.
|
33
|
-
alias stop_workers_without_appsignal stop_workers
|
34
|
-
|
32
|
+
::Puma::Cluster.send(:prepend, Module.new do
|
35
33
|
def stop_workers
|
36
34
|
Appsignal.stop("puma cluster")
|
37
|
-
|
35
|
+
super
|
38
36
|
end
|
39
|
-
end
|
37
|
+
end)
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
data/lib/appsignal/hooks/que.rb
CHANGED
@@ -12,7 +12,7 @@ module Appsignal
|
|
12
12
|
|
13
13
|
def install
|
14
14
|
require "appsignal/integrations/que"
|
15
|
-
::Que::Job.send(:
|
15
|
+
::Que::Job.send(:prepend, Appsignal::Integrations::QuePlugin)
|
16
16
|
|
17
17
|
::Que.error_notifier = proc do |error, _job|
|
18
18
|
Appsignal::Transaction.current.set_error(error)
|
data/lib/appsignal/hooks/rake.rb
CHANGED
@@ -11,30 +11,8 @@ module Appsignal
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def install
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def execute(*args)
|
18
|
-
execute_without_appsignal(*args)
|
19
|
-
rescue Exception => error # rubocop:disable Lint/RescueException
|
20
|
-
# Format given arguments and cast to hash if possible
|
21
|
-
params, _ = args
|
22
|
-
params = params.to_hash if params.respond_to?(:to_hash)
|
23
|
-
|
24
|
-
transaction = Appsignal::Transaction.create(
|
25
|
-
SecureRandom.uuid,
|
26
|
-
Appsignal::Transaction::BACKGROUND_JOB,
|
27
|
-
Appsignal::Transaction::GenericRequest.new(
|
28
|
-
:params => params
|
29
|
-
)
|
30
|
-
)
|
31
|
-
transaction.set_action(name)
|
32
|
-
transaction.set_error(error)
|
33
|
-
transaction.complete
|
34
|
-
Appsignal.stop("rake")
|
35
|
-
raise error
|
36
|
-
end
|
37
|
-
end
|
14
|
+
require "appsignal/integrations/rake"
|
15
|
+
::Rake::Task.send(:prepend, Appsignal::Integrations::RakeIntegration)
|
38
16
|
end
|
39
17
|
end
|
40
18
|
end
|
@@ -13,19 +13,8 @@ module Appsignal
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def install
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def process(commands, &block)
|
20
|
-
sanitized_commands = commands.map do |command, *args|
|
21
|
-
"#{command}#{" ?" * args.size}"
|
22
|
-
end.join("\n")
|
23
|
-
|
24
|
-
Appsignal.instrument "query.redis", id, sanitized_commands do
|
25
|
-
process_without_appsignal(commands, &block)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
16
|
+
require "appsignal/integrations/redis"
|
17
|
+
::Redis::Client.send(:prepend, Appsignal::Integrations::RedisIntegration)
|
29
18
|
|
30
19
|
Appsignal::Environment.report_enabled("redis")
|
31
20
|
end
|