appsignal 3.12.0 → 3.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -5
- data/lib/appsignal/config.rb +33 -15
- data/lib/appsignal/helpers/instrumentation.rb +2 -2
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +4 -7
- data/spec/lib/appsignal/config_spec.rb +95 -70
- data/spec/lib/appsignal/transaction_spec.rb +57 -68
- data/spec/lib/appsignal_spec.rb +94 -0
- data/spec/support/helpers/config_helpers.rb +6 -0
- data/spec/support/matchers/transaction.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c3b3a593d57934c4d68cd4931ea948c5420ae2cc6e4fc43e482fab0df89165a
|
4
|
+
data.tar.gz: 0baf865761f51726ccc56b39ad9dabb7f5e0dbdb8be02ab9c1e4389b7d6595e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24e03e7a0255146b69fc04dbafb01f446d51f0ab2a72f3596b922b42f652a344b12171a6bc8d94e00d91da666fa40f4fa5820996c1fa2fe0651a23abd90a2cb4
|
7
|
+
data.tar.gz: 01b1507a66c700c640a5465f9ec15d2a0f8b5ea42f1ba246b8daa0a81816eaf0d04a37dcc13325686576ef2d47b3ee1d36488d0af3f8ee443c2905278d0bd9b6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# AppSignal for Ruby gem Changelog
|
2
2
|
|
3
|
+
## 3.12.2
|
4
|
+
|
5
|
+
_Published on 2024-07-25._
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
- Fix the default env and root path for the integrations using loader mechanism. If `APPSIGNAL_APP_ENV` is set when using `Appsignal.load(...)`, the AppSignal env set in `APPSIGNAL_APP_ENV` is now leading again. (patch [b2d1c7ee](https://github.com/appsignal/appsignal-ruby/commit/b2d1c7ee082e6865d9dc8d23ef060ecec9197a0e))
|
10
|
+
|
11
|
+
## 3.12.1
|
12
|
+
|
13
|
+
_Published on 2024-07-25._
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- Fix `Appsignal.monitor_and_stop` block passing. It would error with a `LocalJumpError`. Thanks to @cwaider. (patch [150569ff](https://github.com/appsignal/appsignal-ruby/commit/150569ff49e54ab743ed3db16d109abcf5719e30))
|
18
|
+
|
3
19
|
## 3.12.0
|
4
20
|
|
5
21
|
_Published on 2024-07-22._
|
@@ -28,11 +44,9 @@ _Published on 2024-07-22._
|
|
28
44
|
```ruby
|
29
45
|
# config/initializers/appsignal.rb
|
30
46
|
|
31
|
-
Appsignal.
|
32
|
-
|
33
|
-
|
34
|
-
:ignore_actions => ["My action"]
|
35
|
-
)
|
47
|
+
Appsignal.configure do |config|
|
48
|
+
config.ignore_actions = ["My action"]
|
49
|
+
end
|
36
50
|
```
|
37
51
|
|
38
52
|
Be aware that when `start_at` is set to `after_initialize`, AppSignal will not track any errors that occur when the initializers are run and the app fails to start.
|
data/lib/appsignal/config.rb
CHANGED
@@ -20,6 +20,35 @@ module Appsignal
|
|
20
20
|
loader_defaults << [name, options]
|
21
21
|
end
|
22
22
|
|
23
|
+
# Determine which env AppSignal should initialize with.
|
24
|
+
# @api private
|
25
|
+
def self.determine_env(initial_env = nil)
|
26
|
+
[
|
27
|
+
initial_env,
|
28
|
+
ENV.fetch("APPSIGNAL_APP_ENV", nil),
|
29
|
+
ENV.fetch("RAILS_ENV", nil),
|
30
|
+
ENV.fetch("RACK_ENV", nil)
|
31
|
+
].compact.each do |env|
|
32
|
+
return env if env
|
33
|
+
end
|
34
|
+
|
35
|
+
loader_defaults.reverse.each do |(_loader_name, loader_defaults)|
|
36
|
+
env = loader_defaults[:env]
|
37
|
+
return env if env
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Determine which root path AppSignal should initialize with.
|
42
|
+
# @api private
|
43
|
+
def self.determine_root_path
|
44
|
+
loader_defaults.reverse.each do |(_loader_name, loader_defaults)|
|
45
|
+
root_path = loader_defaults[:root_path]
|
46
|
+
return root_path if root_path
|
47
|
+
end
|
48
|
+
|
49
|
+
Dir.pwd
|
50
|
+
end
|
51
|
+
|
23
52
|
# @api private
|
24
53
|
DEFAULT_CONFIG = {
|
25
54
|
:activejob_report_errors => "all",
|
@@ -226,7 +255,9 @@ module Appsignal
|
|
226
255
|
|
227
256
|
return unless load_on_new
|
228
257
|
|
229
|
-
#
|
258
|
+
# Always override environment if set via this env var.
|
259
|
+
# TODO: This is legacy behavior. In the `Appsignal.configure` method the
|
260
|
+
# env argument is leading.
|
230
261
|
@env = ENV["APPSIGNAL_APP_ENV"] if ENV.key?("APPSIGNAL_APP_ENV")
|
231
262
|
load_config
|
232
263
|
validate
|
@@ -242,20 +273,7 @@ module Appsignal
|
|
242
273
|
@system_config = detect_from_system
|
243
274
|
merge(system_config)
|
244
275
|
|
245
|
-
#
|
246
|
-
# loader's defaults overwrite all others
|
247
|
-
self.class.loader_defaults.reverse.each do |(_loader_name, loader_defaults)|
|
248
|
-
defaults = loader_defaults.compact.dup
|
249
|
-
# Overwrite root path
|
250
|
-
loader_path = defaults.delete(:root_path)
|
251
|
-
@root_path = loader_path if loader_path
|
252
|
-
# Overwrite env
|
253
|
-
loader_env = defaults.delete(:env)
|
254
|
-
@env = loader_env.to_s if loader_env
|
255
|
-
# Merge with the config loaded so far
|
256
|
-
merge(defaults)
|
257
|
-
end
|
258
|
-
|
276
|
+
# Merge initial config
|
259
277
|
merge(initial_config)
|
260
278
|
# Track origin of env
|
261
279
|
@initial_config[:env] = @initial_env.to_s
|
@@ -154,8 +154,8 @@ module Appsignal
|
|
154
154
|
# documentation.
|
155
155
|
#
|
156
156
|
# @see monitor
|
157
|
-
def monitor_and_stop(action:, namespace: nil)
|
158
|
-
monitor(:namespace => namespace, :action => action)
|
157
|
+
def monitor_and_stop(action:, namespace: nil, &block)
|
158
|
+
monitor(:namespace => namespace, :action => action, &block)
|
159
159
|
ensure
|
160
160
|
Appsignal.stop("monitor_and_stop")
|
161
161
|
end
|
data/lib/appsignal/version.rb
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -121,10 +121,7 @@ module Appsignal
|
|
121
121
|
|
122
122
|
internal_logger.debug("Loading AppSignal gem")
|
123
123
|
|
124
|
-
@config ||= Config.new(
|
125
|
-
Dir.pwd,
|
126
|
-
ENV["APPSIGNAL_APP_ENV"] || ENV["RAILS_ENV"] || ENV.fetch("RACK_ENV", nil)
|
127
|
-
)
|
124
|
+
@config ||= Config.new(Config.determine_root_path, Config.determine_env)
|
128
125
|
|
129
126
|
_start_logger
|
130
127
|
|
@@ -247,9 +244,9 @@ module Appsignal
|
|
247
244
|
if config && config.env == env.to_s
|
248
245
|
config
|
249
246
|
else
|
250
|
-
|
251
|
-
|
252
|
-
|
247
|
+
@config = Config.new(
|
248
|
+
Config.determine_root_path,
|
249
|
+
Config.determine_env(env),
|
253
250
|
{},
|
254
251
|
Appsignal.internal_logger,
|
255
252
|
nil,
|
@@ -1,4 +1,99 @@
|
|
1
1
|
describe Appsignal::Config do
|
2
|
+
describe ".determine_env" do
|
3
|
+
context "with env argument" do
|
4
|
+
before { clear_integration_env_vars! }
|
5
|
+
|
6
|
+
it "considers the given env leading" do
|
7
|
+
expect(described_class.determine_env("given_env")).to eq("given_env")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "considers the given env leading over APPSIGNAL_APP_ENV" do
|
11
|
+
ENV["APPSIGNAL_APP_ENV"] = "env_env"
|
12
|
+
expect(described_class.determine_env("given_env")).to eq("given_env")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "considers the given env leading over other env vars" do
|
16
|
+
ENV["RAILS_ENV"] = "rails_env"
|
17
|
+
ENV["RACK_ENV"] = "rack_env"
|
18
|
+
expect(described_class.determine_env("given_env")).to eq("given_env")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "considers the given env leading over loader defaults" do
|
22
|
+
define_loader(:env_loader) do
|
23
|
+
def on_load
|
24
|
+
register_config_defaults(:env => "loader_env")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
load_loader(:env_loader)
|
28
|
+
expect(described_class.determine_env("given_env")).to eq("given_env")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "without env argument" do
|
33
|
+
before { clear_integration_env_vars! }
|
34
|
+
|
35
|
+
it "considers the APPSIGNAL_APP_ENV leading" do
|
36
|
+
ENV["APPSIGNAL_APP_ENV"] = "env_env"
|
37
|
+
ENV["RAILS_ENV"] = "rails_env"
|
38
|
+
ENV["RACK_ENV"] = "rack_env"
|
39
|
+
expect(described_class.determine_env).to eq("env_env")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "considers the RAILS_ENV leading over other env vars" do
|
43
|
+
ENV["RAILS_ENV"] = "rails_env"
|
44
|
+
ENV["RACK_ENV"] = "rack_env"
|
45
|
+
expect(described_class.determine_env).to eq("rails_env")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "reads from the RACK_ENV env last" do
|
49
|
+
ENV["RACK_ENV"] = "rack_env"
|
50
|
+
expect(described_class.determine_env).to eq("rack_env")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "falls back on the first loader env" do
|
54
|
+
define_loader(:env_loader1) do
|
55
|
+
def on_load
|
56
|
+
register_config_defaults(:env => "loader_env1")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
load_loader(:env_loader1)
|
60
|
+
|
61
|
+
define_loader(:env_loader2) do
|
62
|
+
def on_load
|
63
|
+
register_config_defaults(:env => "loader_env2")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
load_loader(:env_loader2)
|
67
|
+
|
68
|
+
expect(described_class.determine_env).to eq("loader_env2")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe ".determine_root_path" do
|
74
|
+
it "reads the root path from the first loader if any" do
|
75
|
+
define_loader(:path_loader1) do
|
76
|
+
def on_load
|
77
|
+
register_config_defaults(:root_path => "/loader_path1")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
load_loader(:path_loader1)
|
81
|
+
|
82
|
+
define_loader(:path_loader2) do
|
83
|
+
def on_load
|
84
|
+
register_config_defaults(:root_path => "/loader_path2")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
load_loader(:path_loader2)
|
88
|
+
|
89
|
+
expect(described_class.determine_root_path).to eq("/loader_path2")
|
90
|
+
end
|
91
|
+
|
92
|
+
it "falls back on the current working directory" do
|
93
|
+
expect(described_class.determine_root_path).to eq(Dir.pwd)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
2
97
|
describe "#initialize" do
|
3
98
|
describe "environment" do
|
4
99
|
context "when environment is nil" do
|
@@ -123,76 +218,6 @@ describe Appsignal::Config do
|
|
123
218
|
end
|
124
219
|
end
|
125
220
|
|
126
|
-
describe "loader default config" do
|
127
|
-
let(:config) do
|
128
|
-
described_class.new("some-path", "production")
|
129
|
-
end
|
130
|
-
before do
|
131
|
-
class TestLoader < Appsignal::Loaders::Loader
|
132
|
-
register :test
|
133
|
-
def on_load
|
134
|
-
register_config_defaults(
|
135
|
-
:env => "new_env",
|
136
|
-
:root_path => "/some/path",
|
137
|
-
:my_option => "my_value",
|
138
|
-
:nil_option => nil
|
139
|
-
)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
load_loader(:test)
|
143
|
-
end
|
144
|
-
after do
|
145
|
-
Object.send(:remove_const, :TestLoader)
|
146
|
-
unregister_loader(:first)
|
147
|
-
end
|
148
|
-
|
149
|
-
it "merges with the loader defaults" do
|
150
|
-
expect(config.config_hash).to include(:my_option => "my_value")
|
151
|
-
end
|
152
|
-
|
153
|
-
it "does not set any nil values" do
|
154
|
-
expect(config.config_hash).to_not have_key(:nil_option)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "overwrites the env" do
|
158
|
-
expect(config.env).to eq("new_env")
|
159
|
-
end
|
160
|
-
|
161
|
-
it "overwrites the path" do
|
162
|
-
expect(config.root_path).to eq("/some/path")
|
163
|
-
end
|
164
|
-
|
165
|
-
context "with multiple loaders" do
|
166
|
-
before do
|
167
|
-
class SecondLoader < Appsignal::Loaders::Loader
|
168
|
-
register :second
|
169
|
-
def on_load
|
170
|
-
register_config_defaults(
|
171
|
-
:env => "second_env",
|
172
|
-
:root_path => "/second/path",
|
173
|
-
:my_option => "second_value",
|
174
|
-
:second_option => "second_value"
|
175
|
-
)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
load_loader(:second)
|
179
|
-
end
|
180
|
-
after do
|
181
|
-
Object.send(:remove_const, :SecondLoader)
|
182
|
-
unregister_loader(:second)
|
183
|
-
end
|
184
|
-
|
185
|
-
it "makes the first loader's config leading" do
|
186
|
-
expect(config.config_hash).to include(
|
187
|
-
:my_option => "my_value",
|
188
|
-
:second_option => "second_value"
|
189
|
-
)
|
190
|
-
expect(config.env).to eq("new_env")
|
191
|
-
expect(config.root_path).to eq("/some/path")
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
221
|
describe "initial config" do
|
197
222
|
let(:initial_config) do
|
198
223
|
{
|
@@ -1499,54 +1499,53 @@ describe Appsignal::Transaction do
|
|
1499
1499
|
describe "#set_error" do
|
1500
1500
|
let(:transaction) { new_transaction }
|
1501
1501
|
let(:env) { http_request_env_with_data }
|
1502
|
-
let(:error)
|
1503
|
-
e = ExampleStandardError.new("test message")
|
1504
|
-
allow(e).to receive(:backtrace).and_return(["line 1"])
|
1505
|
-
e
|
1506
|
-
end
|
1502
|
+
let(:error) { ExampleStandardError.new("test message") }
|
1507
1503
|
|
1508
|
-
it "
|
1504
|
+
it "responds to add_exception for backwards compatibility" do
|
1509
1505
|
expect(transaction).to respond_to(:add_exception)
|
1510
1506
|
end
|
1511
1507
|
|
1512
|
-
it "
|
1508
|
+
it "does not add the error if not active" do
|
1513
1509
|
allow(Appsignal).to receive(:active?).and_return(false)
|
1514
|
-
expect(transaction.ext).to_not receive(:set_error)
|
1515
1510
|
|
1516
1511
|
transaction.set_error(error)
|
1512
|
+
|
1513
|
+
expect(transaction).to_not have_error
|
1517
1514
|
end
|
1518
1515
|
|
1519
|
-
context "when error is not an error" do
|
1516
|
+
context "when error argument is not an error" do
|
1520
1517
|
let(:error) { Object.new }
|
1521
1518
|
|
1522
1519
|
it "does not add the error" do
|
1523
|
-
|
1520
|
+
logs = capture_logs { transaction.set_error(error) }
|
1521
|
+
|
1522
|
+
expect(transaction).to_not have_error
|
1523
|
+
expect(logs).to contains_log(
|
1524
|
+
:error,
|
1524
1525
|
"Appsignal::Transaction#set_error: Cannot set error. " \
|
1525
1526
|
"The given value is not an exception: #{error.inspect}"
|
1526
1527
|
)
|
1527
|
-
expect(transaction.ext).to_not receive(:set_error)
|
1528
|
-
|
1529
|
-
transaction.set_error(error)
|
1530
1528
|
end
|
1531
1529
|
end
|
1532
1530
|
|
1533
1531
|
context "for a http request" do
|
1534
|
-
it "
|
1535
|
-
|
1532
|
+
it "sets an error on the transaction" do
|
1533
|
+
allow(error).to receive(:backtrace).and_return(["line 1"])
|
1534
|
+
transaction.set_error(error)
|
1535
|
+
|
1536
|
+
expect(transaction).to have_error(
|
1536
1537
|
"ExampleStandardError",
|
1537
1538
|
"test message",
|
1538
|
-
|
1539
|
+
["line 1"]
|
1539
1540
|
)
|
1540
|
-
|
1541
|
-
transaction.set_error(error)
|
1542
1541
|
end
|
1543
1542
|
end
|
1544
1543
|
|
1545
1544
|
context "when the error has no causes" do
|
1546
|
-
it "
|
1547
|
-
expect(transaction.ext).to_not receive(:set_sample_data)
|
1548
|
-
|
1545
|
+
it "does not set the causes information as sample data" do
|
1549
1546
|
transaction.set_error(error)
|
1547
|
+
|
1548
|
+
expect(transaction).to_not include_error_causes
|
1550
1549
|
end
|
1551
1550
|
end
|
1552
1551
|
|
@@ -1562,31 +1561,25 @@ describe Appsignal::Transaction do
|
|
1562
1561
|
end
|
1563
1562
|
|
1564
1563
|
it "sends the causes information as sample data" do
|
1565
|
-
|
1564
|
+
transaction.set_error(error)
|
1565
|
+
|
1566
|
+
expect(transaction).to have_error(
|
1566
1567
|
"ExampleStandardError",
|
1567
1568
|
"test message",
|
1568
|
-
|
1569
|
+
["line 1"]
|
1569
1570
|
)
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
:message => "cause message 2"
|
1582
|
-
}
|
1583
|
-
]
|
1584
|
-
)
|
1571
|
+
expect(transaction).to include_error_causes(
|
1572
|
+
[
|
1573
|
+
{
|
1574
|
+
"name" => "RuntimeError",
|
1575
|
+
"message" => "cause message"
|
1576
|
+
},
|
1577
|
+
{
|
1578
|
+
"name" => "StandardError",
|
1579
|
+
"message" => "cause message 2"
|
1580
|
+
}
|
1581
|
+
]
|
1585
1582
|
)
|
1586
|
-
|
1587
|
-
expect(Appsignal.internal_logger).to_not receive(:debug)
|
1588
|
-
|
1589
|
-
transaction.set_error(error)
|
1590
1583
|
end
|
1591
1584
|
end
|
1592
1585
|
|
@@ -1605,33 +1598,29 @@ describe Appsignal::Transaction do
|
|
1605
1598
|
end
|
1606
1599
|
|
1607
1600
|
it "sends only the first causes as sample data" do
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
:name => "ExampleStandardError",
|
1617
|
-
:message => "wrapper error #{9 - i}"
|
1618
|
-
}
|
1619
|
-
end
|
1601
|
+
expected_error_causes =
|
1602
|
+
Array.new(10) do |i|
|
1603
|
+
{
|
1604
|
+
"name" => "ExampleStandardError",
|
1605
|
+
"message" => "wrapper error #{9 - i}"
|
1606
|
+
}
|
1607
|
+
end
|
1608
|
+
expected_error_causes.last["is_root_cause"] = false
|
1620
1609
|
|
1621
|
-
|
1610
|
+
logs = capture_logs { transaction.set_error(error) }
|
1622
1611
|
|
1623
|
-
expect(transaction
|
1624
|
-
"
|
1625
|
-
|
1612
|
+
expect(transaction).to have_error(
|
1613
|
+
"ExampleStandardError",
|
1614
|
+
"wrapper error 10",
|
1615
|
+
["line 1"]
|
1626
1616
|
)
|
1627
|
-
|
1628
|
-
expect(
|
1617
|
+
expect(transaction).to include_error_causes(expected_error_causes)
|
1618
|
+
expect(logs).to contains_log(
|
1619
|
+
:debug,
|
1629
1620
|
"Appsignal::Transaction#set_error: Error has more " \
|
1630
1621
|
"than 10 error causes. Only the first 10 " \
|
1631
1622
|
"will be reported."
|
1632
1623
|
)
|
1633
|
-
|
1634
|
-
transaction.set_error(error)
|
1635
1624
|
end
|
1636
1625
|
end
|
1637
1626
|
|
@@ -1643,18 +1632,18 @@ describe Appsignal::Transaction do
|
|
1643
1632
|
e
|
1644
1633
|
end
|
1645
1634
|
|
1646
|
-
it "
|
1635
|
+
it "does not raise an error" do
|
1647
1636
|
transaction.set_error(error)
|
1648
1637
|
end
|
1649
1638
|
|
1650
|
-
it "
|
1651
|
-
|
1639
|
+
it "sets an error on the transaction without an error message" do
|
1640
|
+
transaction.set_error(error)
|
1641
|
+
|
1642
|
+
expect(transaction).to have_error(
|
1652
1643
|
"ExampleStandardError",
|
1653
1644
|
"",
|
1654
|
-
|
1645
|
+
["line 1"]
|
1655
1646
|
)
|
1656
|
-
|
1657
|
-
transaction.set_error(error)
|
1658
1647
|
end
|
1659
1648
|
end
|
1660
1649
|
end
|
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -209,6 +209,52 @@ describe Appsignal do
|
|
209
209
|
expect(Appsignal.config.env).to eq("env_env")
|
210
210
|
end
|
211
211
|
|
212
|
+
it "reads the environment from a loader default" do
|
213
|
+
clear_integration_env_vars!
|
214
|
+
define_loader(:loader_env) do
|
215
|
+
def on_load
|
216
|
+
register_config_defaults(
|
217
|
+
:env => "loader_env"
|
218
|
+
)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
load_loader(:loader_env)
|
222
|
+
|
223
|
+
Appsignal.configure do |config|
|
224
|
+
expect(config.env).to eq("loader_env")
|
225
|
+
end
|
226
|
+
|
227
|
+
expect(Appsignal.config.env).to eq("loader_env")
|
228
|
+
end
|
229
|
+
|
230
|
+
it "reads the root_path from a loader default" do
|
231
|
+
clear_integration_env_vars!
|
232
|
+
define_loader(:loader_path) do
|
233
|
+
def on_load
|
234
|
+
register_config_defaults(
|
235
|
+
:root_path => "/loader_path"
|
236
|
+
)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
load_loader(:loader_path)
|
240
|
+
|
241
|
+
Appsignal.configure do |config|
|
242
|
+
expect(config.app_path).to eq("/loader_path")
|
243
|
+
end
|
244
|
+
|
245
|
+
expect(Appsignal.config.root_path).to eq("/loader_path")
|
246
|
+
end
|
247
|
+
|
248
|
+
it "considers the given env leading above APPSIGNAL_APP_ENV" do
|
249
|
+
ENV["APPSIGNAL_APP_ENV"] = "env_env"
|
250
|
+
|
251
|
+
Appsignal.configure(:dsl_env) do |config|
|
252
|
+
expect(config.env).to eq("dsl_env")
|
253
|
+
end
|
254
|
+
|
255
|
+
expect(Appsignal.config.env).to eq("dsl_env")
|
256
|
+
end
|
257
|
+
|
212
258
|
it "allows modification of previously unset config options" do
|
213
259
|
expect do
|
214
260
|
Appsignal.configure do |config|
|
@@ -251,6 +297,48 @@ describe Appsignal do
|
|
251
297
|
expect(stderr).to_not include("[ERROR]")
|
252
298
|
expect(stdout).to_not include("[ERROR]")
|
253
299
|
end
|
300
|
+
|
301
|
+
it "reads the environment from the loader defaults" do
|
302
|
+
clear_integration_env_vars!
|
303
|
+
define_loader(:loader_env) do
|
304
|
+
def on_load
|
305
|
+
register_config_defaults(:env => "loader_env")
|
306
|
+
end
|
307
|
+
end
|
308
|
+
load_loader(:loader_env)
|
309
|
+
|
310
|
+
Appsignal.start
|
311
|
+
|
312
|
+
expect(Appsignal.config.env).to eq("loader_env")
|
313
|
+
end
|
314
|
+
|
315
|
+
it "reads the root_path from the loader defaults" do
|
316
|
+
define_loader(:loader_path) do
|
317
|
+
def on_load
|
318
|
+
register_config_defaults(:root_path => "/loader_path")
|
319
|
+
end
|
320
|
+
end
|
321
|
+
load_loader(:loader_path)
|
322
|
+
|
323
|
+
Appsignal.start
|
324
|
+
|
325
|
+
expect(Appsignal.config.root_path).to eq("/loader_path")
|
326
|
+
end
|
327
|
+
|
328
|
+
it "chooses APPSIGNAL_APP_ENV over the loader defaults as the default env" do
|
329
|
+
clear_integration_env_vars!
|
330
|
+
ENV["APPSIGNAL_APP_ENV"] = "env_env"
|
331
|
+
define_loader(:loader_env) do
|
332
|
+
def on_load
|
333
|
+
register_config_defaults(:env => "loader_env")
|
334
|
+
end
|
335
|
+
end
|
336
|
+
load_loader(:loader_env)
|
337
|
+
|
338
|
+
Appsignal.start
|
339
|
+
|
340
|
+
expect(Appsignal.config.env).to eq("env_env")
|
341
|
+
end
|
254
342
|
end
|
255
343
|
|
256
344
|
context "when config is loaded" do
|
@@ -745,6 +833,12 @@ describe Appsignal do
|
|
745
833
|
|
746
834
|
expect(Appsignal).to have_received(:stop).with("monitor_and_stop")
|
747
835
|
end
|
836
|
+
|
837
|
+
it "passes the block to Appsignal.monitor" do
|
838
|
+
expect do |blk|
|
839
|
+
Appsignal.monitor_and_stop(:action => "My action", &blk)
|
840
|
+
end.to yield_control
|
841
|
+
end
|
748
842
|
end
|
749
843
|
|
750
844
|
describe ".monitor_transaction" do
|
@@ -59,6 +59,7 @@ define_transaction_sample_matcher_for(:environment)
|
|
59
59
|
define_transaction_sample_matcher_for(:session_data)
|
60
60
|
define_transaction_sample_matcher_for(:tags)
|
61
61
|
define_transaction_sample_matcher_for(:custom_data)
|
62
|
+
define_transaction_sample_matcher_for(:error_causes)
|
62
63
|
|
63
64
|
RSpec::Matchers.define :be_completed do
|
64
65
|
match(:notify_expectation_failures => true) do |transaction|
|
@@ -66,14 +67,14 @@ RSpec::Matchers.define :be_completed do
|
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
69
|
-
RSpec::Matchers.define :have_error do |error_class, error_message|
|
70
|
+
RSpec::Matchers.define :have_error do |error_class, error_message, error_backtrace|
|
70
71
|
match(:notify_expectation_failures => true) do |transaction|
|
71
72
|
transaction_error = transaction.to_h["error"]
|
72
73
|
if error_class && error_message
|
73
74
|
expect(transaction_error).to include(
|
74
75
|
"name" => error_class,
|
75
76
|
"message" => error_message,
|
76
|
-
"backtrace" => kind_of(String)
|
77
|
+
"backtrace" => error_backtrace ? JSON.dump(error_backtrace) : kind_of(String)
|
77
78
|
)
|
78
79
|
else
|
79
80
|
expect(transaction_error).to be_any
|
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: 3.12.
|
4
|
+
version: 3.12.2
|
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: 2024-07-
|
13
|
+
date: 2024-07-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|