appsignal 3.12.5 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +73 -0
- data/lib/appsignal/check_in/cron.rb +80 -0
- data/lib/appsignal/check_in.rb +46 -0
- data/lib/appsignal/cli/install.rb +75 -45
- data/lib/appsignal/config.rb +7 -3
- data/lib/appsignal/helpers/heartbeat.rb +20 -0
- data/lib/appsignal/helpers/instrumentation.rb +8 -0
- data/lib/appsignal/integrations/http.rb +2 -7
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +20 -6
- data/spec/lib/appsignal/check_in_spec.rb +342 -0
- data/spec/lib/appsignal/cli/install_spec.rb +114 -41
- data/spec/lib/appsignal/config_spec.rb +24 -0
- data/spec/lib/appsignal/integrations/http_spec.rb +0 -21
- data/spec/lib/appsignal_spec.rb +52 -0
- metadata +6 -5
- data/lib/appsignal/heartbeat.rb +0 -59
- data/lib/appsignal/helpers/heartbeats.rb +0 -44
- data/spec/lib/appsignal/heartbeat_spec.rb +0 -127
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3908c76b33dae84dfbaaa42896c709c8ceaf8443dd3855c4811e660fd9da5df0
|
4
|
+
data.tar.gz: a5be1a3498ff49fe1e6de1d09abe81bb4d2ce2a5cc44a69e6fa45ebe9b9d8496
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98b58eda188a7abce65a74ee3a8dbf3b7c59f6f7c9af28c7cc18181942d7ac9a886f5648f4425af78417d475739172b0ef925851f06307ba2e586d52d9763077
|
7
|
+
data.tar.gz: 8311cc2b6c88447565c87cc231c50e3aa0640905cef72f400cb1620057ae22ef779da497dac76287ec9404957684fe838fd6c6471d9fcc5081b5cde94e747f05
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,78 @@
|
|
1
1
|
# AppSignal for Ruby gem Changelog
|
2
2
|
|
3
|
+
## 3.13.0
|
4
|
+
|
5
|
+
_Published on 2024-08-14._
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- Remove the HTTP gem's exception handling. Errors from the HTTP gem will no longer always be reported. The error will be reported only when an HTTP request is made in an instrumented context. This gives applications the opportunity to add their own custom exception handling.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
begin
|
13
|
+
HTTP.get("https://appsignal.com/error")
|
14
|
+
rescue => error
|
15
|
+
# Either handle the error or report it to AppSignal
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
(minor [2a452ff0](https://github.com/appsignal/appsignal-ruby/commit/2a452ff07e0b0938b1623fa8846af6ef37917ec2))
|
20
|
+
- Rename heartbeats to cron check-ins. Calls to `Appsignal.heartbeat` and `Appsignal::Heartbeat` should be replaced with calls to `Appsignal::CheckIn.cron` and `Appsignal::CheckIn::Cron`, for example:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
# Before
|
24
|
+
Appsignal.heartbeat("do_something") do
|
25
|
+
do_something
|
26
|
+
end
|
27
|
+
|
28
|
+
# After
|
29
|
+
Appsignal::CheckIn.cron("do_something") do
|
30
|
+
do_something
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
(patch [2f686cd0](https://github.com/appsignal/appsignal-ruby/commit/2f686cd00d5daa6e0854a8cacfe0e874a3a7c146))
|
35
|
+
|
36
|
+
### Deprecated
|
37
|
+
|
38
|
+
- Calls to `Appsignal.heartbeat` and `Appsignal::Heartbeat` will emit a deprecation warning. (patch [2f686cd0](https://github.com/appsignal/appsignal-ruby/commit/2f686cd00d5daa6e0854a8cacfe0e874a3a7c146))
|
39
|
+
|
40
|
+
## 3.12.6
|
41
|
+
|
42
|
+
_Published on 2024-08-05._
|
43
|
+
|
44
|
+
### Changed
|
45
|
+
|
46
|
+
- Configure AppSignal with the install CLI when no known frameworks is found. Automate the configure step so that this doesn't have to be done manually along with the manual setup for the app. (patch [a9c546fa](https://github.com/appsignal/appsignal-ruby/commit/a9c546fa86afbec290cd8439a559bf60cad21fc8))
|
47
|
+
|
48
|
+
### Deprecated
|
49
|
+
|
50
|
+
- Deprecate the `Appsignal.listen_for_error` helper. Use a manual error rescue with `Appsignal.report_error`. This method allows for more customization of the reported error.
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
# Before
|
54
|
+
Appsignal.listen_for_error do
|
55
|
+
raise "some error"
|
56
|
+
end
|
57
|
+
|
58
|
+
# After
|
59
|
+
begin
|
60
|
+
raise "some error"
|
61
|
+
rescue => error
|
62
|
+
Appsignal.report_error(error)
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
Read our [Exception handling guide](https://docs.appsignal.com/ruby/instrumentation/exception-handling.html) for more information.
|
67
|
+
|
68
|
+
(patch [14bd8882](https://github.com/appsignal/appsignal-ruby/commit/14bd88824dea2993cb0165bbbed0def29d69f72a))
|
69
|
+
- Deprecate the `Appsignal.configure`'s `app_path` writer. Use the `Appsignal.configure`'s `root_path` keyword argument to configure the path. (patch [c79f46c3](https://github.com/appsignal/appsignal-ruby/commit/c79f46c3cd96ac51726a963f38999bfb3c246d52))
|
70
|
+
|
71
|
+
### Fixed
|
72
|
+
|
73
|
+
- Fix an error on the Padrino require in the installer CLI. The latest Padrino version will crash the installer on load. Ignore the error when it fails to load. (patch [dfe23707](https://github.com/appsignal/appsignal-ruby/commit/dfe23707f769ff818714ee7cf14340f9472ce2e4))
|
74
|
+
- Fix the `Appsignal.configure` path config not being customizable. It's now possible to pass a `root_path` keyword argument to `Appsignal.configure` to customize the path from which AppSignal reads the config file, `config/appsignal.yml`. (patch [c79f46c3](https://github.com/appsignal/appsignal-ruby/commit/c79f46c3cd96ac51726a963f38999bfb3c246d52))
|
75
|
+
|
3
76
|
## 3.12.5
|
4
77
|
|
5
78
|
_Published on 2024-08-01._
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appsignal
|
4
|
+
module CheckIn
|
5
|
+
class Cron
|
6
|
+
class << self
|
7
|
+
# @api private
|
8
|
+
def transmitter
|
9
|
+
@transmitter ||= Appsignal::Transmitter.new(
|
10
|
+
"#{Appsignal.config[:logging_endpoint]}/check_ins/json"
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def emit_initializer_deprecation_warning
|
15
|
+
return if @initializer_deprecation_warning_emitted
|
16
|
+
|
17
|
+
callers = caller
|
18
|
+
Appsignal::Utils::StdoutAndLoggerMessage.warning(
|
19
|
+
"Passing a `name` keyword argument to `Appsignal::CheckIn::Cron.new` is deprecated. " \
|
20
|
+
"Please use the `identifier` keyword argument instead, " \
|
21
|
+
"in the following file and elsewhere, to remove this message.\n#{callers[2]}"
|
22
|
+
)
|
23
|
+
@initializer_deprecation_warning_emitted = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# @api private
|
28
|
+
attr_reader :identifier, :digest
|
29
|
+
|
30
|
+
def initialize(identifier: nil, name: nil)
|
31
|
+
@identifier = identifier || name || raise(ArgumentError, "missing keyword: :identifier")
|
32
|
+
Cron.emit_initializer_deprecation_warning unless name.nil?
|
33
|
+
@digest = SecureRandom.hex(8)
|
34
|
+
end
|
35
|
+
|
36
|
+
def start
|
37
|
+
transmit_event("start")
|
38
|
+
end
|
39
|
+
|
40
|
+
def finish
|
41
|
+
transmit_event("finish")
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def event(kind)
|
47
|
+
{
|
48
|
+
:identifier => @identifier,
|
49
|
+
:digest => @digest,
|
50
|
+
:kind => kind,
|
51
|
+
:timestamp => Time.now.utc.to_i,
|
52
|
+
:check_in_type => "cron"
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def transmit_event(kind)
|
57
|
+
unless Appsignal.active?
|
58
|
+
Appsignal.internal_logger.debug(
|
59
|
+
"AppSignal not active, not transmitting cron check-in event"
|
60
|
+
)
|
61
|
+
return
|
62
|
+
end
|
63
|
+
|
64
|
+
response = self.class.transmitter.transmit(event(kind))
|
65
|
+
|
66
|
+
if response.code.to_i >= 200 && response.code.to_i < 300
|
67
|
+
Appsignal.internal_logger.debug(
|
68
|
+
"Transmitted cron check-in `#{identifier}` (#{digest}) #{kind} event"
|
69
|
+
)
|
70
|
+
else
|
71
|
+
Appsignal.internal_logger.error(
|
72
|
+
"Failed to transmit cron check-in #{kind} event: status code was #{response.code}"
|
73
|
+
)
|
74
|
+
end
|
75
|
+
rescue => e
|
76
|
+
Appsignal.internal_logger.error("Failed to transmit cron check-in #{kind} event: #{e}")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appsignal
|
4
|
+
module CheckIn
|
5
|
+
class << self
|
6
|
+
# Track cron check-ins.
|
7
|
+
#
|
8
|
+
# Track the execution of certain processes by sending a cron check-in.
|
9
|
+
#
|
10
|
+
# To track the duration of a piece of code, pass a block to {.cron}
|
11
|
+
# to report both when the process starts, and when it finishes.
|
12
|
+
#
|
13
|
+
# If an exception is raised within the block, the finish event will not
|
14
|
+
# be reported, triggering a notification about the missing cron check-in.
|
15
|
+
# The exception will bubble outside of the cron check-in block.
|
16
|
+
#
|
17
|
+
# @example Send a cron check-in
|
18
|
+
# Appsignal::CheckIn.cron("send_invoices")
|
19
|
+
#
|
20
|
+
# @example Send a cron check-in with duration
|
21
|
+
# Appsignal::CheckIn.cron("send_invoices") do
|
22
|
+
# # your code
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# @param name [String] name of the cron check-in to report.
|
26
|
+
# @yield the block to monitor.
|
27
|
+
# @return [void]
|
28
|
+
# @since 3.13.0
|
29
|
+
# @see https://docs.appsignal.com/check-ins/cron
|
30
|
+
def cron(identifier)
|
31
|
+
cron = Appsignal::CheckIn::Cron.new(:identifier => identifier)
|
32
|
+
output = nil
|
33
|
+
|
34
|
+
if block_given?
|
35
|
+
cron.start
|
36
|
+
output = yield
|
37
|
+
end
|
38
|
+
|
39
|
+
cron.finish
|
40
|
+
output
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
require "appsignal/check_in/cron"
|
@@ -18,16 +18,16 @@ module Appsignal
|
|
18
18
|
$stdout.sync = true
|
19
19
|
|
20
20
|
puts
|
21
|
-
puts colorize "
|
22
|
-
puts colorize "## Starting AppSignal Installer
|
23
|
-
puts colorize "##
|
24
|
-
puts colorize "## Need help? support@appsignal.com
|
25
|
-
puts colorize "## Docs
|
26
|
-
puts colorize "
|
21
|
+
puts colorize "############################################", :green
|
22
|
+
puts colorize "## Starting AppSignal Installer ##", :green
|
23
|
+
puts colorize "## -------------------------------------- ##", :green
|
24
|
+
puts colorize "## Need help? support@appsignal.com ##", :green
|
25
|
+
puts colorize "## Docs: https://docs.appsignal.com ##", :green
|
26
|
+
puts colorize "############################################", :green
|
27
27
|
puts
|
28
28
|
unless push_api_key
|
29
29
|
puts colorize "Problem encountered:", :red
|
30
|
-
puts " No
|
30
|
+
puts " No Push API key entered."
|
31
31
|
puts " - Sign up for AppSignal and follow the instructions"
|
32
32
|
puts " - Already signed up? Click 'Add app' on the account overview page"
|
33
33
|
puts
|
@@ -37,22 +37,25 @@ module Appsignal
|
|
37
37
|
config = new_config
|
38
38
|
config[:push_api_key] = push_api_key
|
39
39
|
|
40
|
-
print "Validating API key"
|
40
|
+
print "Validating Push API key"
|
41
41
|
periods
|
42
42
|
puts
|
43
43
|
begin
|
44
44
|
auth_check = Appsignal::AuthCheck.new(config)
|
45
45
|
unless auth_check.perform == "200"
|
46
|
-
|
46
|
+
print colorize(" Error:", :red)
|
47
|
+
puts " Push API key '#{config[:push_api_key]}' is not valid. " \
|
48
|
+
"Please get a new one at https://appsignal.com/accounts"
|
47
49
|
return
|
48
50
|
end
|
49
51
|
rescue => e
|
50
|
-
|
52
|
+
print colorize(" Error:", :red)
|
53
|
+
puts "There was an error validating your Push API key:"
|
51
54
|
puts colorize "'#{e}'", :red
|
52
|
-
puts " Please try again"
|
55
|
+
puts " Please check the Push API key and try again"
|
53
56
|
return
|
54
57
|
end
|
55
|
-
puts colorize " API key valid!", :green
|
58
|
+
puts colorize " Push API key valid!", :green
|
56
59
|
puts
|
57
60
|
|
58
61
|
if installed_frameworks.include?(:rails)
|
@@ -66,12 +69,7 @@ module Appsignal
|
|
66
69
|
elsif installed_frameworks.include?(:sinatra)
|
67
70
|
install_for_sinatra(config)
|
68
71
|
else
|
69
|
-
|
70
|
-
puts " We could not detect which framework you are using. " \
|
71
|
-
"We'd be very grateful if you email us on support@appsignal.com " \
|
72
|
-
"with information about your setup."
|
73
|
-
puts
|
74
|
-
done_notice
|
72
|
+
install_for_unknown_framework(config)
|
75
73
|
end
|
76
74
|
end
|
77
75
|
|
@@ -119,11 +117,18 @@ module Appsignal
|
|
119
117
|
puts
|
120
118
|
configure(config, %w[development production staging], true)
|
121
119
|
|
122
|
-
puts "
|
123
|
-
puts " Sinatra requires some manual
|
124
|
-
puts "
|
120
|
+
puts "Sinatra installation"
|
121
|
+
puts " Sinatra apps requires some manual setup."
|
122
|
+
puts " Update the `config.ru` (or the application's main file) to " \
|
123
|
+
"look like this:"
|
124
|
+
puts
|
125
|
+
puts %(require "appsignal")
|
126
|
+
puts %(require "sinatra" # or require "sinatra/base")
|
125
127
|
puts
|
126
|
-
puts "
|
128
|
+
puts "Appsignal.load(:sinatra) # Load the Sinatra integration"
|
129
|
+
puts "Appsignal.start # Start AppSignal"
|
130
|
+
puts
|
131
|
+
puts "# Rest of the config.ru file"
|
127
132
|
puts
|
128
133
|
puts " You can find more information in the documentation:"
|
129
134
|
puts " https://docs.appsignal.com/ruby/integrations/sinatra.html"
|
@@ -137,11 +142,14 @@ module Appsignal
|
|
137
142
|
puts
|
138
143
|
configure(config, %w[development production staging], true)
|
139
144
|
|
140
|
-
puts "
|
141
|
-
puts " Padrino requires some manual
|
142
|
-
puts " After installing the gem, add the following
|
145
|
+
puts "Padrino installation"
|
146
|
+
puts " Padrino apps requires some manual setup."
|
147
|
+
puts " After installing the gem, add the following lines to `config/boot.rb`:"
|
148
|
+
puts
|
149
|
+
puts %(require "appsignal")
|
143
150
|
puts
|
144
|
-
puts "
|
151
|
+
puts "Appsignal.load(:padrino) # Load the Padrino integration"
|
152
|
+
puts "Appsignal.start # Start AppSignal"
|
145
153
|
puts
|
146
154
|
puts " You can find more information in the documentation:"
|
147
155
|
puts " https://docs.appsignal.com/ruby/integrations/padrino.html"
|
@@ -157,7 +165,8 @@ module Appsignal
|
|
157
165
|
|
158
166
|
configure(config, %w[development production staging], true)
|
159
167
|
|
160
|
-
puts "
|
168
|
+
puts "Grape installation"
|
169
|
+
puts " Grape apps require some manual setup."
|
161
170
|
puts " See the installation instructions at:"
|
162
171
|
puts " https://docs.appsignal.com/ruby/integrations/grape.html"
|
163
172
|
press_any_key
|
@@ -170,11 +179,17 @@ module Appsignal
|
|
170
179
|
puts
|
171
180
|
configure(config, %w[development production staging], true)
|
172
181
|
|
173
|
-
puts "
|
174
|
-
puts " Hanami requires some manual
|
175
|
-
puts "
|
182
|
+
puts "Hanami installation"
|
183
|
+
puts " Hanami apps requires some manual setup."
|
184
|
+
puts " Update the config.ru file to include the following:"
|
185
|
+
puts
|
186
|
+
puts %( require "appsignal")
|
187
|
+
puts %( require "hanami/boot")
|
176
188
|
puts
|
177
|
-
puts "
|
189
|
+
puts "Appsignal.load(:hanami) # Load the Hanami integration"
|
190
|
+
puts "Appsignal.start # Start AppSignal"
|
191
|
+
puts
|
192
|
+
puts "# Rest of the config.ru file"
|
178
193
|
puts
|
179
194
|
puts " You can find more information in the documentation:"
|
180
195
|
puts " https://docs.appsignal.com/ruby/integrations/hanami.html"
|
@@ -197,6 +212,23 @@ module Appsignal
|
|
197
212
|
puts
|
198
213
|
end
|
199
214
|
|
215
|
+
def install_for_unknown_framework(config)
|
216
|
+
puts "Installing"
|
217
|
+
config[:name] = required_input(" Enter application name: ")
|
218
|
+
puts
|
219
|
+
configure(config, %w[development production staging], true)
|
220
|
+
|
221
|
+
puts colorize "Warning: We could not detect which framework you are using", :red
|
222
|
+
puts " Some manual installation is most likely required."
|
223
|
+
puts " Please check our documentation for supported libraries: "
|
224
|
+
puts " https://docs.appsignal.com/ruby/integrations.html"
|
225
|
+
puts
|
226
|
+
puts " We'd be very grateful if you email us on " \
|
227
|
+
"support@appsignal.com with information about your setup."
|
228
|
+
press_any_key
|
229
|
+
done_notice
|
230
|
+
end
|
231
|
+
|
200
232
|
def configure(config, environments, name_overwritten)
|
201
233
|
install_for_capistrano
|
202
234
|
|
@@ -240,29 +272,27 @@ module Appsignal
|
|
240
272
|
end
|
241
273
|
|
242
274
|
def done_notice
|
243
|
-
sleep 0.3
|
244
|
-
puts colorize "#####################################", :green
|
245
|
-
puts colorize "## AppSignal installation complete ##", :green
|
246
|
-
puts colorize "#####################################", :green
|
247
|
-
sleep 0.3
|
248
|
-
puts
|
249
275
|
if Gem.win_platform?
|
250
|
-
|
276
|
+
print colorize "Warning:", :red
|
277
|
+
puts " The AppSignal agent currently does not work on Microsoft " \
|
251
278
|
"Windows. Please push these changes to your staging/production " \
|
252
279
|
"environment and make sure some actions are performed. " \
|
253
|
-
"AppSignal
|
280
|
+
"AppSignal will pick up your app after a few minutes."
|
254
281
|
else
|
255
|
-
puts "
|
282
|
+
puts "Sending example data to AppSignal..."
|
256
283
|
if Appsignal::Demo.transmit
|
257
284
|
puts " Example data sent!"
|
258
285
|
puts " It may take about a minute for the data to appear on https://appsignal.com/accounts"
|
259
|
-
puts
|
260
|
-
puts " Please return to your browser and follow the instructions."
|
261
286
|
else
|
262
|
-
|
263
|
-
puts "
|
287
|
+
print colorize "Error:", :red
|
288
|
+
puts " Couldn't start the AppSignal agent and send example data to AppSignal.com"
|
289
|
+
puts " Please contact us at support@appsignal.com and " \
|
290
|
+
"send us a diagnose report using `appsignal diagnose`."
|
291
|
+
return
|
264
292
|
end
|
265
293
|
end
|
294
|
+
puts
|
295
|
+
puts "Please return to your browser and follow the instructions."
|
266
296
|
end
|
267
297
|
|
268
298
|
def installed_frameworks
|
@@ -281,7 +311,7 @@ module Appsignal
|
|
281
311
|
def framework_available?(framework_file)
|
282
312
|
require framework_file
|
283
313
|
true
|
284
|
-
rescue LoadError
|
314
|
+
rescue LoadError, NameError
|
285
315
|
false
|
286
316
|
end
|
287
317
|
|
data/lib/appsignal/config.rb
CHANGED
@@ -212,7 +212,7 @@ module Appsignal
|
|
212
212
|
# Initialize a new configuration object for AppSignal.
|
213
213
|
#
|
214
214
|
# @param root_path [String] Root path of the app.
|
215
|
-
# @param
|
215
|
+
# @param initial_env [String] The environment to load when AppSignal is started. It
|
216
216
|
# will look for an environment with this name in the `config/appsignal.yml`
|
217
217
|
# config file.
|
218
218
|
# @param initial_config [Hash<String, Object>] The initial configuration to
|
@@ -622,8 +622,12 @@ module Appsignal
|
|
622
622
|
@config.root_path
|
623
623
|
end
|
624
624
|
|
625
|
-
def app_path=(
|
626
|
-
|
625
|
+
def app_path=(_path)
|
626
|
+
Appsignal::Utils::StdoutAndLoggerMessage.warning \
|
627
|
+
"The `Appsignal.configure`'s `app_path=` writer is deprecated " \
|
628
|
+
"and can no longer be used to set the root path. " \
|
629
|
+
"Use the `Appsignal.configure`'s method `root_path` keyword argument " \
|
630
|
+
"to set the root path."
|
627
631
|
end
|
628
632
|
|
629
633
|
def env
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appsignal
|
4
|
+
module Helpers
|
5
|
+
module Heartbeat
|
6
|
+
# @deprecated Use {Appsignal::CheckIn.cron} instead.
|
7
|
+
def heartbeat(name, &block)
|
8
|
+
unless @heartbeat_helper_deprecation_warning_emitted
|
9
|
+
callers = caller
|
10
|
+
Appsignal::Utils::StdoutAndLoggerMessage.warning \
|
11
|
+
"The helper Appsignal.heartbeat has been deprecated. " \
|
12
|
+
"Please update the helper call to Appsignal::CheckIn.cron " \
|
13
|
+
"in the following file and elsewhere to remove this message.\n#{callers.first}"
|
14
|
+
@heartbeat_helper_deprecation_warning_emitted = true
|
15
|
+
end
|
16
|
+
Appsignal::CheckIn.cron(name, &block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -300,7 +300,10 @@ module Appsignal
|
|
300
300
|
# @see .send_error
|
301
301
|
# @see https://docs.appsignal.com/ruby/instrumentation/integrating-appsignal.html
|
302
302
|
# AppSignal integration guide
|
303
|
+
# @see https://docs.appsignal.com/ruby/instrumentation/exception-handling.html
|
304
|
+
# Exception handling guide
|
303
305
|
#
|
306
|
+
# @deprecated Use `rescue => error` with {.report_error} instead.
|
304
307
|
# @param tags [Hash, nil]
|
305
308
|
# @param namespace [String] the namespace for this error.
|
306
309
|
# @yield yields the given block.
|
@@ -309,6 +312,11 @@ module Appsignal
|
|
309
312
|
tags = nil,
|
310
313
|
namespace = Appsignal::Transaction::HTTP_REQUEST
|
311
314
|
)
|
315
|
+
stdout_and_logger_warning \
|
316
|
+
"The `Appsignal.listen_for_error` helper is deprecated. " \
|
317
|
+
"Please use `rescue => error` and `Appsignal.report_error` instead. " \
|
318
|
+
"Read our exception handling documentation: " \
|
319
|
+
"https://docs.appsignal.com/ruby/instrumentation/exception-handling.html"
|
312
320
|
yield
|
313
321
|
rescue Exception => error # rubocop:disable Lint/RescueException
|
314
322
|
send_error(error) do |transaction|
|
@@ -8,13 +8,8 @@ module Appsignal
|
|
8
8
|
parsed_request_uri = uri.is_a?(URI) ? uri : URI.parse(uri.to_s)
|
9
9
|
request_uri = "#{parsed_request_uri.scheme}://#{parsed_request_uri.host}"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
super
|
14
|
-
end
|
15
|
-
rescue Exception => error # rubocop:disable Lint/RescueException
|
16
|
-
Appsignal.set_error(error)
|
17
|
-
raise error
|
11
|
+
Appsignal.instrument("request.http_rb", "#{verb.upcase} #{request_uri}") do
|
12
|
+
super
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
data/lib/appsignal/version.rb
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -6,7 +6,7 @@ require "stringio"
|
|
6
6
|
|
7
7
|
require "appsignal/logger"
|
8
8
|
require "appsignal/utils/stdout_and_logger_message"
|
9
|
-
require "appsignal/helpers/
|
9
|
+
require "appsignal/helpers/heartbeat"
|
10
10
|
require "appsignal/helpers/instrumentation"
|
11
11
|
require "appsignal/helpers/metrics"
|
12
12
|
|
@@ -18,7 +18,7 @@ require "appsignal/helpers/metrics"
|
|
18
18
|
# {Appsignal::Helpers::Metrics}) for ease of use.
|
19
19
|
module Appsignal
|
20
20
|
class << self
|
21
|
-
include Helpers::
|
21
|
+
include Helpers::Heartbeat
|
22
22
|
include Helpers::Instrumentation
|
23
23
|
include Helpers::Metrics
|
24
24
|
|
@@ -228,24 +228,28 @@ module Appsignal
|
|
228
228
|
# # Or for the environment given as an argument
|
229
229
|
# Appsignal.configure(:production)
|
230
230
|
#
|
231
|
+
# @param env [String, Symbol] The environment to load.
|
232
|
+
# @param root_path [String] The path to look the `config/appsignal.yml` config file in.
|
233
|
+
# Defaults to the current working directory.
|
231
234
|
# @yield [Config] Gives the {Config} instance to the block.
|
232
235
|
# @return [void]
|
233
236
|
# @see config
|
234
237
|
# @see Config
|
235
238
|
# @see https://docs.appsignal.com/ruby/configuration.html Configuration guide
|
236
239
|
# @see https://docs.appsignal.com/ruby/configuration/options.html Configuration options
|
237
|
-
def configure(env = nil)
|
240
|
+
def configure(env = nil, root_path: nil)
|
238
241
|
if Appsignal.started?
|
239
242
|
Appsignal.internal_logger
|
240
243
|
.warn("AppSignal is already started. Ignoring `Appsignal.configure` call.")
|
241
244
|
return
|
242
245
|
end
|
243
246
|
|
244
|
-
if config && (env.nil? || config.env == env.to_s)
|
247
|
+
if config && ((env.nil? || config.env == env.to_s) &&
|
248
|
+
(root_path.nil? || config.root_path == root_path))
|
245
249
|
config
|
246
250
|
else
|
247
251
|
@config = Config.new(
|
248
|
-
Config.determine_root_path,
|
252
|
+
root_path || Config.determine_root_path,
|
249
253
|
Config.determine_env(env),
|
250
254
|
{},
|
251
255
|
Appsignal.internal_logger,
|
@@ -457,6 +461,16 @@ module Appsignal
|
|
457
461
|
"Please update the constant name to Appsignal::Probes " \
|
458
462
|
"in the following file to remove this message.\n#{callers.first}"
|
459
463
|
Appsignal::Probes
|
464
|
+
when :Heartbeat
|
465
|
+
unless @heartbeat_constant_deprecation_warning_emitted
|
466
|
+
callers = caller
|
467
|
+
Appsignal::Utils::StdoutAndLoggerMessage.warning \
|
468
|
+
"The constant Appsignal::Heartbeat has been deprecated. " \
|
469
|
+
"Please update the constant name to Appsignal::CheckIn::Cron " \
|
470
|
+
"in the following file and elsewhere to remove this message.\n#{callers.first}"
|
471
|
+
@heartbeat_constant_deprecation_warning_emitted = true
|
472
|
+
end
|
473
|
+
Appsignal::CheckIn::Cron
|
460
474
|
else
|
461
475
|
super
|
462
476
|
end
|
@@ -485,4 +499,4 @@ require "appsignal/integrations/railtie" if defined?(::Rails)
|
|
485
499
|
require "appsignal/transaction"
|
486
500
|
require "appsignal/version"
|
487
501
|
require "appsignal/transmitter"
|
488
|
-
require "appsignal/
|
502
|
+
require "appsignal/check_in"
|