appsignal 2.11.8-java → 3.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/.rubocop_todo.yml +1 -1
  4. data/.semaphore/semaphore.yml +88 -111
  5. data/CHANGELOG.md +24 -0
  6. data/appsignal.gemspec +1 -1
  7. data/build_matrix.yml +11 -15
  8. data/lib/appsignal.rb +2 -29
  9. data/lib/appsignal/auth_check.rb +2 -8
  10. data/lib/appsignal/cli.rb +1 -23
  11. data/lib/appsignal/config.rb +1 -25
  12. data/lib/appsignal/event_formatter.rb +0 -25
  13. data/lib/appsignal/helpers/instrumentation.rb +69 -5
  14. data/lib/appsignal/hooks.rb +6 -13
  15. data/lib/appsignal/hooks/action_cable.rb +3 -34
  16. data/lib/appsignal/hooks/active_support_notifications.rb +7 -86
  17. data/lib/appsignal/hooks/celluloid.rb +5 -9
  18. data/lib/appsignal/hooks/net_http.rb +2 -12
  19. data/lib/appsignal/hooks/puma.rb +3 -5
  20. data/lib/appsignal/hooks/que.rb +1 -1
  21. data/lib/appsignal/hooks/rake.rb +2 -24
  22. data/lib/appsignal/hooks/redis.rb +2 -13
  23. data/lib/appsignal/hooks/resque.rb +2 -43
  24. data/lib/appsignal/hooks/sidekiq.rb +6 -143
  25. data/lib/appsignal/hooks/unicorn.rb +3 -24
  26. data/lib/appsignal/hooks/webmachine.rb +1 -7
  27. data/lib/appsignal/integrations/action_cable.rb +34 -0
  28. data/lib/appsignal/integrations/active_support_notifications.rb +77 -0
  29. data/lib/appsignal/integrations/net_http.rb +16 -0
  30. data/lib/appsignal/integrations/object.rb +39 -4
  31. data/lib/appsignal/integrations/padrino.rb +5 -7
  32. data/lib/appsignal/integrations/que.rb +26 -33
  33. data/lib/appsignal/integrations/railtie.rb +1 -4
  34. data/lib/appsignal/integrations/rake.rb +26 -2
  35. data/lib/appsignal/integrations/redis.rb +17 -0
  36. data/lib/appsignal/integrations/resque.rb +39 -10
  37. data/lib/appsignal/integrations/sidekiq.rb +171 -0
  38. data/lib/appsignal/integrations/unicorn.rb +28 -0
  39. data/lib/appsignal/integrations/webmachine.rb +22 -24
  40. data/lib/appsignal/minutely.rb +0 -12
  41. data/lib/appsignal/version.rb +1 -1
  42. data/spec/lib/appsignal/auth_check_spec.rb +1 -24
  43. data/spec/lib/appsignal/cli_spec.rb +1 -1
  44. data/spec/lib/appsignal/config_spec.rb +2 -66
  45. data/spec/lib/appsignal/event_formatter_spec.rb +0 -37
  46. data/spec/lib/appsignal/hooks/celluloid_spec.rb +6 -1
  47. data/spec/lib/appsignal/hooks/rake_spec.rb +1 -2
  48. data/spec/lib/appsignal/hooks/redis_spec.rb +50 -15
  49. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +12 -464
  50. data/spec/lib/appsignal/hooks/unicorn_spec.rb +14 -3
  51. data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -13
  52. data/spec/lib/appsignal/hooks_spec.rb +6 -22
  53. data/spec/lib/appsignal/integrations/object_spec.rb +91 -8
  54. data/spec/lib/appsignal/integrations/padrino_spec.rb +2 -3
  55. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -45
  56. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +524 -0
  57. data/spec/lib/appsignal/integrations/webmachine_spec.rb +26 -8
  58. data/spec/lib/appsignal/minutely_spec.rb +0 -19
  59. data/spec/lib/appsignal/transaction_spec.rb +1 -14
  60. data/spec/lib/appsignal/transmitter_spec.rb +1 -1
  61. data/spec/lib/appsignal_spec.rb +162 -116
  62. data/spec/spec_helper.rb +1 -15
  63. metadata +11 -21
  64. data/lib/appsignal/cli/notify_of_deploy.rb +0 -131
  65. data/lib/appsignal/integrations/object_ruby_19.rb +0 -37
  66. data/lib/appsignal/integrations/object_ruby_modern.rb +0 -64
  67. data/lib/appsignal/integrations/resque_active_job.rb +0 -19
  68. data/lib/appsignal/js_exception_transaction.rb +0 -56
  69. data/lib/appsignal/rack/js_exception_catcher.rb +0 -80
  70. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +0 -180
  71. data/spec/lib/appsignal/integrations/object_19_spec.rb +0 -266
  72. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +0 -28
  73. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -28
  74. data/spec/lib/appsignal/js_exception_transaction_spec.rb +0 -128
  75. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +0 -170
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ # 3.0.1
4
+ - Fix error occurring on APPSIGNAL_DNS_SERVER environment variable option
5
+ parsing. PR #709
6
+
7
+ # 3.0.0
8
+
9
+ Please read our [upgrade from version 2 to 3 guide][upgrade3] before upgrading.
10
+
11
+ [upgrade3]: https://docs.appsignal.com/ruby/installation/upgrade-from-2-to-3.html
12
+
13
+ - Drop Ruby 1.9 support. PR #683, #682, #688, #694
14
+ - Require Ruby 2.0 or newer for gem. PR #701
15
+ - Use Module.prepend for all gem integrations. Fixes #603 in combination with
16
+ other gems that provide instrumentation for gems. PR #683
17
+ - Remove deprecated integrations, classes, methods and arguments. PR #685, #686
18
+ - Deprecate `set_error` and `send_error` error helpers `tags` and `namespace`
19
+ arguments. PR #702
20
+ - Add Sidekiq error handler. Report more Sidekiq errors that happen around job
21
+ execution. PR #699
22
+
23
+ # 2.11.9
24
+ - Fix and simplify Ruby method delegation for object method instrumentation in
25
+ the different Ruby versions. PR #706
26
+
3
27
  # 2.11.8
4
28
  - Mark minutely probe thread as fork-safe by @pixeltrix. PR #704
5
29
 
data/appsignal.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem| # rubocop:disable Metrics/BlockLength
21
21
  gem.name = "appsignal"
22
22
  gem.require_paths = %w[lib ext]
23
23
  gem.version = Appsignal::VERSION
24
- gem.required_ruby_version = ">= 1.9"
24
+ gem.required_ruby_version = ">= 2.0"
25
25
  # Default extension installer. Overridden by JRuby gemspec as defined in
26
26
  # `Rakefile`.
27
27
  gem.extensions = %w[ext/extconf.rb]
data/build_matrix.yml CHANGED
@@ -58,7 +58,7 @@ semaphore: # Default `.semaphore/semaphore.yml` contents
58
58
  - name: Validate CI setup
59
59
  env_vars:
60
60
  - name: RUBY_VERSION
61
- value: 2.6.5
61
+ value: 2.6.6
62
62
  - name: GEMSET
63
63
  value: no_dependencies
64
64
  - name: BUNDLE_GEMFILE
@@ -72,7 +72,7 @@ semaphore: # Default `.semaphore/semaphore.yml` contents
72
72
  - name: RuboCop
73
73
  env_vars:
74
74
  - name: RUBY_VERSION
75
- value: 2.6.5
75
+ value: 2.6.6
76
76
  - name: GEMSET
77
77
  value: no_dependencies
78
78
  - name: BUNDLE_GEMFILE
@@ -94,10 +94,6 @@ matrix:
94
94
  - "rails-6.0"
95
95
 
96
96
  ruby:
97
- - ruby: "1.9.3-p551"
98
- rubygems: "2.7.8"
99
- bundler: "1.17.3"
100
- gems: "none"
101
97
  - ruby: "2.0.0-p648"
102
98
  rubygems: "2.7.8"
103
99
  bundler: "1.17.3"
@@ -111,12 +107,12 @@ matrix:
111
107
  gems: "none"
112
108
  - ruby: "2.3.8"
113
109
  gems: "none"
114
- - ruby: "2.4.9"
110
+ - ruby: "2.4.10"
115
111
  gems: "none"
116
- - ruby: "2.5.7"
112
+ - ruby: "2.5.8"
117
113
  gems: "minimal"
118
- - ruby: "2.6.5"
119
- - ruby: "2.7.1"
114
+ - ruby: "2.6.6"
115
+ - ruby: "2.7.2"
120
116
  - ruby: "3.0.0"
121
117
  - ruby: "jruby-9.1.17.0"
122
118
  gems: "minimal"
@@ -138,15 +134,15 @@ matrix:
138
134
  bundler: "1.17.3"
139
135
  exclude:
140
136
  ruby:
141
- - "2.6.5"
142
- - "2.7.1"
137
+ - "2.6.6"
138
+ - "2.7.2"
143
139
  - "3.0.0"
144
140
  - gem: "rails-4.2"
145
141
  bundler: "1.17.3"
146
142
  exclude:
147
143
  ruby:
148
- - "2.6.5"
149
- - "2.7.1"
144
+ - "2.6.6"
145
+ - "2.7.2"
150
146
  - "3.0.0"
151
147
  - gem: "rails-5.0"
152
148
  exclude:
@@ -170,7 +166,7 @@ matrix:
170
166
  - "2.1.10"
171
167
  - "2.2.10"
172
168
  - "2.3.8"
173
- - "2.4.9"
169
+ - "2.4.10"
174
170
  - "jruby-9.1.17.0"
175
171
  - gem: "resque-1"
176
172
  bundler: "1.17.3"
data/lib/appsignal.rb CHANGED
@@ -4,9 +4,9 @@ require "json"
4
4
  require "securerandom"
5
5
 
6
6
  require "appsignal/logger"
7
+ require "appsignal/utils/deprecation_message"
7
8
  require "appsignal/helpers/instrumentation"
8
9
  require "appsignal/helpers/metrics"
9
- require "appsignal/utils/deprecation_message"
10
10
 
11
11
  # AppSignal for Ruby gem's main module.
12
12
  #
@@ -18,7 +18,6 @@ module Appsignal
18
18
  class << self
19
19
  include Helpers::Instrumentation
20
20
  include Helpers::Metrics
21
- include Utils::DeprecationMessage
22
21
 
23
22
  # Accessor for the AppSignal configuration.
24
23
  # Return the current AppSignal configuration.
@@ -129,7 +128,6 @@ module Appsignal
129
128
  config.write_to_environment
130
129
  Appsignal::Extension.start
131
130
  Appsignal::Hooks.load_hooks
132
- Appsignal::EventFormatter.initialize_deprecated_formatters
133
131
  initialize_extensions
134
132
 
135
133
  if config[:enable_allocation_tracking] && !Appsignal::System.jruby?
@@ -222,15 +220,9 @@ module Appsignal
222
220
  # Sets the log level and sets the logger. Uses a file-based logger or the
223
221
  # STDOUT-based logger. See the `:log` configuration option.
224
222
  #
225
- # @param path_arg [nil] Deprecated param. Use the `:log_path`
226
- # configuration option instead.
227
223
  # @return [void]
228
224
  # @since 0.7.0
229
- def start_logger(path_arg = nil)
230
- if path_arg
231
- logger.info("Setting the path in start_logger has no effect anymore, set it in the config instead")
232
- end
233
-
225
+ def start_logger
234
226
  if config && config[:log] == "file" && config.log_file_path
235
227
  start_file_logger(config.log_file_path)
236
228
  else
@@ -285,21 +277,6 @@ module Appsignal
285
277
  config && config.active? && extension_loaded?
286
278
  end
287
279
 
288
- # @deprecated No replacement
289
- def is_ignored_error?(error) # rubocop:disable Naming/PredicateName
290
- deprecation_message "Appsignal.is_ignored_error? is deprecated " \
291
- "with no replacement and will be removed in version 3.0."
292
- Appsignal.config[:ignore_errors].include?(error.class.name)
293
- end
294
- alias :is_ignored_exception? :is_ignored_error?
295
-
296
- # @deprecated No replacement
297
- def is_ignored_action?(action) # rubocop:disable Naming/PredicateName
298
- deprecation_message "Appsignal.is_ignored_action? is deprecated " \
299
- "with no replacement and will be removed in version 3.0."
300
- Appsignal.config[:ignore_actions].include?(action)
301
- end
302
-
303
280
  private
304
281
 
305
282
  def start_stdout_logger
@@ -344,11 +321,7 @@ require "appsignal/marker"
344
321
  require "appsignal/minutely"
345
322
  require "appsignal/garbage_collection_profiler"
346
323
  require "appsignal/integrations/railtie" if defined?(::Rails)
347
- require "appsignal/integrations/resque"
348
- require "appsignal/integrations/resque_active_job"
349
324
  require "appsignal/transaction"
350
325
  require "appsignal/version"
351
326
  require "appsignal/rack/generic_instrumentation"
352
- require "appsignal/rack/js_exception_catcher"
353
- require "appsignal/js_exception_transaction"
354
327
  require "appsignal/transmitter"
@@ -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, :logger
23
+ attr_reader :config
24
24
 
25
- def initialize(config, logger = nil)
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 notify_of_deploy].freeze
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
@@ -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,
@@ -85,8 +81,6 @@ module Appsignal
85
81
  ENV_STRING_KEYS = %w[
86
82
  APPSIGNAL_APP_NAME
87
83
  APPSIGNAL_CA_FILE_PATH
88
- APPSIGNAL_DNS_SERVERS
89
- APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH
90
84
  APPSIGNAL_HOSTNAME
91
85
  APPSIGNAL_HTTP_PROXY
92
86
  APPSIGNAL_LOG
@@ -102,7 +96,6 @@ module Appsignal
102
96
  APPSIGNAL_ACTIVE
103
97
  APPSIGNAL_DEBUG
104
98
  APPSIGNAL_ENABLE_ALLOCATION_TRACKING
105
- APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING
106
99
  APPSIGNAL_ENABLE_GC_INSTRUMENTATION
107
100
  APPSIGNAL_ENABLE_HOST_METRICS
108
101
  APPSIGNAL_ENABLE_MINUTELY_PROBES
@@ -118,6 +111,7 @@ module Appsignal
118
111
  ].freeze
119
112
  # @api private
120
113
  ENV_ARRAY_KEYS = %w[
114
+ APPSIGNAL_DNS_SERVERS
121
115
  APPSIGNAL_FILTER_PARAMETERS
122
116
  APPSIGNAL_FILTER_SESSION_DATA
123
117
  APPSIGNAL_IGNORE_ACTIONS
@@ -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
@@ -3,6 +3,8 @@
3
3
  module Appsignal
4
4
  module Helpers
5
5
  module Instrumentation # rubocop:disable Metrics/ModuleLength
6
+ include Appsignal::Utils::DeprecationMessage
7
+
6
8
  # Creates an AppSignal transaction for the given block.
7
9
  #
8
10
  # If AppSignal is not {.active?} it will still execute the block, but not
@@ -139,7 +141,10 @@ module Appsignal
139
141
  )
140
142
  yield
141
143
  rescue Exception => error # rubocop:disable Lint/RescueException
142
- send_error(error, tags, namespace)
144
+ send_error(error) do |transaction|
145
+ transaction.set_tags(tags) if tags
146
+ transaction.set_namespace(namespace) if namespace
147
+ end
143
148
  raise error
144
149
  end
145
150
  alias :listen_for_exception :listen_for_error
@@ -164,7 +169,7 @@ module Appsignal
164
169
  # Appsignal.send_error(e)
165
170
  # end
166
171
  #
167
- # @example Send an exception with tags
172
+ # @example Send an exception with tags. Deprecated method.
168
173
  # begin
169
174
  # raise "oh no!"
170
175
  # rescue => e
@@ -172,17 +177,20 @@ module Appsignal
172
177
  # end
173
178
  #
174
179
  # @example Add more metadata to transaction
175
- # Appsignal.send_error(e, :key => "value") do |transaction|
180
+ # Appsignal.send_error(e) do |transaction|
176
181
  # transaction.params(:search_query => params[:search_query])
177
182
  # transaction.set_action("my_action_name")
183
+ # transaction.set_tags(:key => "value")
178
184
  # transaction.set_namespace("my_namespace")
179
185
  # end
180
186
  #
181
187
  # @param error [Exception] The error to send to AppSignal.
182
188
  # @param tags [Hash{String, Symbol => String, Symbol, Integer}]
183
189
  # Additional tags to add to the error. See also {.tag_request}.
190
+ # This parameter is deprecated. Use the block argument instead.
184
191
  # @param namespace [String] The namespace in which the error occurred.
185
192
  # See also {.set_namespace}.
193
+ # This parameter is deprecated. Use the block argument instead.
186
194
  # @yield [transaction] yields block to allow modification of the
187
195
  # transaction before it's send.
188
196
  # @yieldparam transaction [Transaction] yields the AppSignal transaction
@@ -197,9 +205,30 @@ module Appsignal
197
205
  def send_error(
198
206
  error,
199
207
  tags = nil,
200
- namespace = Appsignal::Transaction::HTTP_REQUEST
208
+ namespace = nil
201
209
  )
210
+ if tags
211
+ call_location = caller(1..1).first
212
+ deprecation_message \
213
+ "The tags argument for `Appsignal.send_error` is deprecated. " \
214
+ "Please use the block method to set tags instead.\n\n" \
215
+ " Appsignal.send_error(error) do |transaction|\n" \
216
+ " transaction.set_tags(#{tags})\n" \
217
+ " end\n\n" \
218
+ "Appsignal.send_error called on location: #{call_location}"
219
+ end
220
+ if namespace
221
+ call_location = caller(1..1).first
222
+ deprecation_message \
223
+ "The namespace argument for `Appsignal.send_error` is deprecated. " \
224
+ "Please use the block method to set the namespace instead.\n\n" \
225
+ " Appsignal.send_error(error) do |transaction|\n" \
226
+ " transaction.namespace(#{namespace.inspect})\n" \
227
+ " end\n\n" \
228
+ "Appsignal.send_error called on location: #{call_location}"
229
+ end
202
230
  return unless active?
231
+
203
232
  unless error.is_a?(Exception)
204
233
  logger.error "Appsignal.send_error: Cannot send error. The given " \
205
234
  "value is not an exception: #{error.inspect}"
@@ -207,7 +236,7 @@ module Appsignal
207
236
  end
208
237
  transaction = Appsignal::Transaction.new(
209
238
  SecureRandom.uuid,
210
- namespace,
239
+ namespace || Appsignal::Transaction::HTTP_REQUEST,
211
240
  Appsignal::Transaction::GenericRequest.new({})
212
241
  )
213
242
  transaction.set_tags(tags) if tags
@@ -244,12 +273,26 @@ module Appsignal
244
273
  # end
245
274
  # end
246
275
  #
276
+ # @example Add more metadata to transaction
277
+ # Appsignal.set_error(e) do |transaction|
278
+ # transaction.params(:search_query => params[:search_query])
279
+ # transaction.set_action("my_action_name")
280
+ # transaction.set_tags(:key => "value")
281
+ # transaction.set_namespace("my_namespace")
282
+ # end
283
+ #
247
284
  # @param exception [Exception] The error to add to the current
248
285
  # transaction.
249
286
  # @param tags [Hash{String, Symbol => String, Symbol, Integer}]
250
287
  # Additional tags to add to the error. See also {.tag_request}.
288
+ # This parameter is deprecated. Use the block argument instead.
251
289
  # @param namespace [String] The namespace in which the error occurred.
252
290
  # See also {.set_namespace}.
291
+ # This parameter is deprecated. Use the block argument instead.
292
+ # @yield [transaction] yields block to allow modification of the
293
+ # transaction.
294
+ # @yieldparam transaction [Transaction] yields the AppSignal transaction
295
+ # used to store the error.
253
296
  # @return [void]
254
297
  #
255
298
  # @see Transaction#set_error
@@ -257,6 +300,26 @@ module Appsignal
257
300
  # Exception handling guide
258
301
  # @since 0.6.6
259
302
  def set_error(exception, tags = nil, namespace = nil)
303
+ if tags
304
+ call_location = caller(1..1).first
305
+ deprecation_message \
306
+ "The tags argument for `Appsignal.set_error` is deprecated. " \
307
+ "Please use the block method to set tags instead.\n\n" \
308
+ " Appsignal.set_error(error) do |transaction|\n" \
309
+ " transaction.set_tags(#{tags})\n" \
310
+ " end\n\n" \
311
+ "Appsignal.set_error called on location: #{call_location}"
312
+ end
313
+ if namespace
314
+ call_location = caller(1..1).first
315
+ deprecation_message \
316
+ "The namespace argument for `Appsignal.set_error` is deprecated. " \
317
+ "Please use the block method to set the namespace instead.\n\n" \
318
+ " Appsignal.set_error(error) do |transaction|\n" \
319
+ " transaction.namespace(#{namespace.inspect})\n" \
320
+ " end\n\n" \
321
+ "Appsignal.set_error called on location: #{call_location}"
322
+ end
260
323
  unless exception.is_a?(Exception)
261
324
  logger.error "Appsignal.set_error: Cannot set error. The given " \
262
325
  "value is not an exception: #{exception.inspect}"
@@ -267,6 +330,7 @@ module Appsignal
267
330
  transaction.set_error(exception)
268
331
  transaction.set_tags(tags) if tags
269
332
  transaction.set_namespace(namespace) if namespace
333
+ yield transaction if block_given?
270
334
  end
271
335
  alias :set_exception :set_error
272
336
  alias :add_exception :set_error