appsignal 4.5.7 → 4.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb6b257bdb500ffff85f0aaf2c4a63c85ef1d454df501973b99c3871869564fd
4
- data.tar.gz: 9f62ae7ee6fd67935b079ece3d8c5ef827396b654b675754bcaa9a323ca8141e
3
+ metadata.gz: f023b8343540c92b7c106f7c9853d7ec08c64f0138fa1904be7b606aadf6691b
4
+ data.tar.gz: eb18c6e7c352ab0e5e44f739190df8a2c671212b97133311070633944597b63f
5
5
  SHA512:
6
- metadata.gz: 2a58b34251fd0eef84bf5cfb0f275f4e974d3e48eccdfb10426acda5ec6ba39c6f33377b3f77bdfb7c0772f2bdc510ce0a2f5e829649c67b203f105ae1360c41
7
- data.tar.gz: d96563953abcb4614df3325b486ba23b6e25458d1649661a977e45ea06e24bec7bfa79f21295ed901d466313b3d8753f1d91d3585f20c166388b6006cef000cf
6
+ metadata.gz: 678d39b904447512f7222a7c3f82bd251d507e745d9b1402f7c3a3784fabd691f1a1538421ff4dd7fb158cdc74d02e925cbea10eff59581c2d661d3d1ad9c03a
7
+ data.tar.gz: 18efa45cf4d42fd8faacaf5cec5ec93e76d41773d83e9e077a6d4528aeb5019a05ce41b35b1e88e3449ccd8635ce27045c8cca49d46077327d6490e3e6dc31d4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 4.5.8
4
+
5
+ _Published on 2025-04-04._
6
+
7
+ ### Added
8
+
9
+ - Add the `enable_at_exit_hook` option to configure if `Appsignal.stop` is called when the Ruby application exits. Calling `Appsignal.stop` will stop the application for a moment to flush all the data to our agent before shutting down.
10
+
11
+ This option has three possible values:
12
+
13
+ - `always`: Always call `Appsignal.stop` when the program exits. On (Docker) containers it's automatically set to this value.
14
+ - `never`: Never call `Appsignal.stop` when the program exits. The default value when the program doesn't run on a (Docker) container.
15
+ - `on_error`: Call `Appsignal.stop` when the program exits with an error.
16
+
17
+ (patch [d0a5875c](https://github.com/appsignal/appsignal-ruby/commit/d0a5875cef5101680f1cab4649d71440212f9ea8), [043a6c74](https://github.com/appsignal/appsignal-ruby/commit/043a6c740b708e1182ed7161e3c9ad38bd3314de), [b680fe6f](https://github.com/appsignal/appsignal-ruby/commit/b680fe6f6b283205a13ca61bd4a26167f541dbca))
18
+
19
+ ### Deprecated
20
+
21
+ - Deprecate the `Appsignal.monitor_and_stop` helper.
22
+
23
+ We instead recommend using the `Appsignal.monitor` helper and configuring the `enable_at_exit_hook` config option to `always`.
24
+
25
+ (patch [84969aea](https://github.com/appsignal/appsignal-ruby/commit/84969aeaca8f3737921e9adf1efdad55b52e1206))
26
+
3
27
  ## 4.5.7
4
28
 
5
29
  _Published on 2025-03-20._
@@ -93,6 +93,7 @@ module Appsignal
93
93
  :ca_file_path => File.expand_path(File.join("../../../resources/cacert.pem"), __FILE__),
94
94
  :dns_servers => [],
95
95
  :enable_allocation_tracking => true,
96
+ :enable_at_exit_hook => "on_error",
96
97
  :enable_at_exit_reporter => true,
97
98
  :enable_host_metrics => true,
98
99
  :enable_minutely_probes => true,
@@ -153,6 +154,7 @@ module Appsignal
153
154
  :name => "APPSIGNAL_APP_NAME",
154
155
  :bind_address => "APPSIGNAL_BIND_ADDRESS",
155
156
  :ca_file_path => "APPSIGNAL_CA_FILE_PATH",
157
+ :enable_at_exit_hook => "APPSIGNAL_ENABLE_AT_EXIT_HOOK",
156
158
  :hostname => "APPSIGNAL_HOSTNAME",
157
159
  :host_role => "APPSIGNAL_HOST_ROLE",
158
160
  :http_proxy => "APPSIGNAL_HTTP_PROXY",
@@ -507,6 +509,8 @@ module Appsignal
507
509
  # environment variable is present and not empty.
508
510
  env_push_api_key = ENV["APPSIGNAL_PUSH_API_KEY"] || ""
509
511
  hash[:active] = true unless env_push_api_key.strip.empty?
512
+
513
+ hash[:enable_at_exit_hook] = "always" if Appsignal::Extension.running_in_container?
510
514
  end
511
515
  end
512
516
 
@@ -154,6 +154,11 @@ module Appsignal
154
154
  #
155
155
  # @see monitor
156
156
  def monitor_and_stop(action:, namespace: nil, &block)
157
+ Appsignal::Utils::StdoutAndLoggerMessage.warning \
158
+ "The `Appsignal.monitor_and_stop` helper is deprecated. " \
159
+ "Use the `Appsignal.monitor` along with our `enable_at_exit_hook` " \
160
+ "option instead."
161
+
157
162
  monitor(:namespace => namespace, :action => action, &block)
158
163
  ensure
159
164
  Appsignal.stop("monitor_and_stop")
@@ -11,27 +11,41 @@ module Appsignal
11
11
  end
12
12
 
13
13
  def install
14
- return unless Appsignal.config[:enable_at_exit_reporter]
15
-
16
14
  Kernel.at_exit(&AtExitCallback.method(:call))
17
15
  end
18
16
 
19
- # Report any unhandled errors and will crash the Ruby process.
17
+ # Stop AppSignal before the app exists.
18
+ #
19
+ # This is the default behavior and can be customized with the
20
+ # `enable_at_exit_hook` option.
21
+ #
22
+ # When the `enable_at_exit_reporter` option is set to `true` (the
23
+ # default), it will report any unhandled errors that will crash the Ruby
24
+ # process.
20
25
  #
21
26
  # If this error was previously reported by any of our instrumentation,
22
27
  # the error will not also be reported here. This way we don't report an
23
28
  # error from a Rake task or instrumented script twice.
24
29
  class AtExitCallback
25
30
  def self.call
31
+ report_error = false
32
+ return unless Appsignal.config&.[](:enable_at_exit_reporter)
33
+
26
34
  error = $! # rubocop:disable Style/SpecialGlobalVars
27
35
  return unless error
28
36
  return if ignored_error?(error)
29
37
  return if Appsignal::Transaction.last_errors.include?(error)
30
38
 
39
+ report_error = true
40
+
31
41
  Appsignal.report_error(error) do |transaction|
32
42
  transaction.set_namespace("unhandled")
33
43
  end
34
- Appsignal.stop("at_exit")
44
+ ensure
45
+ at_exit_hook = Appsignal.config&.[](:enable_at_exit_hook)
46
+ if at_exit_hook == "always" || (at_exit_hook == "on_error" && report_error)
47
+ Appsignal.stop("at_exit")
48
+ end
35
49
  end
36
50
 
37
51
  IGNORED_ERRORS = [
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "4.5.7"
4
+ VERSION = "4.5.8"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.7
4
+ version: 4.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-03-20 00:00:00.000000000 Z
13
+ date: 2025-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: logger