appsignal 4.0.0.beta.1-java → 4.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/README.md +8 -13
- data/benchmark.rake +4 -3
- data/lib/appsignal/helpers/instrumentation.rb +50 -36
- data/lib/appsignal/helpers/metrics.rb +42 -9
- data/lib/appsignal/rack/body_wrapper.rb +12 -0
- data/lib/appsignal/sample_data.rb +13 -0
- data/lib/appsignal/transaction.rb +62 -38
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +1 -0
- data/spec/lib/appsignal/cli/diagnose_spec.rb +13 -1
- data/spec/lib/appsignal/rack/body_wrapper_spec.rb +48 -0
- data/spec/lib/appsignal/sample_data_spec.rb +39 -0
- data/spec/lib/appsignal/transaction_spec.rb +24 -6
- data/spec/lib/appsignal_spec.rb +20 -3
- data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +5 -0
- data/spec/support/helpers/transaction_helpers.rb +1 -1
- data/spec/support/testing.rb +4 -0
- 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: 8b24fff89ddabacc2b97eedd0f2350e332084c31c4e879dab2b9f13e02f631e2
|
4
|
+
data.tar.gz: ec09dc858c399b9004cebb9afcdb1e041ba4f0efd068f173c6177e2bb5d10b1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ff5785db46ea54a79b993742b1f2730cae2bb236069c331414782732ed47de3a0c28a95e3bb8c9db45adcf2a402083af88f909d5065d839551d9f52bc560e64
|
7
|
+
data.tar.gz: 6da6a43068a8edf31158269f956be507f2125ec61dd8374192f228582c730862a5a659d5b2f530e7c995264e571d2e27daf049367089608dcdbbb63b5db16ef9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# AppSignal for Ruby gem Changelog
|
2
2
|
|
3
|
+
## 4.0.0
|
4
|
+
|
5
|
+
_Published on 2024-08-23._
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- Release the final package version. See the pre-release changelog entries for the changes in this version. (major)
|
10
|
+
|
11
|
+
### Removed
|
12
|
+
|
13
|
+
- Remove the `Transaction.new` method Transaction ID argument. The Transaction ID will always be automatically generated. (major [bb938a9f](https://github.com/appsignal/appsignal-ruby/commit/bb938a9f79b8b51e4c47d3f268326f89c137df6f))
|
14
|
+
|
15
|
+
## 4.0.0.beta.2
|
16
|
+
|
17
|
+
_Published on 2024-08-19._
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Add a helper for parameters sample data to be unset. This is a private method until we stabilize it. (patch [e9336363](https://github.com/appsignal/appsignal-ruby/commit/e9336363fa869c88ab925f57e86ead45e8e18c29))
|
22
|
+
|
3
23
|
## 4.0.0.beta.1
|
4
24
|
|
5
25
|
_Published on 2024-08-19._
|
@@ -113,6 +133,22 @@ _Published on 2024-08-19._
|
|
113
133
|
|
114
134
|
- Fix an issue where, when setting several errors for the same transaction, error causes from a different error would be shown for an error that has no causes. (patch [d54ce8b9](https://github.com/appsignal/appsignal-ruby/commit/d54ce8b947c9316756c4191155e8d255a8e25a8c))
|
115
135
|
|
136
|
+
## 3.13.1
|
137
|
+
|
138
|
+
_Published on 2024-08-23._
|
139
|
+
|
140
|
+
### Changed
|
141
|
+
|
142
|
+
- Release the final package version. See the pre-release changelog entries for the changes in this version. (patch)
|
143
|
+
|
144
|
+
## 3.13.1.alpha.1
|
145
|
+
|
146
|
+
_Published on 2024-08-22._
|
147
|
+
|
148
|
+
### Changed
|
149
|
+
|
150
|
+
- Ignore `Errno::EPIPE` errors when instrumenting response bodies. We've noticed this error gets reported when the connection is broken between server and client. This happens in normal scenarios so we'll ignore this error in this scenario to avoid error reports from errors that cannot be resolved. (patch [8ad8a057](https://github.com/appsignal/appsignal-ruby/commit/8ad8a05787dcb12a5c7febc64559e7f145a59096))
|
151
|
+
|
116
152
|
## 3.13.0
|
117
153
|
|
118
154
|
_Published on 2024-08-14._
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ request.
|
|
42
42
|
begin
|
43
43
|
config = File.read("config.yml")
|
44
44
|
rescue => e
|
45
|
-
Appsignal.
|
45
|
+
Appsignal.report_error(e)
|
46
46
|
# Load alternative config
|
47
47
|
config = { :name => ENV["NAME"] }
|
48
48
|
end
|
@@ -56,9 +56,9 @@ Need more information with errors and performance issues? Add tags to your
|
|
56
56
|
requests to identify common factors for problems.
|
57
57
|
|
58
58
|
```ruby
|
59
|
-
Appsignal.
|
60
|
-
user
|
61
|
-
locale
|
59
|
+
Appsignal.add_tags(
|
60
|
+
:user => current_user.id,
|
61
|
+
:locale => I18n.locale
|
62
62
|
)
|
63
63
|
```
|
64
64
|
|
@@ -143,11 +143,6 @@ anything.
|
|
143
143
|
For more detailed information and examples please visit our
|
144
144
|
[integrations] page.
|
145
145
|
|
146
|
-
### Front-end monitoring (Beta)
|
147
|
-
|
148
|
-
We have a [Front-end monitoring program][front-end-monitoring] running in Beta
|
149
|
-
currently. Be sure to check it out!
|
150
|
-
|
151
146
|
## Supported systems
|
152
147
|
|
153
148
|
Currently the AppSignal agent works on most Unix-like operating systems, such
|
@@ -304,11 +299,11 @@ Also see our [SUPPORT.md file](SUPPORT.md).
|
|
304
299
|
[ruby-doc]: https://www.rubydoc.info/gems/appsignal
|
305
300
|
[contributing-guide]: https://docs.appsignal.com/appsignal/contributing.html
|
306
301
|
[supported-systems]: https://docs.appsignal.com/support/operating-systems.html
|
307
|
-
[integrations]: https://docs.appsignal.com/ruby/integrations
|
308
|
-
[custom-instrumentation]: https://docs.appsignal.com/ruby/instrumentation
|
309
|
-
[front-end-monitoring]: https://docs.appsignal.com/front-end
|
302
|
+
[integrations]: https://docs.appsignal.com/ruby/integrations.html
|
303
|
+
[custom-instrumentation]: https://docs.appsignal.com/ruby/instrumentation.html
|
304
|
+
[front-end-monitoring]: https://docs.appsignal.com/front-end.html
|
310
305
|
[exception-handling]: https://docs.appsignal.com/ruby/instrumentation/exception-handling.html
|
311
|
-
[tagging]: https://docs.appsignal.com/
|
306
|
+
[tagging]: https://docs.appsignal.com/guides/custom-data/tagging-request.html
|
312
307
|
[host-metrics]: https://docs.appsignal.com/metrics/host.html
|
313
308
|
[custom-metrics]: https://docs.appsignal.com/metrics/custom.html
|
314
309
|
|
data/benchmark.rake
CHANGED
@@ -65,10 +65,11 @@ def start_agent
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def monitor_transaction(transaction_id)
|
68
|
-
transaction = Appsignal::Transaction.
|
69
|
-
|
70
|
-
|
68
|
+
transaction = Appsignal::Transaction.new(
|
69
|
+
Appsignal::Transaction::HTTP_REQUEST,
|
70
|
+
:id => transaction_id
|
71
71
|
)
|
72
|
+
Appsignal::Transaction.set_current_transaction(transaction)
|
72
73
|
transaction.set_action("HomeController#show")
|
73
74
|
transaction.add_params(:id => 1)
|
74
75
|
|
@@ -88,6 +88,7 @@ module Appsignal
|
|
88
88
|
# end
|
89
89
|
# end
|
90
90
|
#
|
91
|
+
# @since 3.11.0
|
91
92
|
# @param namespace [String/Symbol] The namespace to set on the new
|
92
93
|
# transaction.
|
93
94
|
# Defaults to the 'web' namespace.
|
@@ -105,10 +106,10 @@ module Appsignal
|
|
105
106
|
# @raise [Exception] Any exception that occurs within the given block is
|
106
107
|
# re-raised by this method.
|
107
108
|
# @return [Object] The value of the given block is returned.
|
108
|
-
#
|
109
|
-
|
110
|
-
|
111
|
-
)
|
109
|
+
#
|
110
|
+
# @see https://docs.appsignal.com/ruby/instrumentation/background-jobs.html
|
111
|
+
# Monitor guide
|
112
|
+
def monitor(action:, namespace: nil)
|
112
113
|
return yield unless active?
|
113
114
|
|
114
115
|
has_parent_transaction = Appsignal::Transaction.current?
|
@@ -160,6 +161,8 @@ module Appsignal
|
|
160
161
|
|
161
162
|
# Send an error to AppSignal regardless of the context.
|
162
163
|
#
|
164
|
+
# **We recommend using the {#report_error} helper instead.**
|
165
|
+
#
|
163
166
|
# Records and send the exception to AppSignal.
|
164
167
|
#
|
165
168
|
# This instrumentation helper does not require a transaction to be
|
@@ -186,6 +189,7 @@ module Appsignal
|
|
186
189
|
# Appsignal.add_tags(:key => "value")
|
187
190
|
# end
|
188
191
|
#
|
192
|
+
# @since 0.6.0
|
189
193
|
# @param error [Exception] The error to send to AppSignal.
|
190
194
|
# @yield [transaction] yields block to allow modification of the
|
191
195
|
# transaction before it's send.
|
@@ -193,12 +197,8 @@ module Appsignal
|
|
193
197
|
# used to send the error.
|
194
198
|
# @return [void]
|
195
199
|
#
|
196
|
-
# @see Transaction#report_error
|
197
200
|
# @see https://docs.appsignal.com/ruby/instrumentation/exception-handling.html
|
198
201
|
# Exception handling guide
|
199
|
-
# @see https://docs.appsignal.com/ruby/instrumentation/tagging.html
|
200
|
-
# Tagging guide
|
201
|
-
# @since 0.6.0
|
202
202
|
def send_error(error, &block)
|
203
203
|
return unless active?
|
204
204
|
|
@@ -208,10 +208,8 @@ module Appsignal
|
|
208
208
|
return
|
209
209
|
end
|
210
210
|
|
211
|
-
transaction =
|
212
|
-
|
213
|
-
Appsignal::Transaction::HTTP_REQUEST
|
214
|
-
)
|
211
|
+
transaction =
|
212
|
+
Appsignal::Transaction.new(Appsignal::Transaction::HTTP_REQUEST)
|
215
213
|
transaction.set_error(error, &block)
|
216
214
|
|
217
215
|
transaction.complete
|
@@ -220,6 +218,8 @@ module Appsignal
|
|
220
218
|
|
221
219
|
# Set an error on the current transaction.
|
222
220
|
#
|
221
|
+
# **We recommend using the {#report_error} helper instead.**
|
222
|
+
#
|
223
223
|
# **Note**: Does not do anything if AppSignal is not active, no
|
224
224
|
# transaction is currently active or when the "error" is not a class
|
225
225
|
# extended from Ruby's Exception class.
|
@@ -253,6 +253,7 @@ module Appsignal
|
|
253
253
|
# Appsignal.add_tags(:key => "value")
|
254
254
|
# end
|
255
255
|
#
|
256
|
+
# @since 0.6.6
|
256
257
|
# @param exception [Exception] The error to add to the current
|
257
258
|
# transaction.
|
258
259
|
# @yield [transaction] yields block to allow modification of the
|
@@ -261,11 +262,8 @@ module Appsignal
|
|
261
262
|
# used to store the error.
|
262
263
|
# @return [void]
|
263
264
|
#
|
264
|
-
# @see Transaction#set_error
|
265
|
-
# @see Transaction#report_error
|
266
265
|
# @see https://docs.appsignal.com/ruby/instrumentation/exception-handling.html
|
267
266
|
# Exception handling guide
|
268
|
-
# @since 0.6.6
|
269
267
|
def set_error(exception)
|
270
268
|
unless exception.is_a?(Exception)
|
271
269
|
internal_logger.error "Appsignal.set_error: Cannot set error. " \
|
@@ -281,12 +279,21 @@ module Appsignal
|
|
281
279
|
alias :set_exception :set_error
|
282
280
|
alias :add_exception :set_error
|
283
281
|
|
284
|
-
# Report an error.
|
282
|
+
# Report an error to AppSignal.
|
285
283
|
#
|
286
284
|
# If a transaction is currently active, it will report the error on the
|
287
285
|
# current transaction. If no transaction is active, it will report the
|
288
286
|
# error on a new transaction.
|
289
287
|
#
|
288
|
+
# If a transaction is active and the transaction already has an error
|
289
|
+
# reported on it, it will report multiple errors, up to a maximum of 10
|
290
|
+
# errors.
|
291
|
+
#
|
292
|
+
# If a block is given to this method, the metadata set in this block will
|
293
|
+
# only be applied to the transaction created for the given error. The
|
294
|
+
# block will be called when the transaction is completed, which can be
|
295
|
+
# much later than when {#report_error} is called.
|
296
|
+
#
|
290
297
|
# **Note**: If AppSignal is not active, no error is reported.
|
291
298
|
#
|
292
299
|
# **Note**: If the given exception argument is not an Exception subclass,
|
@@ -309,6 +316,7 @@ module Appsignal
|
|
309
316
|
# Appsignal.add_tags(:key => "value")
|
310
317
|
# end
|
311
318
|
#
|
319
|
+
# @since 4.0.0
|
312
320
|
# @param exception [Exception] The error to add to the current
|
313
321
|
# transaction.
|
314
322
|
# @yield [transaction] yields block to allow modification of the
|
@@ -319,7 +327,6 @@ module Appsignal
|
|
319
327
|
#
|
320
328
|
# @see https://docs.appsignal.com/ruby/instrumentation/exception-handling.html
|
321
329
|
# Exception handling guide
|
322
|
-
# @since 3.10.0
|
323
330
|
def report_error(exception, &block)
|
324
331
|
unless exception.is_a?(Exception)
|
325
332
|
internal_logger.error "Appsignal.report_error: Cannot add error. " \
|
@@ -333,10 +340,7 @@ module Appsignal
|
|
333
340
|
if has_parent_transaction
|
334
341
|
Appsignal::Transaction.current
|
335
342
|
else
|
336
|
-
Appsignal::Transaction.new(
|
337
|
-
SecureRandom.uuid,
|
338
|
-
Appsignal::Transaction::HTTP_REQUEST
|
339
|
-
)
|
343
|
+
Appsignal::Transaction.new(Appsignal::Transaction::HTTP_REQUEST)
|
340
344
|
end
|
341
345
|
|
342
346
|
transaction.add_error(exception, &block)
|
@@ -363,10 +367,9 @@ module Appsignal
|
|
363
367
|
# end
|
364
368
|
# end
|
365
369
|
#
|
370
|
+
# @since 2.2.0
|
366
371
|
# @param action [String]
|
367
372
|
# @return [void]
|
368
|
-
# @see Transaction#set_action
|
369
|
-
# @since 2.2.0
|
370
373
|
def set_action(action)
|
371
374
|
return if !active? ||
|
372
375
|
!Appsignal::Transaction.current? ||
|
@@ -403,10 +406,12 @@ module Appsignal
|
|
403
406
|
# end
|
404
407
|
# end
|
405
408
|
#
|
409
|
+
# @since 2.2.0
|
406
410
|
# @param namespace [String]
|
407
411
|
# @return [void]
|
408
|
-
#
|
409
|
-
# @
|
412
|
+
#
|
413
|
+
# @see https://docs.appsignal.com/guides/namespaces.html
|
414
|
+
# Grouping with namespaces guide
|
410
415
|
def set_namespace(namespace)
|
411
416
|
return if !active? ||
|
412
417
|
!Appsignal::Transaction.current? ||
|
@@ -452,7 +457,6 @@ module Appsignal
|
|
452
457
|
# @param data [Hash/Array] Custom data to add to the transaction.
|
453
458
|
# @return [void]
|
454
459
|
#
|
455
|
-
# @see Transaction#add_custom_data
|
456
460
|
# @see https://docs.appsignal.com/guides/custom-data/sample-data.html
|
457
461
|
# Sample data guide
|
458
462
|
def add_custom_data(data)
|
@@ -497,7 +501,6 @@ module Appsignal
|
|
497
501
|
# The name of the tag as a String.
|
498
502
|
# @return [void]
|
499
503
|
#
|
500
|
-
# @see Transaction#add_tags
|
501
504
|
# @see https://docs.appsignal.com/ruby/instrumentation/tagging.html
|
502
505
|
# Tagging guide
|
503
506
|
def add_tags(tags = {})
|
@@ -542,7 +545,6 @@ module Appsignal
|
|
542
545
|
# Sample data guide
|
543
546
|
# @see https://docs.appsignal.com/guides/filter-data/filter-parameters.html
|
544
547
|
# Parameter filtering guide
|
545
|
-
# @see Transaction#add_params
|
546
548
|
def add_params(params = nil, &block)
|
547
549
|
return unless active?
|
548
550
|
return unless Appsignal::Transaction.current?
|
@@ -552,6 +554,21 @@ module Appsignal
|
|
552
554
|
end
|
553
555
|
alias :set_params :add_params
|
554
556
|
|
557
|
+
# Mark the parameters sample data to be set as an empty value.
|
558
|
+
#
|
559
|
+
# @api private
|
560
|
+
# @since 4.0.0
|
561
|
+
# @return [void]
|
562
|
+
#
|
563
|
+
# @see Helpers::Instrumentation#set_empty_params!
|
564
|
+
def set_empty_params!
|
565
|
+
return unless active?
|
566
|
+
return unless Appsignal::Transaction.current?
|
567
|
+
|
568
|
+
transaction = Appsignal::Transaction.current
|
569
|
+
transaction.set_empty_params!
|
570
|
+
end
|
571
|
+
|
555
572
|
# Add session data to the current transaction.
|
556
573
|
#
|
557
574
|
# Session data is automatically added by most of our integrations. It
|
@@ -584,7 +601,6 @@ module Appsignal
|
|
584
601
|
# Sample data guide
|
585
602
|
# @see https://docs.appsignal.com/guides/filter-data/filter-session-data.html
|
586
603
|
# Session data filtering guide
|
587
|
-
# @see Transaction#add_session_data
|
588
604
|
def add_session_data(session_data = nil, &block)
|
589
605
|
return unless active?
|
590
606
|
return unless Appsignal::Transaction.current?
|
@@ -626,7 +642,6 @@ module Appsignal
|
|
626
642
|
# Sample data guide
|
627
643
|
# @see https://docs.appsignal.com/guides/filter-data/filter-headers.html
|
628
644
|
# Request headers filtering guide
|
629
|
-
# @see Transaction#add_headers
|
630
645
|
def add_headers(headers = nil, &block)
|
631
646
|
return unless active?
|
632
647
|
return unless Appsignal::Transaction.current?
|
@@ -663,6 +678,7 @@ module Appsignal
|
|
663
678
|
# "User closed modal without actions"
|
664
679
|
# )
|
665
680
|
#
|
681
|
+
# @since 2.12.0
|
666
682
|
# @param category [String] category of breadcrumb
|
667
683
|
# e.g. "UI", "Network", "Navigation", "Console".
|
668
684
|
# @param action [String] name of breadcrumb
|
@@ -672,10 +688,8 @@ module Appsignal
|
|
672
688
|
# @option time [Time] time of breadcrumb, should respond to `.to_i` defaults to `Time.now.utc`
|
673
689
|
# @return [void]
|
674
690
|
#
|
675
|
-
# @see Transaction#add_breadcrumb
|
676
691
|
# @see https://docs.appsignal.com/ruby/instrumentation/breadcrumbs.html
|
677
692
|
# Breadcrumb reference
|
678
|
-
# @since 2.12.0
|
679
693
|
def add_breadcrumb(category, action, message = "", metadata = {}, time = Time.now.utc)
|
680
694
|
return unless active?
|
681
695
|
return unless Appsignal::Transaction.current?
|
@@ -703,6 +717,7 @@ module Appsignal
|
|
703
717
|
# # To be instrumented code
|
704
718
|
# end
|
705
719
|
#
|
720
|
+
# @since 1.3.0
|
706
721
|
# @param name [String] Name of the instrumented event. Read our event
|
707
722
|
# naming guide listed under "See also".
|
708
723
|
# @param title [String, nil] Human readable name of the event.
|
@@ -716,13 +731,11 @@ module Appsignal
|
|
716
731
|
# event.
|
717
732
|
# @return [Object] Returns the block's return value.
|
718
733
|
#
|
719
|
-
# @see Appsignal::Transaction#instrument
|
720
734
|
# @see .instrument_sql
|
721
735
|
# @see https://docs.appsignal.com/ruby/instrumentation/instrumentation.html
|
722
736
|
# AppSignal custom instrumentation guide
|
723
737
|
# @see https://docs.appsignal.com/api/event-names.html
|
724
738
|
# AppSignal event naming guide
|
725
|
-
# @since 1.3.0
|
726
739
|
def instrument(
|
727
740
|
name,
|
728
741
|
title = nil,
|
@@ -750,6 +763,7 @@ module Appsignal
|
|
750
763
|
# # query value will replace 'foo..' with a question mark `?`.
|
751
764
|
# end
|
752
765
|
#
|
766
|
+
# @since 2.0.0
|
753
767
|
# @param name [String] Name of the instrumented event. Read our event
|
754
768
|
# naming guide listed under "See also".
|
755
769
|
# @param title [String, nil] Human readable name of the event.
|
@@ -763,7 +777,6 @@ module Appsignal
|
|
763
777
|
# AppSignal custom instrumentation guide
|
764
778
|
# @see https://docs.appsignal.com/api/event-names.html
|
765
779
|
# AppSignal event naming guide
|
766
|
-
# @since 2.0.0
|
767
780
|
def instrument_sql(name, title = nil, body = nil, &block)
|
768
781
|
instrument(
|
769
782
|
name,
|
@@ -796,9 +809,10 @@ module Appsignal
|
|
796
809
|
#
|
797
810
|
# # Only the "my_event.my_group" instrumentation event is reported.
|
798
811
|
#
|
812
|
+
# @since 3.10.0
|
799
813
|
# @yield block of code that shouldn't be instrumented.
|
800
814
|
# @return [Object] Returns the return value of the block.
|
801
|
-
#
|
815
|
+
#
|
802
816
|
# @see https://docs.appsignal.com/ruby/instrumentation/ignore-instrumentation.html
|
803
817
|
# Ignore instrumentation guide
|
804
818
|
def ignore_instrumentation_events
|
@@ -3,37 +3,70 @@
|
|
3
3
|
module Appsignal
|
4
4
|
module Helpers
|
5
5
|
module Metrics
|
6
|
-
|
6
|
+
# Report a gauge metric.
|
7
|
+
#
|
8
|
+
# @since 2.6.0
|
9
|
+
# @param name [String, Symbol] The name of the metric.
|
10
|
+
# @param value [Integer, Float] The value of the metric.
|
11
|
+
# @param tags [Hash] The tags for the metric. The Hash keys can be either
|
12
|
+
# a String or a Symbol. The tag values can be a String, Symbol,
|
13
|
+
# Integer, Float, TrueClass or FalseClass.
|
14
|
+
#
|
15
|
+
# @see https://docs.appsignal.com/metrics/custom.html
|
16
|
+
# Metrics documentation
|
17
|
+
def set_gauge(name, value, tags = {})
|
7
18
|
Appsignal::Extension.set_gauge(
|
8
|
-
|
19
|
+
name.to_s,
|
9
20
|
value.to_f,
|
10
21
|
Appsignal::Utils::Data.generate(tags)
|
11
22
|
)
|
12
23
|
rescue RangeError
|
13
24
|
Appsignal.internal_logger
|
14
|
-
.warn("
|
25
|
+
.warn("The gauge value '#{value}' for metric '#{name}' is too big")
|
15
26
|
end
|
16
27
|
|
17
|
-
|
28
|
+
# Report a counter metric.
|
29
|
+
#
|
30
|
+
# @since 2.6.0
|
31
|
+
# @param name [String, Symbol] The name of the metric.
|
32
|
+
# @param value [Integer, Float] The value of the metric.
|
33
|
+
# @param tags [Hash] The tags for the metric. The Hash keys can be either
|
34
|
+
# a String or a Symbol. The tag values can be a String, Symbol,
|
35
|
+
# Integer, Float, TrueClass or FalseClass.
|
36
|
+
#
|
37
|
+
# @see https://docs.appsignal.com/metrics/custom.html
|
38
|
+
# Metrics documentation
|
39
|
+
def increment_counter(name, value = 1.0, tags = {})
|
18
40
|
Appsignal::Extension.increment_counter(
|
19
|
-
|
41
|
+
name.to_s,
|
20
42
|
value.to_f,
|
21
43
|
Appsignal::Utils::Data.generate(tags)
|
22
44
|
)
|
23
45
|
rescue RangeError
|
24
46
|
Appsignal.internal_logger
|
25
|
-
.warn("
|
47
|
+
.warn("The counter value '#{value}' for metric '#{name}' is too big")
|
26
48
|
end
|
27
49
|
|
28
|
-
|
50
|
+
# Report a distribution metric.
|
51
|
+
#
|
52
|
+
# @since 2.6.0
|
53
|
+
# @param name [String, Symbol] The name of the metric.
|
54
|
+
# @param value [Integer, Float] The value of the metric.
|
55
|
+
# @param tags [Hash] The tags for the metric. The Hash keys can be either
|
56
|
+
# a String or a Symbol. The tag values can be a String, Symbol,
|
57
|
+
# Integer, Float, TrueClass or FalseClass.
|
58
|
+
#
|
59
|
+
# @see https://docs.appsignal.com/metrics/custom.html
|
60
|
+
# Metrics documentation
|
61
|
+
def add_distribution_value(name, value, tags = {})
|
29
62
|
Appsignal::Extension.add_distribution_value(
|
30
|
-
|
63
|
+
name.to_s,
|
31
64
|
value.to_f,
|
32
65
|
Appsignal::Utils::Data.generate(tags)
|
33
66
|
)
|
34
67
|
rescue RangeError
|
35
68
|
Appsignal.internal_logger
|
36
|
-
.warn("
|
69
|
+
.warn("The distribution value '#{value}' for metric '#{name}' is too big")
|
37
70
|
end
|
38
71
|
end
|
39
72
|
end
|
@@ -4,6 +4,8 @@ module Appsignal
|
|
4
4
|
module Rack
|
5
5
|
# @api private
|
6
6
|
class BodyWrapper
|
7
|
+
IGNORED_ERRORS = [Errno::EPIPE].freeze
|
8
|
+
|
7
9
|
def self.wrap(original_body, appsignal_transaction)
|
8
10
|
# The logic of how Rack treats a response body differs based on which methods
|
9
11
|
# the body responds to. This means that to support the Rack 3.x spec in full
|
@@ -49,6 +51,8 @@ module Appsignal
|
|
49
51
|
Appsignal.instrument("close_response_body.rack") { @body.close }
|
50
52
|
end
|
51
53
|
@body_already_closed = true
|
54
|
+
rescue *IGNORED_ERRORS # Do not report
|
55
|
+
raise
|
52
56
|
rescue Exception => error # rubocop:disable Lint/RescueException
|
53
57
|
@transaction.set_error(error)
|
54
58
|
raise error
|
@@ -75,6 +79,8 @@ module Appsignal
|
|
75
79
|
Appsignal.instrument("process_response_body.rack", "Process Rack response body (#each)") do
|
76
80
|
@body.each(&blk)
|
77
81
|
end
|
82
|
+
rescue *IGNORED_ERRORS # Do not report
|
83
|
+
raise
|
78
84
|
rescue Exception => error # rubocop:disable Lint/RescueException
|
79
85
|
@transaction.set_error(error)
|
80
86
|
raise error
|
@@ -94,6 +100,8 @@ module Appsignal
|
|
94
100
|
Appsignal.instrument("process_response_body.rack", "Process Rack response body (#call)") do
|
95
101
|
@body.call(stream)
|
96
102
|
end
|
103
|
+
rescue *IGNORED_ERRORS # Do not report
|
104
|
+
raise
|
97
105
|
rescue Exception => error # rubocop:disable Lint/RescueException
|
98
106
|
@transaction.set_error(error)
|
99
107
|
raise error
|
@@ -118,6 +126,8 @@ module Appsignal
|
|
118
126
|
) do
|
119
127
|
@body.to_ary
|
120
128
|
end
|
129
|
+
rescue *IGNORED_ERRORS # Do not report
|
130
|
+
raise
|
121
131
|
rescue Exception => error # rubocop:disable Lint/RescueException
|
122
132
|
@transaction.set_error(error)
|
123
133
|
raise error
|
@@ -134,6 +144,8 @@ module Appsignal
|
|
134
144
|
) do
|
135
145
|
@body.to_path
|
136
146
|
end
|
147
|
+
rescue *IGNORED_ERRORS # Do not report
|
148
|
+
raise
|
137
149
|
rescue Exception => error # rubocop:disable Lint/RescueException
|
138
150
|
@transaction.set_error(error)
|
139
151
|
raise error
|
@@ -7,9 +7,11 @@ module Appsignal
|
|
7
7
|
@key = key
|
8
8
|
@accepted_type = accepted_type
|
9
9
|
@blocks = []
|
10
|
+
@empty = false
|
10
11
|
end
|
11
12
|
|
12
13
|
def add(data = nil, &block)
|
14
|
+
@empty = false
|
13
15
|
if block_given?
|
14
16
|
@blocks << block
|
15
17
|
elsif accepted_type?(data)
|
@@ -19,6 +21,12 @@ module Appsignal
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
# @api private
|
25
|
+
def set_empty_value!
|
26
|
+
@empty = true
|
27
|
+
@blocks.clear
|
28
|
+
end
|
29
|
+
|
22
30
|
def value
|
23
31
|
value = nil
|
24
32
|
@blocks.map! do |block_or_value|
|
@@ -44,6 +52,11 @@ module Appsignal
|
|
44
52
|
@blocks.any?
|
45
53
|
end
|
46
54
|
|
55
|
+
# @api private
|
56
|
+
def empty?
|
57
|
+
@empty
|
58
|
+
end
|
59
|
+
|
47
60
|
protected
|
48
61
|
|
49
62
|
attr_reader :blocks
|
@@ -30,9 +30,7 @@ module Appsignal
|
|
30
30
|
# Check if we already have a running transaction
|
31
31
|
if Thread.current[:appsignal_transaction].nil?
|
32
32
|
# If not, start a new transaction
|
33
|
-
set_current_transaction(
|
34
|
-
Appsignal::Transaction.new(SecureRandom.uuid, namespace)
|
35
|
-
)
|
33
|
+
set_current_transaction(Appsignal::Transaction.new(namespace))
|
36
34
|
else
|
37
35
|
# Otherwise, log the issue about trying to start another transaction
|
38
36
|
Appsignal.internal_logger.warn(
|
@@ -109,24 +107,22 @@ module Appsignal
|
|
109
107
|
end
|
110
108
|
|
111
109
|
# @api private
|
112
|
-
attr_reader :
|
113
|
-
:breadcrumbs, :is_duplicate, :error_blocks
|
110
|
+
attr_reader :transaction_id, :action, :namespace
|
114
111
|
|
115
112
|
# Use {.create} to create new transactions.
|
116
113
|
#
|
117
|
-
# @param transaction_id [String] ID of the to be created transaction.
|
118
114
|
# @param namespace [String] Namespace of the to be created transaction.
|
119
115
|
# @see create
|
120
116
|
# @api private
|
121
|
-
def initialize(
|
122
|
-
@transaction_id =
|
117
|
+
def initialize(namespace, id: SecureRandom.uuid, ext: nil)
|
118
|
+
@transaction_id = id
|
123
119
|
@action = nil
|
124
120
|
@namespace = namespace
|
125
121
|
@paused = false
|
126
122
|
@discarded = false
|
127
123
|
@tags = {}
|
128
124
|
@breadcrumbs = []
|
129
|
-
@store = Hash.new
|
125
|
+
@store = Hash.new { |hash, key| hash[key] = {} }
|
130
126
|
@error_blocks = Hash.new { |hash, key| hash[key] = [] }
|
131
127
|
@is_duplicate = false
|
132
128
|
@error_set = nil
|
@@ -143,10 +139,17 @@ module Appsignal
|
|
143
139
|
) || Appsignal::Extension::MockTransaction.new
|
144
140
|
end
|
145
141
|
|
142
|
+
# @api private
|
143
|
+
def duplicate?
|
144
|
+
@is_duplicate
|
145
|
+
end
|
146
|
+
|
147
|
+
# @api private
|
146
148
|
def nil_transaction?
|
147
149
|
false
|
148
150
|
end
|
149
151
|
|
152
|
+
# @api private
|
150
153
|
def complete
|
151
154
|
if discarded?
|
152
155
|
Appsignal.internal_logger.debug "Skipping transaction '#{transaction_id}' " \
|
@@ -161,9 +164,9 @@ module Appsignal
|
|
161
164
|
# create duplicates for errors, which are always sampled.
|
162
165
|
should_sample = true
|
163
166
|
|
164
|
-
unless
|
167
|
+
unless duplicate?
|
165
168
|
self.class.last_errors = @error_blocks.keys
|
166
|
-
should_sample = ext.finish(0)
|
169
|
+
should_sample = @ext.finish(0)
|
167
170
|
end
|
168
171
|
|
169
172
|
@error_blocks.each do |error, blocks|
|
@@ -190,7 +193,7 @@ module Appsignal
|
|
190
193
|
end
|
191
194
|
end
|
192
195
|
sample_data if should_sample
|
193
|
-
ext.complete
|
196
|
+
@ext.complete
|
194
197
|
end
|
195
198
|
|
196
199
|
# @api private
|
@@ -240,12 +243,24 @@ module Appsignal
|
|
240
243
|
# @yield This block is called when the transaction is sampled. The block's
|
241
244
|
# return value will become the new parameters.
|
242
245
|
# @return [void]
|
246
|
+
#
|
243
247
|
# @see Helpers::Instrumentation#add_params
|
248
|
+
# @see https://docs.appsignal.com/guides/custom-data/sample-data.html
|
249
|
+
# Sample data guide
|
244
250
|
def add_params(given_params = nil, &block)
|
245
251
|
@params.add(given_params, &block)
|
246
252
|
end
|
247
253
|
alias :set_params :add_params
|
248
254
|
|
255
|
+
# @api private
|
256
|
+
# @since 4.0.0
|
257
|
+
# @return [void]
|
258
|
+
#
|
259
|
+
# @see Helpers::Instrumentation#set_empty_params!
|
260
|
+
def set_empty_params!
|
261
|
+
@params.set_empty_value!
|
262
|
+
end
|
263
|
+
|
249
264
|
# Add parameters to the transaction if not already set.
|
250
265
|
#
|
251
266
|
# @api private
|
@@ -257,7 +272,7 @@ module Appsignal
|
|
257
272
|
#
|
258
273
|
# @see #add_params
|
259
274
|
def add_params_if_nil(given_params = nil, &block)
|
260
|
-
add_params(given_params, &block)
|
275
|
+
add_params(given_params, &block) if !@params.value? && !@params.empty?
|
261
276
|
end
|
262
277
|
alias :set_params_if_nil :add_params_if_nil
|
263
278
|
|
@@ -265,6 +280,7 @@ module Appsignal
|
|
265
280
|
#
|
266
281
|
# When this method is called multiple times, it will merge the tags.
|
267
282
|
#
|
283
|
+
# @since 4.0.0
|
268
284
|
# @param given_tags [Hash] Collection of tags.
|
269
285
|
# @option given_tags [String, Symbol, Integer] :any
|
270
286
|
# The name of the tag as a Symbol.
|
@@ -278,7 +294,7 @@ module Appsignal
|
|
278
294
|
def add_tags(given_tags = {})
|
279
295
|
@tags.merge!(given_tags)
|
280
296
|
end
|
281
|
-
alias :set_tags add_tags
|
297
|
+
alias :set_tags :add_tags
|
282
298
|
|
283
299
|
# Add session data to the transaction.
|
284
300
|
#
|
@@ -287,12 +303,12 @@ module Appsignal
|
|
287
303
|
# When both the `given_session_data` and a block is given to this method,
|
288
304
|
# the block is leading and the argument will _not_ be used.
|
289
305
|
#
|
306
|
+
# @since 4.0.0
|
290
307
|
# @param given_session_data [Hash] A hash containing session data.
|
291
308
|
# @yield This block is called when the transaction is sampled. The block's
|
292
309
|
# return value will become the new session data.
|
293
310
|
# @return [void]
|
294
311
|
#
|
295
|
-
# @since 4.0.0
|
296
312
|
# @see Helpers::Instrumentation#add_session_data
|
297
313
|
# @see https://docs.appsignal.com/guides/custom-data/sample-data.html
|
298
314
|
# Sample data guide
|
@@ -307,13 +323,13 @@ module Appsignal
|
|
307
323
|
# the `given_session_data` argument is leading and the block will _not_ be
|
308
324
|
# called.
|
309
325
|
#
|
326
|
+
# @api private
|
327
|
+
# @since 4.0.0
|
310
328
|
# @param given_session_data [Hash] A hash containing session data.
|
311
329
|
# @yield This block is called when the transaction is sampled. The block's
|
312
330
|
# return value will become the new session data.
|
313
331
|
# @return [void]
|
314
332
|
#
|
315
|
-
# @api private
|
316
|
-
# @since 4.0.0
|
317
333
|
# @see #add_session_data
|
318
334
|
# @see https://docs.appsignal.com/guides/custom-data/sample-data.html
|
319
335
|
# Sample data guide
|
@@ -324,12 +340,12 @@ module Appsignal
|
|
324
340
|
|
325
341
|
# Add headers to the transaction.
|
326
342
|
#
|
343
|
+
# @since 4.0.0
|
327
344
|
# @param given_headers [Hash] A hash containing headers.
|
328
345
|
# @yield This block is called when the transaction is sampled. The block's
|
329
346
|
# return value will become the new headers.
|
330
347
|
# @return [void]
|
331
348
|
#
|
332
|
-
# @since 4.0.0
|
333
349
|
# @see Helpers::Instrumentation#add_headers
|
334
350
|
# @see https://docs.appsignal.com/guides/custom-data/sample-data.html
|
335
351
|
# Sample data guide
|
@@ -343,13 +359,13 @@ module Appsignal
|
|
343
359
|
# When both the `given_headers` and a block is given to this method,
|
344
360
|
# the block is leading and the argument will _not_ be used.
|
345
361
|
#
|
362
|
+
# @api private
|
363
|
+
# @since 4.0.0
|
346
364
|
# @param given_headers [Hash] A hash containing headers.
|
347
365
|
# @yield This block is called when the transaction is sampled. The block's
|
348
366
|
# return value will become the new headers.
|
349
367
|
# @return [void]
|
350
368
|
#
|
351
|
-
# @api private
|
352
|
-
# @since 4.0.0
|
353
369
|
# @see #add_headers
|
354
370
|
# @see https://docs.appsignal.com/guides/custom-data/sample-data.html
|
355
371
|
# Sample data guide
|
@@ -361,11 +377,12 @@ module Appsignal
|
|
361
377
|
# Add custom data to the transaction.
|
362
378
|
#
|
363
379
|
# @since 4.0.0
|
380
|
+
# @param data [Hash/Array]
|
381
|
+
# @return [void]
|
382
|
+
#
|
364
383
|
# @see Helpers::Instrumentation#add_custom_data
|
365
384
|
# @see https://docs.appsignal.com/guides/custom-data/sample-data.html
|
366
385
|
# Sample data guide
|
367
|
-
# @param data [Hash/Array]
|
368
|
-
# @return [void]
|
369
386
|
def add_custom_data(data)
|
370
387
|
@custom_data.add(data)
|
371
388
|
end
|
@@ -407,11 +424,11 @@ module Appsignal
|
|
407
424
|
# An action name is used to identify the location of a certain sample;
|
408
425
|
# error and performance issues.
|
409
426
|
#
|
427
|
+
# @since 2.2.0
|
410
428
|
# @param action [String] the action name to set.
|
411
429
|
# @return [void]
|
412
|
-
#
|
413
|
-
# @see #
|
414
|
-
# @since 2.2.0
|
430
|
+
#
|
431
|
+
# @see Appsignal::Helpers::Instrumentation#set_action
|
415
432
|
def set_action(action)
|
416
433
|
return unless action
|
417
434
|
|
@@ -429,10 +446,12 @@ module Appsignal
|
|
429
446
|
# Appsignal.set_action_if_nil("bar")
|
430
447
|
# # Transaction action will be "foo"
|
431
448
|
#
|
449
|
+
# @api private
|
450
|
+
# @since 2.2.0
|
432
451
|
# @param action [String]
|
433
452
|
# @return [void]
|
453
|
+
#
|
434
454
|
# @see #set_action
|
435
|
-
# @since 2.2.0
|
436
455
|
def set_action_if_nil(action)
|
437
456
|
return if @action
|
438
457
|
|
@@ -451,9 +470,13 @@ module Appsignal
|
|
451
470
|
# @example
|
452
471
|
# transaction.set_namespace("background")
|
453
472
|
#
|
473
|
+
# @since 2.2.0
|
454
474
|
# @param namespace [String] namespace name to use for this transaction.
|
455
475
|
# @return [void]
|
456
|
-
#
|
476
|
+
#
|
477
|
+
# @see Appsignal::Helpers::Instrumentation#set_namespace
|
478
|
+
# @see https://docs.appsignal.com/guides/namespaces.html
|
479
|
+
# Grouping with namespaces guide
|
457
480
|
def set_namespace(namespace)
|
458
481
|
return unless namespace
|
459
482
|
|
@@ -485,7 +508,8 @@ module Appsignal
|
|
485
508
|
@ext.set_metadata(key, value)
|
486
509
|
end
|
487
510
|
|
488
|
-
# @
|
511
|
+
# @api private
|
512
|
+
# @see Appsignal::Helpers::Instrumentation#report_error
|
489
513
|
def add_error(error, &block)
|
490
514
|
unless error.is_a?(Exception)
|
491
515
|
Appsignal.internal_logger.error "Appsignal::Transaction#add_error: Cannot add error. " \
|
@@ -508,21 +532,19 @@ module Appsignal
|
|
508
532
|
@error_blocks[error] << block
|
509
533
|
@error_blocks[error].compact!
|
510
534
|
end
|
511
|
-
|
512
535
|
alias :set_error :add_error
|
513
|
-
|
514
536
|
alias_method :add_exception, :add_error
|
515
537
|
|
516
|
-
# @see Helpers::Instrumentation#instrument
|
517
538
|
# @api private
|
539
|
+
# @see Helpers::Instrumentation#instrument
|
518
540
|
def start_event
|
519
541
|
return if paused?
|
520
542
|
|
521
543
|
@ext.start_event(0)
|
522
544
|
end
|
523
545
|
|
524
|
-
# @see Helpers::Instrumentation#instrument
|
525
546
|
# @api private
|
547
|
+
# @see Helpers::Instrumentation#instrument
|
526
548
|
def finish_event(name, title, body, body_format = Appsignal::EventFormatter::DEFAULT)
|
527
549
|
return if paused?
|
528
550
|
|
@@ -535,8 +557,8 @@ module Appsignal
|
|
535
557
|
)
|
536
558
|
end
|
537
559
|
|
538
|
-
# @see Helpers::Instrumentation#instrument
|
539
560
|
# @api private
|
561
|
+
# @see Helpers::Instrumentation#instrument
|
540
562
|
def record_event(name, title, body, duration, body_format = Appsignal::EventFormatter::DEFAULT)
|
541
563
|
return if paused?
|
542
564
|
|
@@ -550,6 +572,7 @@ module Appsignal
|
|
550
572
|
)
|
551
573
|
end
|
552
574
|
|
575
|
+
# @api private
|
553
576
|
# @see Helpers::Instrumentation#instrument
|
554
577
|
def instrument(name, title = nil, body = nil, body_format = Appsignal::EventFormatter::DEFAULT)
|
555
578
|
start_event
|
@@ -566,10 +589,13 @@ module Appsignal
|
|
566
589
|
|
567
590
|
protected
|
568
591
|
|
569
|
-
attr_writer :is_duplicate, :tags, :custom_data, :breadcrumbs, :params,
|
592
|
+
attr_writer :is_duplicate, :tags, :custom_data, :breadcrumbs, :params,
|
593
|
+
:session_data, :headers
|
570
594
|
|
571
595
|
private
|
572
596
|
|
597
|
+
attr_reader :breadcrumbs
|
598
|
+
|
573
599
|
def _set_error(error)
|
574
600
|
backtrace = cleaned_backtrace(error.backtrace)
|
575
601
|
@ext.set_error(
|
@@ -655,11 +681,10 @@ module Appsignal
|
|
655
681
|
|
656
682
|
def duplicate
|
657
683
|
new_transaction_id = SecureRandom.uuid
|
658
|
-
|
659
684
|
self.class.new(
|
660
|
-
new_transaction_id,
|
661
685
|
namespace,
|
662
|
-
:
|
686
|
+
:id => new_transaction_id,
|
687
|
+
:ext => @ext.duplicate(new_transaction_id)
|
663
688
|
).tap do |transaction|
|
664
689
|
transaction.is_duplicate = true
|
665
690
|
transaction.tags = @tags.dup
|
@@ -671,7 +696,6 @@ module Appsignal
|
|
671
696
|
end
|
672
697
|
end
|
673
698
|
|
674
|
-
# @api private
|
675
699
|
def params
|
676
700
|
@params.value
|
677
701
|
rescue => e
|
data/lib/appsignal/version.rb
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -937,6 +937,13 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
937
937
|
" loaders: \"MyApp\"\n" \
|
938
938
|
" file: \"TestApp\"\n"
|
939
939
|
)
|
940
|
+
# Outputs values from the DSL
|
941
|
+
expect(output).to include(
|
942
|
+
" ignore_actions: [\"Action from DSL\"]\n" \
|
943
|
+
" Sources:\n" \
|
944
|
+
" default: []\n" \
|
945
|
+
" dsl: [\"Action from DSL\"]\n"
|
946
|
+
)
|
940
947
|
|
941
948
|
expect(received_report["app"]["rails"]).to be(true)
|
942
949
|
expect(received_report["config"]["sources"]).to include(
|
@@ -947,6 +954,12 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
947
954
|
"name" => "MyApp"
|
948
955
|
}
|
949
956
|
)
|
957
|
+
# Includes values from the DSL
|
958
|
+
expect(received_report["config"]["sources"]).to include(
|
959
|
+
"dsl" => {
|
960
|
+
"ignore_actions" => ["Action from DSL"]
|
961
|
+
}
|
962
|
+
)
|
950
963
|
end
|
951
964
|
|
952
965
|
context "when there's a problem loading the app" do
|
@@ -963,7 +976,6 @@ describe Appsignal::CLI::Diagnose, :api_stub => true, :send_report => :yes_cli_i
|
|
963
976
|
"ExampleStandardError: error message"
|
964
977
|
)
|
965
978
|
|
966
|
-
pp received_report["app"]
|
967
979
|
expect(received_report["app"]["load_error"])
|
968
980
|
.to eq("ExampleStandardError: error message\nline 1\nline 2")
|
969
981
|
end
|
@@ -72,6 +72,18 @@ describe Appsignal::Rack::BodyWrapper do
|
|
72
72
|
expect(transaction).to have_error("ExampleException", "error message")
|
73
73
|
end
|
74
74
|
|
75
|
+
it "doesn't report EPIPE error" do
|
76
|
+
fake_body = double
|
77
|
+
expect(fake_body).to receive(:each).once.and_raise(Errno::EPIPE)
|
78
|
+
|
79
|
+
wrapped = described_class.wrap(fake_body, transaction)
|
80
|
+
expect do
|
81
|
+
expect { |b| wrapped.each(&b) }.to yield_control
|
82
|
+
end.to raise_error(Errno::EPIPE)
|
83
|
+
|
84
|
+
expect(transaction).to_not have_error
|
85
|
+
end
|
86
|
+
|
75
87
|
it "closes the body and tracks an instrumentation event when it gets closed" do
|
76
88
|
fake_body = double(:close => nil)
|
77
89
|
expect(fake_body).to receive(:each).once.and_yield("a").and_yield("b").and_yield("c")
|
@@ -134,6 +146,17 @@ describe Appsignal::Rack::BodyWrapper do
|
|
134
146
|
expect(transaction).to have_error("ExampleException", "error message")
|
135
147
|
end
|
136
148
|
|
149
|
+
it "doesn't report EPIPE error" do
|
150
|
+
expect(fake_body).to receive(:each).once.and_raise(Errno::EPIPE)
|
151
|
+
|
152
|
+
wrapped = described_class.wrap(fake_body, transaction)
|
153
|
+
expect do
|
154
|
+
expect { |b| wrapped.each(&b) }.to yield_control
|
155
|
+
end.to raise_error(Errno::EPIPE)
|
156
|
+
|
157
|
+
expect(transaction).to_not have_error
|
158
|
+
end
|
159
|
+
|
137
160
|
it "reads out the body in full using to_ary" do
|
138
161
|
expect(fake_body).to receive(:to_ary).and_return(["one", "two", "three"])
|
139
162
|
|
@@ -207,6 +230,17 @@ describe Appsignal::Rack::BodyWrapper do
|
|
207
230
|
expect(transaction).to have_error("ExampleException", "error message")
|
208
231
|
end
|
209
232
|
|
233
|
+
it "doesn't report EPIPE error" do
|
234
|
+
expect(fake_body).to receive(:to_path).once.and_raise(Errno::EPIPE)
|
235
|
+
|
236
|
+
wrapped = described_class.wrap(fake_body, transaction)
|
237
|
+
expect do
|
238
|
+
wrapped.to_path
|
239
|
+
end.to raise_error(Errno::EPIPE)
|
240
|
+
|
241
|
+
expect(transaction).to_not have_error
|
242
|
+
end
|
243
|
+
|
210
244
|
it "exposes to_path to the sender" do
|
211
245
|
allow(fake_body).to receive(:to_path).and_return("/tmp/file.bin")
|
212
246
|
|
@@ -259,5 +293,19 @@ describe Appsignal::Rack::BodyWrapper do
|
|
259
293
|
|
260
294
|
expect(transaction).to have_error("ExampleException", "error message")
|
261
295
|
end
|
296
|
+
|
297
|
+
it "doesn't report EPIPE error" do
|
298
|
+
fake_rack_stream = double
|
299
|
+
expect(fake_body).to receive(:call)
|
300
|
+
.with(fake_rack_stream)
|
301
|
+
.and_raise(Errno::EPIPE)
|
302
|
+
|
303
|
+
wrapped = described_class.wrap(fake_body, transaction)
|
304
|
+
expect do
|
305
|
+
wrapped.call(fake_rack_stream)
|
306
|
+
end.to raise_error(Errno::EPIPE)
|
307
|
+
|
308
|
+
expect(transaction).to_not have_error
|
309
|
+
end
|
262
310
|
end
|
263
311
|
end
|
@@ -142,6 +142,45 @@ describe Appsignal::SampleData do
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
+
describe "#set_empty_value!" do
|
146
|
+
it "clears the set values" do
|
147
|
+
data.add(["abc"])
|
148
|
+
data.add(["def"])
|
149
|
+
data.set_empty_value!
|
150
|
+
|
151
|
+
expect(data.value).to be_nil
|
152
|
+
end
|
153
|
+
|
154
|
+
it "allows values to be added afterwards" do
|
155
|
+
data.add(["abc"])
|
156
|
+
data.set_empty_value!
|
157
|
+
|
158
|
+
expect(data.value).to be_nil
|
159
|
+
|
160
|
+
data.add(["def"])
|
161
|
+
expect(data.value).to eq(["def"])
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "#cleared?" do
|
166
|
+
it "returns false if not cleared" do
|
167
|
+
expect(data.empty?).to be(false)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "returns true if cleared" do
|
171
|
+
data.set_empty_value!
|
172
|
+
|
173
|
+
expect(data.empty?).to be(true)
|
174
|
+
end
|
175
|
+
|
176
|
+
it "returns false if cleared and then new values were added" do
|
177
|
+
data.set_empty_value!
|
178
|
+
data.add(["abc"])
|
179
|
+
|
180
|
+
expect(data.empty?).to be(false)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
145
184
|
describe "#duplicate" do
|
146
185
|
it "duplicates the internal Hash state without modifying the original" do
|
147
186
|
data = described_class.new(:my_key, Hash)
|
@@ -39,7 +39,7 @@ describe Appsignal::Transaction do
|
|
39
39
|
let(:ext) { "some_ext" }
|
40
40
|
|
41
41
|
it "assigns the extension transaction to the transaction" do
|
42
|
-
expect(
|
42
|
+
expect(described_class.new("web", :ext => ext).ext).to be(ext)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -338,11 +338,11 @@ describe Appsignal::Transaction do
|
|
338
338
|
expect(original_transaction.ext).to_not eq(duplicate_transaction.ext)
|
339
339
|
end
|
340
340
|
|
341
|
-
it "
|
341
|
+
it "marks transaction as duplicate on the duplicate transaction" do
|
342
342
|
original_transaction, duplicate_transaction = created_transactions
|
343
343
|
|
344
|
-
expect(original_transaction.
|
345
|
-
expect(duplicate_transaction.
|
344
|
+
expect(original_transaction.duplicate?).to be(false)
|
345
|
+
expect(duplicate_transaction.duplicate?).to be(true)
|
346
346
|
end
|
347
347
|
end
|
348
348
|
|
@@ -517,7 +517,7 @@ describe Appsignal::Transaction do
|
|
517
517
|
it "changes the pause flag to true" do
|
518
518
|
expect do
|
519
519
|
transaction.pause!
|
520
|
-
end.to change(transaction, :paused).from(false).to(true)
|
520
|
+
end.to change(transaction, :paused?).from(false).to(true)
|
521
521
|
end
|
522
522
|
end
|
523
523
|
|
@@ -527,7 +527,7 @@ describe Appsignal::Transaction do
|
|
527
527
|
it "changes the pause flag to false" do
|
528
528
|
expect do
|
529
529
|
transaction.resume!
|
530
|
-
end.to change(transaction, :paused).from(true).to(false)
|
530
|
+
end.to change(transaction, :paused?).from(true).to(false)
|
531
531
|
end
|
532
532
|
end
|
533
533
|
|
@@ -590,6 +590,13 @@ describe Appsignal::Transaction do
|
|
590
590
|
|
591
591
|
expect(transaction.store("test")).to eql("transaction" => "value")
|
592
592
|
end
|
593
|
+
|
594
|
+
it "has a default value of a Hash for store values" do
|
595
|
+
transaction.store("abc")["def"] = "123"
|
596
|
+
|
597
|
+
expect(transaction.store("abc")).to eq("def" => "123")
|
598
|
+
expect(transaction.store("xyz")).to eq({})
|
599
|
+
end
|
593
600
|
end
|
594
601
|
|
595
602
|
describe "#add_params" do
|
@@ -732,6 +739,17 @@ describe Appsignal::Transaction do
|
|
732
739
|
expect(transaction).to include_params(preset_params)
|
733
740
|
end
|
734
741
|
end
|
742
|
+
|
743
|
+
context "when the params were set as an empty value" do
|
744
|
+
it "does not set params on the transaction" do
|
745
|
+
transaction.add_params("key1" => "value")
|
746
|
+
transaction.set_empty_params!
|
747
|
+
transaction.add_params_if_nil("key2" => "value")
|
748
|
+
|
749
|
+
transaction._sample
|
750
|
+
expect(transaction).to_not include_params
|
751
|
+
end
|
752
|
+
end
|
735
753
|
end
|
736
754
|
|
737
755
|
describe "#add_session_data" do
|
data/spec/lib/appsignal_spec.rb
CHANGED
@@ -935,6 +935,23 @@ describe Appsignal do
|
|
935
935
|
end
|
936
936
|
end
|
937
937
|
|
938
|
+
describe ".set_empty_params!" do
|
939
|
+
before { start_agent }
|
940
|
+
|
941
|
+
context "with transaction" do
|
942
|
+
let(:transaction) { http_request_transaction }
|
943
|
+
before { set_current_transaction(transaction) }
|
944
|
+
|
945
|
+
it "marks parameters to be sent as an empty value" do
|
946
|
+
Appsignal.add_params("key1" => "value")
|
947
|
+
Appsignal.set_empty_params!
|
948
|
+
|
949
|
+
transaction._sample
|
950
|
+
expect(transaction).to_not include_params
|
951
|
+
end
|
952
|
+
end
|
953
|
+
end
|
954
|
+
|
938
955
|
describe ".add_session_data" do
|
939
956
|
before { start_agent }
|
940
957
|
|
@@ -1140,7 +1157,7 @@ describe Appsignal do
|
|
1140
1157
|
Appsignal::Extension.data_map_new
|
1141
1158
|
).and_raise(RangeError)
|
1142
1159
|
expect(Appsignal.internal_logger).to receive(:warn)
|
1143
|
-
.with("
|
1160
|
+
.with("The gauge value '10' for metric 'key' is too big")
|
1144
1161
|
|
1145
1162
|
Appsignal.set_gauge("key", 10)
|
1146
1163
|
end
|
@@ -1175,7 +1192,7 @@ describe Appsignal do
|
|
1175
1192
|
expect(Appsignal::Extension).to receive(:increment_counter)
|
1176
1193
|
.with("key", 10, Appsignal::Extension.data_map_new).and_raise(RangeError)
|
1177
1194
|
expect(Appsignal.internal_logger).to receive(:warn)
|
1178
|
-
.with("
|
1195
|
+
.with("The counter value '10' for metric 'key' is too big")
|
1179
1196
|
|
1180
1197
|
Appsignal.increment_counter("key", 10)
|
1181
1198
|
end
|
@@ -1204,7 +1221,7 @@ describe Appsignal do
|
|
1204
1221
|
expect(Appsignal::Extension).to receive(:add_distribution_value)
|
1205
1222
|
.with("key", 10, Appsignal::Extension.data_map_new).and_raise(RangeError)
|
1206
1223
|
expect(Appsignal.internal_logger).to receive(:warn)
|
1207
|
-
.with("
|
1224
|
+
.with("The distribution value '10' for metric 'key' is too big")
|
1208
1225
|
|
1209
1226
|
Appsignal.add_distribution_value("key", 10)
|
1210
1227
|
end
|
@@ -16,7 +16,7 @@ module TransactionHelpers
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def new_transaction(namespace = default_namespace, ext: nil)
|
19
|
-
Appsignal::Transaction.new(
|
19
|
+
Appsignal::Transaction.new(namespace, :ext => ext)
|
20
20
|
end
|
21
21
|
|
22
22
|
def rack_request(env)
|
data/spec/support/testing.rb
CHANGED
@@ -167,6 +167,10 @@ end
|
|
167
167
|
module AppsignalTest
|
168
168
|
module Transaction
|
169
169
|
module ClassMethods
|
170
|
+
def self.extended(base)
|
171
|
+
base.attr_reader :ext, :error_blocks
|
172
|
+
end
|
173
|
+
|
170
174
|
# Override the {Appsignal::Transaction.new} method so we can track which
|
171
175
|
# transactions are created on the {Appsignal::Testing.transactions} list.
|
172
176
|
#
|
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.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: java
|
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-08-
|
13
|
+
date: 2024-08-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|