appsignal 3.13.0 → 4.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +499 -487
  3. data/CHANGELOG.md +113 -0
  4. data/Rakefile +31 -7
  5. data/benchmark.rake +4 -6
  6. data/build_matrix.yml +45 -39
  7. data/ext/agent.rb +27 -27
  8. data/ext/appsignal_extension.c +25 -0
  9. data/gemfiles/rails-7.2.gemfile +11 -0
  10. data/lib/appsignal/check_in/cron.rb +2 -15
  11. data/lib/appsignal/cli/diagnose.rb +37 -28
  12. data/lib/appsignal/cli/install.rb +5 -1
  13. data/lib/appsignal/config.rb +57 -119
  14. data/lib/appsignal/demo.rb +2 -2
  15. data/lib/appsignal/extension/jruby.rb +14 -0
  16. data/lib/appsignal/helpers/instrumentation.rb +139 -417
  17. data/lib/appsignal/helpers/metrics.rb +0 -16
  18. data/lib/appsignal/hooks/action_cable.rb +8 -8
  19. data/lib/appsignal/hooks/active_job.rb +2 -2
  20. data/lib/appsignal/hooks/at_exit.rb +37 -0
  21. data/lib/appsignal/hooks.rb +1 -16
  22. data/lib/appsignal/integrations/action_cable.rb +2 -2
  23. data/lib/appsignal/integrations/capistrano/appsignal.cap +2 -4
  24. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -4
  25. data/lib/appsignal/integrations/delayed_job_plugin.rb +3 -3
  26. data/lib/appsignal/integrations/que.rb +2 -2
  27. data/lib/appsignal/integrations/railtie.rb +26 -59
  28. data/lib/appsignal/integrations/rake.rb +2 -2
  29. data/lib/appsignal/integrations/resque.rb +2 -2
  30. data/lib/appsignal/integrations/shoryuken.rb +4 -4
  31. data/lib/appsignal/integrations/sidekiq.rb +3 -3
  32. data/lib/appsignal/integrations/webmachine.rb +2 -2
  33. data/lib/appsignal/loaders.rb +1 -1
  34. data/lib/appsignal/probes.rb +0 -9
  35. data/lib/appsignal/rack/abstract_middleware.rb +4 -26
  36. data/lib/appsignal/rack/event_handler.rb +4 -4
  37. data/lib/appsignal/rack/rails_instrumentation.rb +1 -1
  38. data/lib/appsignal/rack.rb +0 -25
  39. data/lib/appsignal/sample_data.rb +95 -0
  40. data/lib/appsignal/transaction.rb +235 -361
  41. data/lib/appsignal/utils/rails_helper.rb +4 -0
  42. data/lib/appsignal/version.rb +1 -1
  43. data/lib/appsignal.rb +19 -71
  44. data/spec/lib/appsignal/auth_check_spec.rb +1 -1
  45. data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
  46. data/spec/lib/appsignal/capistrano3_spec.rb +53 -13
  47. data/spec/lib/appsignal/check_in_spec.rb +1 -207
  48. data/spec/lib/appsignal/cli/demo_spec.rb +7 -27
  49. data/spec/lib/appsignal/cli/diagnose_spec.rb +145 -110
  50. data/spec/lib/appsignal/config_spec.rb +304 -379
  51. data/spec/lib/appsignal/extension_install_failure_spec.rb +5 -1
  52. data/spec/lib/appsignal/extension_spec.rb +5 -1
  53. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +1 -1
  54. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +1 -2
  55. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +1 -0
  56. data/spec/lib/appsignal/hooks/activejob_spec.rb +7 -12
  57. data/spec/lib/appsignal/hooks/at_exit_spec.rb +72 -0
  58. data/spec/lib/appsignal/hooks/gvl_spec.rb +10 -5
  59. data/spec/lib/appsignal/hooks/http_spec.rb +3 -3
  60. data/spec/lib/appsignal/hooks/net_http_spec.rb +3 -3
  61. data/spec/lib/appsignal/hooks/rake_spec.rb +6 -9
  62. data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -10
  63. data/spec/lib/appsignal/hooks/redis_spec.rb +4 -7
  64. data/spec/lib/appsignal/hooks/resque_spec.rb +3 -5
  65. data/spec/lib/appsignal/hooks_spec.rb +0 -41
  66. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +29 -20
  67. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +4 -9
  68. data/spec/lib/appsignal/integrations/railtie_spec.rb +179 -157
  69. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +3 -5
  70. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +48 -62
  71. data/spec/lib/appsignal/loaders/hanami_spec.rb +6 -9
  72. data/spec/lib/appsignal/loaders/padrino_spec.rb +6 -10
  73. data/spec/lib/appsignal/loaders/sinatra_spec.rb +6 -9
  74. data/spec/lib/appsignal/loaders_spec.rb +8 -1
  75. data/spec/lib/appsignal/marker_spec.rb +1 -1
  76. data/spec/lib/appsignal/probes_spec.rb +4 -83
  77. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +4 -63
  78. data/spec/lib/appsignal/rack/event_handler_spec.rb +18 -15
  79. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -11
  80. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +4 -5
  81. data/spec/lib/appsignal/sample_data_spec.rb +174 -0
  82. data/spec/lib/appsignal/transaction_spec.rb +791 -1031
  83. data/spec/lib/appsignal/transmitter_spec.rb +6 -8
  84. data/spec/lib/appsignal_spec.rb +294 -643
  85. data/spec/spec_helper.rb +1 -3
  86. data/spec/support/fixtures/projects/valid/config/appsignal.yml +4 -7
  87. data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +16 -0
  88. data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +56 -0
  89. data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +5 -0
  90. data/spec/support/helpers/api_request_helper.rb +3 -2
  91. data/spec/support/helpers/config_helpers.rb +41 -11
  92. data/spec/support/helpers/dependency_helper.rb +8 -0
  93. data/spec/support/helpers/log_helpers.rb +1 -0
  94. data/spec/support/helpers/rails_helper.rb +6 -6
  95. data/spec/support/helpers/transaction_helpers.rb +2 -24
  96. data/spec/support/matchers/transaction.rb +3 -3
  97. data/spec/support/mocks/appsignal_mock.rb +3 -3
  98. data/spec/support/mocks/mock_probe.rb +2 -0
  99. data/spec/support/testing.rb +2 -2
  100. metadata +12 -22
  101. data/gemfiles/que_beta.gemfile +0 -5
  102. data/lib/appsignal/helpers/heartbeat.rb +0 -20
  103. data/lib/appsignal/integrations/grape.rb +0 -35
  104. data/lib/appsignal/integrations/hanami.rb +0 -13
  105. data/lib/appsignal/integrations/padrino.rb +0 -13
  106. data/lib/appsignal/integrations/sinatra.rb +0 -13
  107. data/lib/appsignal/rack/generic_instrumentation.rb +0 -22
  108. data/lib/appsignal/rack/streaming_listener.rb +0 -28
  109. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -36
  110. data/spec/lib/appsignal/integrations/hanami_spec.rb +0 -17
  111. data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -15
  112. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -15
  113. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -81
  114. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +0 -69
  115. data/spec/support/fixtures/projects/valid/config/environments/development.rb +0 -0
  116. data/spec/support/fixtures/projects/valid/config/environments/production.rb +0 -0
  117. data/spec/support/fixtures/projects/valid/config/environments/test.rb +0 -0
  118. data/spec/support/rails/my_app.rb +0 -6
  119. /data/spec/support/fixtures/projects/{valid/config/application.rb → valid_with_rails_app/log/.gitkeep} +0 -0
@@ -14,22 +14,6 @@ module Appsignal
14
14
  .warn("Gauge value #{value} for key '#{key}' is too big")
15
15
  end
16
16
 
17
- def set_host_gauge(_key, _value)
18
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
19
- "The `set_host_gauge` method has been deprecated. " \
20
- "Calling this method has no effect. " \
21
- "Please remove method call in the following file to remove " \
22
- "this message.\n#{caller.first}"
23
- end
24
-
25
- def set_process_gauge(_key, _value)
26
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
27
- "The `set_process_gauge` method has been deprecated. " \
28
- "Calling this method has no effect. " \
29
- "Please remove method call in the following file to remove " \
30
- "this message.\n#{caller.first}"
31
- end
32
-
33
17
  def increment_counter(key, value = 1.0, tags = {})
34
18
  Appsignal::Extension.increment_counter(
35
19
  key.to_s,
@@ -50,10 +50,10 @@ module Appsignal
50
50
  transaction.set_action_if_nil("#{channel.class}#subscribed")
51
51
  transaction.set_metadata("path", request.path)
52
52
  transaction.set_metadata("method", "websocket")
53
- transaction.set_params_if_nil { request.params }
54
- transaction.set_headers_if_nil { request.env }
55
- transaction.set_session_data { request.session if request.respond_to? :session }
56
- transaction.set_tags(:request_id => request_id) if request_id
53
+ transaction.add_params_if_nil { request.params }
54
+ transaction.add_headers_if_nil { request.env }
55
+ transaction.add_session_data { request.session if request.respond_to? :session }
56
+ transaction.add_tags(:request_id => request_id) if request_id
57
57
  Appsignal::Transaction.complete_current!
58
58
  end
59
59
  end
@@ -86,10 +86,10 @@ module Appsignal
86
86
  transaction.set_action_if_nil("#{channel.class}#unsubscribed")
87
87
  transaction.set_metadata("path", request.path)
88
88
  transaction.set_metadata("method", "websocket")
89
- transaction.set_params_if_nil { request.params }
90
- transaction.set_headers_if_nil { request.env }
91
- transaction.set_session_data { request.session if request.respond_to? :session }
92
- transaction.set_tags(:request_id => request_id) if request_id
89
+ transaction.add_params_if_nil { request.params }
90
+ transaction.add_headers_if_nil { request.env }
91
+ transaction.add_session_data { request.session if request.respond_to? :session }
92
+ transaction.add_tags(:request_id => request_id) if request_id
93
93
  Appsignal::Transaction.complete_current!
94
94
  end
95
95
  end
@@ -58,10 +58,10 @@ module Appsignal
58
58
  end
59
59
 
60
60
  if transaction
61
- transaction.set_params_if_nil(job["arguments"])
61
+ transaction.add_params_if_nil(job["arguments"])
62
62
 
63
63
  transaction_tags = ActiveJobHelpers.transaction_tags_for(job)
64
- transaction.set_tags(transaction_tags)
64
+ transaction.add_tags(transaction_tags)
65
65
 
66
66
  transaction.set_action(ActiveJobHelpers.action_name(job))
67
67
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ class Hooks
5
+ # @api private
6
+ class AtExit < Appsignal::Hooks::Hook
7
+ register :at_exit
8
+
9
+ def dependencies_present?
10
+ true
11
+ end
12
+
13
+ def install
14
+ return unless Appsignal.config[:enable_at_exit_reporter]
15
+
16
+ Kernel.at_exit(&AtExitCallback.method(:call))
17
+ end
18
+
19
+ # Report any unhandled errors and will crash the Ruby process.
20
+ #
21
+ # If this error was previously reported by any of our instrumentation,
22
+ # the error will not also be reported here. This way we don't report an
23
+ # error from a Rake task or instrumented script twice.
24
+ class AtExitCallback
25
+ def self.call
26
+ error = $! # rubocop:disable Style/SpecialGlobalVars
27
+ return if Appsignal::Transaction.last_errors.include?(error)
28
+
29
+ Appsignal.report_error(error) do |transaction|
30
+ transaction.set_namespace("unhandled")
31
+ end
32
+ Appsignal.stop("at_exit")
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -69,25 +69,10 @@ module Appsignal
69
69
  text.size > 200 ? "#{text[0...197]}..." : text
70
70
  end
71
71
  end
72
-
73
- # Alias integration constants that have moved to their own module.
74
- def self.const_missing(name)
75
- case name
76
- when :SidekiqPlugin
77
- require "appsignal/integrations/sidekiq"
78
- callers = caller
79
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
80
- "The constant Appsignal::Hooks::SidekiqPlugin has been deprecated. " \
81
- "Please update the constant name to Appsignal::Integrations::SidekiqMiddleware " \
82
- "in the following file to remove this message.\n#{callers.first}"
83
- Appsignal::Integrations::SidekiqMiddleware
84
- else
85
- super
86
- end
87
- end
88
72
  end
89
73
  end
90
74
 
75
+ require "appsignal/hooks/at_exit"
91
76
  require "appsignal/hooks/action_cable"
92
77
  require "appsignal/hooks/action_mailer"
93
78
  require "appsignal/hooks/active_job"
@@ -19,11 +19,11 @@ module Appsignal
19
19
  transaction.set_error(exception)
20
20
  raise exception
21
21
  ensure
22
- transaction.set_params_if_nil(args.first)
23
22
  transaction.set_action_if_nil("#{self.class}##{args.first["action"]}")
23
+ transaction.add_params_if_nil(args.first)
24
24
  transaction.set_metadata("path", request.path)
25
25
  transaction.set_metadata("method", "websocket")
26
- transaction.set_tags(:request_id => request_id) if request_id
26
+ transaction.add_tags(:request_id => request_id) if request_id
27
27
  Appsignal::Transaction.complete_current!
28
28
  end
29
29
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Capistrano 3 integration
3
4
  namespace :appsignal do
4
5
  task :deploy do
5
6
  appsignal_env = fetch(:appsignal_env,
@@ -10,12 +11,9 @@ namespace :appsignal do
10
11
  appsignal_config = Appsignal::Config.new(
11
12
  Dir.pwd,
12
13
  appsignal_env,
13
- {},
14
14
  Logger.new(StringIO.new)
15
15
  ).tap do |c|
16
- fetch(:appsignal_config, {}).each do |key, value|
17
- c[key] = value
18
- end
16
+ c.merge_dsl_options(fetch(:appsignal_config, {}))
19
17
  c.validate
20
18
  end
21
19
 
@@ -19,12 +19,9 @@ module Appsignal
19
19
  appsignal_config = Appsignal::Config.new(
20
20
  ENV.fetch("PWD", nil),
21
21
  env,
22
- {},
23
22
  Appsignal::Utils::IntegrationLogger.new(StringIO.new)
24
23
  ).tap do |c|
25
- fetch(:appsignal_config, {}).each do |key, value|
26
- c[key] = value
27
- end
24
+ c.merge_dsl_options(fetch(:appsignal_config, {}))
28
25
  c.validate
29
26
  end
30
27
 
@@ -32,14 +32,14 @@ module Appsignal
32
32
  # ActiveJob
33
33
  job_data = payload.job_data
34
34
  transaction.set_action_if_nil("#{job_data["job_class"]}#perform")
35
- transaction.set_params_if_nil(job_data.fetch("arguments", {}))
35
+ transaction.add_params_if_nil(job_data.fetch("arguments", {}))
36
36
  else
37
37
  # Delayed Job
38
38
  transaction.set_action_if_nil(action_name_from_payload(payload, job.name))
39
- transaction.set_params_if_nil(extract_value(payload, :args, {}))
39
+ transaction.add_params_if_nil(extract_value(payload, :args, {}))
40
40
  end
41
41
 
42
- transaction.set_tags(
42
+ transaction.add_tags(
43
43
  :id => extract_value(job, :id, nil, true),
44
44
  :queue => extract_value(job, :queue),
45
45
  :priority => extract_value(job, :priority, 0),
@@ -16,8 +16,8 @@ module Appsignal
16
16
  ensure
17
17
  local_attrs = respond_to?(:que_attrs) ? que_attrs : attrs
18
18
  transaction.set_action_if_nil("#{local_attrs[:job_class]}#run")
19
- transaction.set_params_if_nil(local_attrs[:args])
20
- transaction.set_tags(
19
+ transaction.add_params_if_nil(local_attrs[:args])
20
+ transaction.add_tags(
21
21
  "id" => local_attrs[:job_id] || local_attrs[:id],
22
22
  "queue" => local_attrs[:queue],
23
23
  "run_at" => local_attrs[:run_at].to_s,
@@ -27,6 +27,7 @@ module Appsignal
27
27
  end
28
28
 
29
29
  def self.on_load(app)
30
+ load_default_config
30
31
  Appsignal::Integrations::Railtie.add_instrumentation_middleware(app)
31
32
 
32
33
  return unless app.config.appsignal.start_at == :on_load
@@ -38,17 +39,19 @@ module Appsignal
38
39
  Appsignal::Integrations::Railtie.start if app.config.appsignal.start_at == :after_initialize
39
40
  end
40
41
 
42
+ def self.load_default_config
43
+ Appsignal::Config.add_loader_defaults(
44
+ :rails,
45
+ :root_path => Rails.root,
46
+ :env => Rails.env,
47
+ :name => Appsignal::Utils::RailsHelper.detected_rails_app_name,
48
+ :log_path => Rails.root.join("log")
49
+ )
50
+ end
51
+
41
52
  def self.start
42
- unless Appsignal.config
43
- Appsignal._config = Appsignal::Config.new(
44
- Rails.root,
45
- Rails.env,
46
- :name => Appsignal::Utils::RailsHelper.detected_rails_app_name,
47
- :log_path => Rails.root.join("log")
48
- )
49
- end
50
53
  Appsignal.start
51
- initialize_error_reporter
54
+ initialize_error_reporter if Appsignal.started?
52
55
  end
53
56
 
54
57
  def self.add_instrumentation_middleware(app)
@@ -71,31 +74,27 @@ module Appsignal
71
74
  end
72
75
  end
73
76
 
74
- # Report errors reported by the Rails error reporter.
77
+ # Report errors reported by the Rails error reporter using {Appsignal.report_error}.
75
78
  #
76
- # We only report that are not reraised by the error reporter, using
77
- # `Rails.error.handle`.
78
79
  # @api private
79
80
  class RailsErrorReporterSubscriber
80
81
  class << self
81
- def report(error, handled:, severity:, context: {}, source: nil)
82
- # Ignore not handled errors. They are reraised by the error reporter
83
- # and are caught and recorded by our Rails middleware.
84
- return unless handled
85
-
86
- Appsignal.send_error(error) do |transaction|
87
- namespace, action_name, path, method, params, tags, custom_data =
88
- context_for(context.dup)
89
- transaction.set_namespace(namespace) if namespace
82
+ def report(error, handled:, severity:, context: {}, source: nil) # rubocop:disable Lint/UnusedMethodArgument
83
+ is_rails_runner = source == "application.runner.railties"
84
+ namespace, action_name, tags, custom_data = context_for(context.dup)
85
+
86
+ Appsignal.report_error(error) do |transaction|
87
+ if namespace
88
+ transaction.set_namespace(namespace)
89
+ elsif is_rails_runner
90
+ transaction.set_namespace("runner")
91
+ end
90
92
  transaction.set_action(action_name) if action_name
91
- transaction.set_metadata("path", path)
92
- transaction.set_metadata("method", method)
93
- transaction.set_params_if_nil(params)
94
- transaction.set_custom_data(custom_data) if custom_data
93
+ transaction.add_custom_data(custom_data) if custom_data
95
94
 
96
95
  tags[:severity] = severity
97
96
  tags[:source] = source.to_s if source
98
- transaction.set_tags(tags)
97
+ transaction.add_tags(tags)
99
98
  end
100
99
  end
101
100
 
@@ -103,40 +102,8 @@ module Appsignal
103
102
 
104
103
  def context_for(context)
105
104
  tags = {}
106
- custom_data = nil
107
105
 
108
106
  appsignal_context = context.delete(:appsignal)
109
- # Fetch the namespace and action name based on the Rails execution
110
- # context.
111
- controller = context.delete(:controller)
112
- path = nil
113
- method = nil
114
- params = nil
115
- if controller
116
- namespace = Appsignal::Transaction::HTTP_REQUEST
117
- action_name = "#{controller.class.name}##{controller.action_name}"
118
- unless controller.request.nil?
119
- path = controller.request.path
120
- method = controller.request.method
121
- params = controller.request.filtered_parameters
122
- end
123
- end
124
- # ActiveJob transaction naming relies on the current AppSignal
125
- # transaction namespace and action name copying done after this.
126
- context.delete(:job)
127
-
128
- # Copy the transaction action name, namespace and other data from
129
- # the currently active transaction, if not already set.
130
- if Appsignal::Transaction.current?
131
- current_transaction = Appsignal::Transaction.current
132
- namespace = current_transaction.namespace
133
-
134
- transaction_action = current_transaction.action
135
- action_name = current_transaction.action if transaction_action
136
-
137
- current_tags = current_transaction.tags
138
- tags.merge!(current_tags) if current_tags
139
- end
140
107
 
141
108
  # Use the user override set in the context
142
109
  if appsignal_context
@@ -151,7 +118,7 @@ module Appsignal
151
118
  end
152
119
  tags.merge!(context)
153
120
 
154
- [namespace, action_name, path, method, params, tags, custom_data]
121
+ [namespace, action_name, tags, custom_data]
155
122
  end
156
123
  end
157
124
  end
@@ -24,8 +24,8 @@ module Appsignal
24
24
  # Format given arguments and cast to hash if possible
25
25
  params, _ = args
26
26
  params = params.to_hash if params.respond_to?(:to_hash)
27
- transaction.set_params_if_nil(params)
28
27
  transaction.set_action(name)
28
+ transaction.add_params_if_nil(params)
29
29
  transaction.complete
30
30
  end
31
31
  end
@@ -33,7 +33,7 @@ module Appsignal
33
33
  private
34
34
 
35
35
  def _appsignal_create_transaction
36
- Appsignal::Transaction.create(Appsignal::Transaction::BACKGROUND_JOB)
36
+ Appsignal::Transaction.create("rake")
37
37
  end
38
38
  end
39
39
 
@@ -21,8 +21,8 @@ module Appsignal
21
21
  ResqueHelpers.arguments(payload),
22
22
  Appsignal.config[:filter_parameters]
23
23
  )
24
- transaction.set_params_if_nil(args)
25
- transaction.set_tags("queue" => queue)
24
+ transaction.add_params_if_nil(args)
25
+ transaction.add_tags("queue" => queue)
26
26
 
27
27
  Appsignal::Transaction.complete_current!
28
28
  end
@@ -15,10 +15,10 @@ module Appsignal
15
15
  batch = sqs_msg.is_a?(Array)
16
16
  attributes = fetch_attributes(batch, sqs_msg)
17
17
  transaction.set_action_if_nil("#{worker_instance.class.name}#perform")
18
- transaction.set_params_if_nil { fetch_args(batch, sqs_msg, body) }
19
- transaction.set_tags(attributes)
20
- transaction.set_tags("queue" => queue)
21
- transaction.set_tags("batch" => true) if batch
18
+ transaction.add_params_if_nil { fetch_args(batch, sqs_msg, body) }
19
+ transaction.add_tags(attributes)
20
+ transaction.add_tags("queue" => queue)
21
+ transaction.add_tags("batch" => true) if batch
22
22
 
23
23
  if attributes.key?("SentTimestamp")
24
24
  transaction.set_queue_start(Time.at(attributes["SentTimestamp"].to_i).to_i)
@@ -41,7 +41,7 @@ module Appsignal
41
41
  transaction = Appsignal::Transaction.create(Appsignal::Transaction::BACKGROUND_JOB)
42
42
  transaction.set_action_if_nil("SidekiqInternal")
43
43
  transaction.set_metadata("sidekiq_error", sidekiq_context[:context])
44
- transaction.set_params_if_nil(:jobstr => sidekiq_context[:jobstr])
44
+ transaction.add_params_if_nil(:jobstr => sidekiq_context[:jobstr])
45
45
  transaction.set_error(exception)
46
46
  end
47
47
 
@@ -73,10 +73,10 @@ module Appsignal
73
73
  raise exception
74
74
  ensure
75
75
  if transaction
76
- transaction.set_params_if_nil { parse_arguments(item) }
76
+ transaction.add_params_if_nil { parse_arguments(item) }
77
77
  queue_start = (item["enqueued_at"].to_f * 1000.0).to_i # Convert seconds to milliseconds
78
78
  transaction.set_queue_start(queue_start)
79
- transaction.set_tags(:request_id => item["jid"])
79
+ transaction.add_tags(:request_id => item["jid"])
80
80
  Appsignal::Transaction.complete_current! unless exception
81
81
 
82
82
  queue = item["queue"] || "unknown"
@@ -12,14 +12,14 @@ module Appsignal
12
12
  else
13
13
  Appsignal::Transaction.create(Appsignal::Transaction::HTTP_REQUEST)
14
14
  end
15
+ transaction.add_params_if_nil { request.query }
16
+ transaction.add_headers_if_nil { request.headers if request.respond_to?(:headers) }
15
17
 
16
18
  Appsignal.instrument("process_action.webmachine") do
17
19
  super
18
20
  end
19
21
  ensure
20
22
  transaction.set_action_if_nil("#{resource.class.name}##{request.method}")
21
- transaction.set_params_if_nil(request.query)
22
- transaction.set_headers_if_nil { request.headers if request.respond_to?(:headers) }
23
23
 
24
24
  Appsignal::Transaction.complete_current! unless has_parent_transaction
25
25
  end
@@ -85,7 +85,7 @@ module Appsignal
85
85
  end
86
86
 
87
87
  def register_config_defaults(options)
88
- Appsignal::Config.add_loader_defaults(self.class.loader_name, options)
88
+ Appsignal::Config.add_loader_defaults(self.class.loader_name, **options)
89
89
  end
90
90
  end
91
91
  end
@@ -29,15 +29,6 @@ module Appsignal
29
29
  probes[key]
30
30
  end
31
31
 
32
- # @deprecated Use {Appsignal::Probes.register} instead.
33
- def register(name, probe)
34
- Appsignal::Utils::StdoutAndLoggerMessage.warning(
35
- "The method 'Appsignal::Probes.probes.register' is deprecated. " \
36
- "Use 'Appsignal::Probes.register' instead."
37
- )
38
- Appsignal::Probes.register(name, probe)
39
- end
40
-
41
32
  # @api private
42
33
  def internal_register(name, probe)
43
34
  if probes.key?(name)
@@ -136,21 +136,19 @@ module Appsignal
136
136
  # Override this method to set metadata after the app is called.
137
137
  # Call `super` to also include the default set metadata.
138
138
  def add_transaction_metadata_after(transaction, request)
139
- default_action =
140
- appsignal_route_env_value(request) || appsignal_action_env_value(request)
141
- transaction.set_action_if_nil(default_action)
142
139
  transaction.set_metadata("path", request.path)
143
140
 
144
141
  request_method = request_method_for(request)
145
142
  transaction.set_metadata("method", request_method) if request_method
146
143
 
147
- transaction.set_params_if_nil { params_for(request) }
148
- transaction.set_session_data_if_nil do
144
+ transaction.add_params { params_for(request) }
145
+ transaction.add_session_data do
149
146
  request.session if request.respond_to?(:session)
150
147
  end
151
- transaction.set_headers_if_nil do
148
+ transaction.add_headers do
152
149
  request.env if request.respond_to?(:env)
153
150
  end
151
+
154
152
  queue_start = Appsignal::Rack::Utils.queue_start_from(request.env)
155
153
  transaction.set_queue_start(queue_start) if queue_start
156
154
  end
@@ -179,26 +177,6 @@ module Appsignal
179
177
  def request_for(env)
180
178
  @request_class.new(env)
181
179
  end
182
-
183
- def appsignal_route_env_value(request)
184
- request.env["appsignal.route"].tap do |value|
185
- next unless value
186
-
187
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
188
- "Setting the action name with the request env 'appsignal.route' is deprecated. " \
189
- "Please use `Appsignal.set_action` instead. "
190
- end
191
- end
192
-
193
- def appsignal_action_env_value(request)
194
- request.env["appsignal.action"].tap do |value|
195
- next unless value
196
-
197
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
198
- "Setting the action name with the request env 'appsignal.action' is deprecated. " \
199
- "Please use `Appsignal.set_action` instead. "
200
- end
201
- end
202
180
  end
203
181
  end
204
182
  end
@@ -110,9 +110,9 @@ module Appsignal
110
110
 
111
111
  self.class.safe_execution("Appsignal::Rack::EventHandler#on_finish") do
112
112
  transaction.finish_event("process_request.rack", "", "")
113
- transaction.set_params_if_nil { request.params }
114
- transaction.set_headers_if_nil { request.env }
115
- transaction.set_session_data_if_nil do
113
+ transaction.add_params_if_nil { request.params }
114
+ transaction.add_headers_if_nil { request.env }
115
+ transaction.add_session_data_if_nil do
116
116
  request.session if request.respond_to?(:session)
117
117
  end
118
118
  queue_start = Appsignal::Rack::Utils.queue_start_from(request.env)
@@ -124,7 +124,7 @@ module Appsignal
124
124
  500
125
125
  end
126
126
  if response_status
127
- transaction.set_tags(:response_status => response_status)
127
+ transaction.add_tags(:response_status => response_status)
128
128
  Appsignal.increment_counter(
129
129
  :response_status,
130
130
  1,
@@ -19,7 +19,7 @@ module Appsignal
19
19
  transaction.set_action_if_nil("#{controller.class}##{controller.action_name}") if controller
20
20
 
21
21
  request_id = request.env["action_dispatch.request_id"]
22
- transaction.set_tags(:request_id => request_id) if request_id
22
+ transaction.add_tags(:request_id => request_id) if request_id
23
23
 
24
24
  super
25
25
  end
@@ -37,30 +37,5 @@ module Appsignal
37
37
  end
38
38
  end
39
39
  end
40
-
41
- # Alias constants that have moved with a warning message that points to the
42
- # place to update the reference.
43
- def self.const_missing(name)
44
- case name
45
- when :GenericInstrumentation
46
- require "appsignal/rack/generic_instrumentation"
47
-
48
- callers = caller
49
- Appsignal::Utils::StdoutAndLoggerMessage.warning \
50
- "The constant Appsignal::Rack::GenericInstrumentation has been deprecated. " \
51
- "Please use the new Appsignal::Rack::InstrumentationMiddleware middleware. " \
52
- "This new middleware does not default the action name to 'unknown'. " \
53
- "Set the action name for the endpoint using the Appsignal.set_action helper. " \
54
- "Read our Rack docs for more information " \
55
- "https://docs.appsignal.com/ruby/integrations/rack.html " \
56
- "Update the constant name to " \
57
- "Appsignal::Rack::InstrumentationMiddleware in the following file to " \
58
- "remove this message.\n#{callers.first}"
59
- # Return the alias so it can't ever get stuck in a recursive loop
60
- Appsignal::Rack::GenericInstrumentationAlias
61
- else
62
- super
63
- end
64
- end
65
40
  end
66
41
  end