appsignal 2.11.9-java → 3.0.0.beta.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/.semaphore/semaphore.yml +0 -23
  4. data/CHANGELOG.md +5 -14
  5. data/build_matrix.yml +0 -4
  6. data/lib/appsignal.rb +1 -27
  7. data/lib/appsignal/auth_check.rb +2 -8
  8. data/lib/appsignal/cli.rb +1 -23
  9. data/lib/appsignal/config.rb +0 -24
  10. data/lib/appsignal/event_formatter.rb +0 -25
  11. data/lib/appsignal/hooks.rb +0 -23
  12. data/lib/appsignal/hooks/action_cable.rb +5 -44
  13. data/lib/appsignal/hooks/active_support_notifications.rb +7 -86
  14. data/lib/appsignal/hooks/celluloid.rb +5 -9
  15. data/lib/appsignal/hooks/net_http.rb +2 -12
  16. data/lib/appsignal/hooks/puma.rb +3 -5
  17. data/lib/appsignal/hooks/que.rb +1 -1
  18. data/lib/appsignal/hooks/rake.rb +2 -24
  19. data/lib/appsignal/hooks/redis.rb +2 -13
  20. data/lib/appsignal/hooks/resque.rb +2 -43
  21. data/lib/appsignal/hooks/sidekiq.rb +1 -5
  22. data/lib/appsignal/hooks/unicorn.rb +3 -24
  23. data/lib/appsignal/hooks/webmachine.rb +1 -7
  24. data/lib/appsignal/integrations/action_cable.rb +34 -0
  25. data/lib/appsignal/integrations/active_support_notifications.rb +77 -0
  26. data/lib/appsignal/integrations/net_http.rb +16 -0
  27. data/lib/appsignal/integrations/object.rb +61 -4
  28. data/lib/appsignal/integrations/padrino.rb +5 -7
  29. data/lib/appsignal/integrations/que.rb +26 -33
  30. data/lib/appsignal/integrations/railtie.rb +1 -4
  31. data/lib/appsignal/integrations/rake.rb +26 -2
  32. data/lib/appsignal/integrations/redis.rb +17 -0
  33. data/lib/appsignal/integrations/resque.rb +39 -10
  34. data/lib/appsignal/integrations/unicorn.rb +28 -0
  35. data/lib/appsignal/integrations/webmachine.rb +22 -24
  36. data/lib/appsignal/minutely.rb +0 -18
  37. data/lib/appsignal/version.rb +1 -1
  38. data/spec/lib/appsignal/auth_check_spec.rb +1 -24
  39. data/spec/lib/appsignal/cli_spec.rb +1 -1
  40. data/spec/lib/appsignal/config_spec.rb +0 -66
  41. data/spec/lib/appsignal/event_formatter_spec.rb +0 -37
  42. data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -88
  43. data/spec/lib/appsignal/hooks/celluloid_spec.rb +6 -1
  44. data/spec/lib/appsignal/hooks/rake_spec.rb +1 -2
  45. data/spec/lib/appsignal/hooks/redis_spec.rb +50 -15
  46. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +7 -61
  47. data/spec/lib/appsignal/hooks/unicorn_spec.rb +14 -3
  48. data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -13
  49. data/spec/lib/appsignal/hooks_spec.rb +0 -57
  50. data/spec/lib/appsignal/integrations/object_spec.rb +4 -95
  51. data/spec/lib/appsignal/integrations/padrino_spec.rb +2 -3
  52. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -45
  53. data/spec/lib/appsignal/integrations/webmachine_spec.rb +26 -8
  54. data/spec/lib/appsignal/minutely_spec.rb +0 -19
  55. data/spec/lib/appsignal/transaction_spec.rb +1 -14
  56. data/spec/lib/appsignal/transmitter_spec.rb +1 -1
  57. data/spec/lib/appsignal_spec.rb +0 -69
  58. data/spec/lib/puma/appsignal_spec.rb +0 -28
  59. data/spec/spec_helper.rb +1 -15
  60. metadata +10 -23
  61. data/lib/appsignal/cli/notify_of_deploy.rb +0 -131
  62. data/lib/appsignal/integrations/object_ruby_19.rb +0 -37
  63. data/lib/appsignal/integrations/object_ruby_modern.rb +0 -41
  64. data/lib/appsignal/integrations/resque_active_job.rb +0 -19
  65. data/lib/appsignal/js_exception_transaction.rb +0 -56
  66. data/lib/appsignal/rack/js_exception_catcher.rb +0 -80
  67. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +0 -180
  68. data/spec/lib/appsignal/integrations/object_19_spec.rb +0 -266
  69. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +0 -28
  70. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -28
  71. data/spec/lib/appsignal/js_exception_transaction_spec.rb +0 -128
  72. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +0 -170
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Integrations
5
+ module NetHttpIntegration
6
+ def request(request, body = nil, &block)
7
+ Appsignal.instrument(
8
+ "request.net_http",
9
+ "#{request.method} #{use_ssl? ? "https" : "http"}://#{request["host"] || address}"
10
+ ) do
11
+ super
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -4,8 +4,65 @@ if defined?(Appsignal)
4
4
  Appsignal::Environment.report_enabled("object_instrumentation")
5
5
  end
6
6
 
7
- if RUBY_VERSION < "2.0"
8
- require "appsignal/integrations/object_ruby_19"
9
- else
10
- require "appsignal/integrations/object_ruby_modern"
7
+ class Object
8
+ if Appsignal::System.ruby_2_7_or_newer?
9
+ def self.appsignal_instrument_class_method(method_name, options = {})
10
+ singleton_class.send \
11
+ :alias_method, "appsignal_uninstrumented_#{method_name}", method_name
12
+ singleton_class.send(:define_method, method_name) do |*args, **kwargs, &block|
13
+ name = options.fetch(:name) do
14
+ "#{method_name}.class_method.#{appsignal_reverse_class_name}.other"
15
+ end
16
+ Appsignal.instrument name do
17
+ send "appsignal_uninstrumented_#{method_name}", *args, **kwargs, &block
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.appsignal_instrument_method(method_name, options = {})
23
+ alias_method "appsignal_uninstrumented_#{method_name}", method_name
24
+ define_method method_name do |*args, **kwargs, &block|
25
+ name = options.fetch(:name) do
26
+ "#{method_name}.#{appsignal_reverse_class_name}.other"
27
+ end
28
+ Appsignal.instrument name do
29
+ send "appsignal_uninstrumented_#{method_name}", *args, **kwargs, &block
30
+ end
31
+ end
32
+ end
33
+ else
34
+ def self.appsignal_instrument_class_method(method_name, options = {})
35
+ singleton_class.send \
36
+ :alias_method, "appsignal_uninstrumented_#{method_name}", method_name
37
+ singleton_class.send(:define_method, method_name) do |*args, &block|
38
+ name = options.fetch(:name) do
39
+ "#{method_name}.class_method.#{appsignal_reverse_class_name}.other"
40
+ end
41
+ Appsignal.instrument name do
42
+ send "appsignal_uninstrumented_#{method_name}", *args, &block
43
+ end
44
+ end
45
+ end
46
+
47
+ def self.appsignal_instrument_method(method_name, options = {})
48
+ alias_method "appsignal_uninstrumented_#{method_name}", method_name
49
+ define_method method_name do |*args, &block|
50
+ name = options.fetch(:name) do
51
+ "#{method_name}.#{appsignal_reverse_class_name}.other"
52
+ end
53
+ Appsignal.instrument name do
54
+ send "appsignal_uninstrumented_#{method_name}", *args, &block
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ def self.appsignal_reverse_class_name
61
+ return "AnonymousClass" unless name
62
+ name.split("::").reverse.join(".")
63
+ end
64
+
65
+ def appsignal_reverse_class_name
66
+ self.class.appsignal_reverse_class_name
67
+ end
11
68
  end
@@ -19,13 +19,9 @@ module Appsignal
19
19
  end
20
20
  end
21
21
 
22
- module Padrino::Routing::InstanceMethods
23
- alias route_without_appsignal route!
24
-
22
+ module Appsignal::Integrations::PadrinoIntegration
25
23
  def route!(base = settings, pass_block = nil)
26
- if !Appsignal.active? || env["sinatra.static_file"]
27
- return route_without_appsignal(base, pass_block)
28
- end
24
+ return super if !Appsignal.active? || env["sinatra.static_file"]
29
25
 
30
26
  transaction = Appsignal::Transaction.create(
31
27
  SecureRandom.uuid,
@@ -34,7 +30,7 @@ module Padrino::Routing::InstanceMethods
34
30
  )
35
31
  begin
36
32
  Appsignal.instrument("process_action.padrino") do
37
- route_without_appsignal(base, pass_block)
33
+ super
38
34
  end
39
35
  rescue Exception => error # rubocop:disable Lint/RescueException
40
36
  transaction.set_error(error)
@@ -78,6 +74,8 @@ module Padrino::Routing::InstanceMethods
78
74
  end
79
75
  end
80
76
 
77
+ Padrino::Application.send(:prepend, Appsignal::Integrations::PadrinoIntegration)
78
+
81
79
  Padrino.after_load do
82
80
  Appsignal::Integrations::PadrinoPlugin.init
83
81
  end
@@ -3,42 +3,35 @@
3
3
  module Appsignal
4
4
  module Integrations
5
5
  module QuePlugin
6
- def self.included(base)
7
- base.class_eval do
8
- def _run_with_appsignal(*)
9
- local_attrs = respond_to?(:que_attrs) ? que_attrs : attrs
10
- env = {
11
- :metadata => {
12
- :id => local_attrs[:job_id] || local_attrs[:id],
13
- :queue => local_attrs[:queue],
14
- :run_at => local_attrs[:run_at].to_s,
15
- :priority => local_attrs[:priority],
16
- :attempts => local_attrs[:error_count].to_i
17
- },
18
- :params => local_attrs[:args]
19
- }
6
+ def _run(*)
7
+ local_attrs = respond_to?(:que_attrs) ? que_attrs : attrs
8
+ env = {
9
+ :metadata => {
10
+ :id => local_attrs[:job_id] || local_attrs[:id],
11
+ :queue => local_attrs[:queue],
12
+ :run_at => local_attrs[:run_at].to_s,
13
+ :priority => local_attrs[:priority],
14
+ :attempts => local_attrs[:error_count].to_i
15
+ },
16
+ :params => local_attrs[:args]
17
+ }
20
18
 
21
- request = Appsignal::Transaction::GenericRequest.new(env)
19
+ request = Appsignal::Transaction::GenericRequest.new(env)
22
20
 
23
- transaction = Appsignal::Transaction.create(
24
- SecureRandom.uuid,
25
- Appsignal::Transaction::BACKGROUND_JOB,
26
- request
27
- )
21
+ transaction = Appsignal::Transaction.create(
22
+ SecureRandom.uuid,
23
+ Appsignal::Transaction::BACKGROUND_JOB,
24
+ request
25
+ )
28
26
 
29
- begin
30
- Appsignal.instrument("perform_job.que") { _run_without_appsignal }
31
- rescue Exception => error # rubocop:disable Lint/RescueException
32
- transaction.set_error(error)
33
- raise error
34
- ensure
35
- transaction.set_action_if_nil "#{local_attrs[:job_class]}#run"
36
- Appsignal::Transaction.complete_current!
37
- end
38
- end
39
-
40
- alias_method :_run_without_appsignal, :_run
41
- alias_method :_run, :_run_with_appsignal
27
+ begin
28
+ Appsignal.instrument("perform_job.que") { super }
29
+ rescue Exception => error # rubocop:disable Lint/RescueException
30
+ transaction.set_error(error)
31
+ raise error
32
+ ensure
33
+ transaction.set_action_if_nil "#{local_attrs[:job_class]}#run"
34
+ Appsignal::Transaction.complete_current!
42
35
  end
43
36
  end
44
37
  end
@@ -31,10 +31,7 @@ module Appsignal
31
31
  )
32
32
 
33
33
  if Appsignal.config[:enable_frontend_error_catching]
34
- app.middleware.insert_before(
35
- Appsignal::Rack::RailsInstrumentation,
36
- Appsignal::Rack::JSExceptionCatcher
37
- )
34
+ app.middleware.insert_before(Appsignal::Rack::RailsInstrumentation)
38
35
  end
39
36
 
40
37
  Appsignal.start
@@ -1,4 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Since version 1.0 requiring this file is not necessary anymore to get
4
- # Rake integration, it's just here for backward compatibility.
3
+ module Appsignal
4
+ module Integrations
5
+ module RakeIntegration
6
+ def execute(*args)
7
+ super
8
+ rescue Exception => error # rubocop:disable Lint/RescueException
9
+ # Format given arguments and cast to hash if possible
10
+ params, _ = args
11
+ params = params.to_hash if params.respond_to?(:to_hash)
12
+
13
+ transaction = Appsignal::Transaction.create(
14
+ SecureRandom.uuid,
15
+ Appsignal::Transaction::BACKGROUND_JOB,
16
+ Appsignal::Transaction::GenericRequest.new(
17
+ :params => params
18
+ )
19
+ )
20
+ transaction.set_action(name)
21
+ transaction.set_error(error)
22
+ transaction.complete
23
+ Appsignal.stop("rake")
24
+ raise error
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Integrations
5
+ module RedisIntegration
6
+ def process(commands, &block)
7
+ sanitized_commands = commands.map do |command, *args|
8
+ "#{command}#{" ?" * args.size}"
9
+ end.join("\n")
10
+
11
+ Appsignal.instrument "query.redis", id, sanitized_commands do
12
+ super
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,16 +3,45 @@
3
3
  module Appsignal
4
4
  module Integrations
5
5
  # @api private
6
- module ResquePlugin
7
- def self.extended(_)
8
- callers = caller
9
- Appsignal::Utils::DeprecationMessage.message \
10
- "The AppSignal ResquePlugin is deprecated and does " \
11
- "nothing on extend. In this version of the AppSignal Ruby gem " \
12
- "the integration with Resque is automatic on all Resque workers. " \
13
- "Please remove the following line from this file to remove this " \
14
- "message: extend Appsignal::Integrations::ResquePlugin\n" \
15
- "#{callers.first}"
6
+ module ResqueIntegration
7
+ def perform
8
+ transaction = Appsignal::Transaction.create(
9
+ SecureRandom.uuid,
10
+ Appsignal::Transaction::BACKGROUND_JOB,
11
+ Appsignal::Transaction::GenericRequest.new({})
12
+ )
13
+
14
+ Appsignal.instrument "perform.resque" do
15
+ super
16
+ end
17
+ rescue Exception => exception # rubocop:disable Lint/RescueException
18
+ transaction.set_error(exception)
19
+ raise exception
20
+ ensure
21
+ if transaction
22
+ transaction.set_action_if_nil("#{payload["class"]}#perform")
23
+ args =
24
+ Appsignal::Utils::HashSanitizer.sanitize(
25
+ ResqueHelpers.arguments(payload),
26
+ Appsignal.config[:filter_parameters]
27
+ )
28
+ transaction.params = args if args
29
+ transaction.set_tags("queue" => queue)
30
+
31
+ Appsignal::Transaction.complete_current!
32
+ end
33
+ Appsignal.stop("resque")
34
+ end
35
+ end
36
+
37
+ class ResqueHelpers
38
+ def self.arguments(payload)
39
+ case payload["class"]
40
+ when "ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper"
41
+ nil # Set in the ActiveJob integration
42
+ else
43
+ payload["args"]
44
+ end
16
45
  end
17
46
  end
18
47
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Integrations
5
+ module UnicornIntegration
6
+ # Make sure that appsignal is started and the last transaction
7
+ # in a worker gets flushed.
8
+ #
9
+ # We'd love to be able to hook this into Unicorn in a less
10
+ # intrusive way, but this is the best we can do given the
11
+ # options we have.
12
+
13
+ module Server
14
+ def worker_loop(worker)
15
+ Appsignal.forked
16
+ super
17
+ end
18
+ end
19
+
20
+ module Worker
21
+ def close
22
+ Appsignal.stop("unicorn")
23
+ super
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -3,35 +3,33 @@
3
3
  module Appsignal
4
4
  module Integrations
5
5
  # @api private
6
- module WebmachinePlugin
7
- module FSM
8
- def run_with_appsignal
9
- transaction = Appsignal::Transaction.create(
10
- SecureRandom.uuid,
11
- Appsignal::Transaction::HTTP_REQUEST,
12
- request,
13
- :params_method => :query
14
- )
6
+ module WebmachineIntegration
7
+ def run
8
+ transaction = Appsignal::Transaction.create(
9
+ SecureRandom.uuid,
10
+ Appsignal::Transaction::HTTP_REQUEST,
11
+ request,
12
+ :params_method => :query
13
+ )
15
14
 
16
- transaction.set_action_if_nil("#{resource.class.name}##{request.method}")
15
+ transaction.set_action_if_nil("#{resource.class.name}##{request.method}")
17
16
 
18
- Appsignal.instrument("process_action.webmachine") do
19
- run_without_appsignal
20
- end
21
-
22
- Appsignal::Transaction.complete_current!
17
+ Appsignal.instrument("process_action.webmachine") do
18
+ super
23
19
  end
24
20
 
25
- private
21
+ Appsignal::Transaction.complete_current!
22
+ end
23
+
24
+ private
26
25
 
27
- def handle_exceptions_with_appsignal
28
- handle_exceptions_without_appsignal do
29
- begin
30
- yield
31
- rescue Exception => e # rubocop:disable Lint/RescueException
32
- Appsignal.set_error(e)
33
- raise e
34
- end
26
+ def handle_exceptions
27
+ super do
28
+ begin
29
+ yield
30
+ rescue Exception => e # rubocop:disable Lint/RescueException
31
+ Appsignal.set_error(e)
32
+ raise e
35
33
  end
36
34
  end
37
35
  end
@@ -3,8 +3,6 @@
3
3
  module Appsignal
4
4
  class Minutely
5
5
  class ProbeCollection
6
- include Appsignal::Utils::DeprecationMessage
7
-
8
6
  def initialize
9
7
  @probes = {}
10
8
  end
@@ -27,16 +25,6 @@ module Appsignal
27
25
  probes[key]
28
26
  end
29
27
 
30
- # @param probe [Object] Any object that listens to the `call` method will
31
- # be used as a probe.
32
- # @deprecated Use {#register} instead.
33
- # @return [void]
34
- def <<(probe)
35
- deprecation_message "Deprecated `Appsignal::Minute.probes <<` " \
36
- "call. Please use `Appsignal::Minutely.probes.register` instead."
37
- register probe.object_id, probe
38
- end
39
-
40
28
  # Register a new minutely probe.
41
29
  #
42
30
  # Supported probe types are:
@@ -135,12 +123,6 @@ module Appsignal
135
123
  def start
136
124
  stop
137
125
  @thread = Thread.new do
138
- # Advise multi-threaded app servers to ignore this thread
139
- # for the purposes of fork safety warnings
140
- if Thread.current.respond_to?(:thread_variable_set)
141
- Thread.current.thread_variable_set(:fork_safe, true)
142
- end
143
-
144
126
  sleep initial_wait_time
145
127
  initialize_probes
146
128
  loop do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "2.11.9".freeze
4
+ VERSION = "3.0.0.beta.1".freeze
5
5
  end