aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/notifications_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #36318 from itsWill/fix_event_object_payloadRafael França2019-07-251-0/+21
|\ | | | | Merge payload for EventObject subscribers
| * Merge payload for EventObject subscribersGuilherme Mansur2019-05-221-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When instrumenting a block of code like: ```ruby ActiveSupport::Notifications.instrument("process_action.action_controller", raw_paylaod) do |payload| payload[:view_runtime] = render_view end ``` If we use an evented subscriber like so: ``` ruby ActiveSupport::Notifications.subscribe("process_action.action_controller", raw_payload) do |event| assert event.payload[:view_runtime] end ``` The code breaks because the underlying EventObject's payload does not have the `:view_runtime` key added during instrumentation. This is because the `EventedObject` subscriber calls the `finish` method with the `payload` of the event at the time it was pushed into the stack, before the block executes, but we want to call `finish` with the `payload` after the instrument block executes this way if the `payload` was modified during the block we have access to it. This is consistent with the other types of subscribers who don't have this bug.
* | Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | | | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* | Fix `subscribed` with no pattern to subscribe all messagesRyuta Kamizono2019-06-031-0/+18
|/ | | | | | | This is a regression for #36184. And also, add new `monotonic` argument to the last of the method signature rather than the first.
* Introduce ↵Vishal Telangre2019-05-101-1/+68
| | | | | | | | | | | | | | | | | | | | 'ActiveSupport::Notifications::Fanout::Subscribers::MonotonicTimed' and 'ActiveSupport::Notifications::monotonic_subscribe' Also, change the signature of ‘ActiveSupport::Notifications::Fanout#subscribe’ to accept optional ‘monotonic’ boolean argument. Then initialize either a ‘Timed’ or ‘MonotonicTimed’ subscriber based on the value of ‘monotonic’ parameter. Introduce ‘ActiveSupport::Notifications::monotonic_subscribe’ method Also, provision ‘ActiveSupport::Notifications::subscribed’ to optionally accept ‘monotonic’ boolean argument. Update documentation for ActiveSupport::Notifications Add tests Update guides documentation under the 'Active Support Instrumentation' chapter Incorporate feedback: use optional keyword argument to specify optional 'monotonic' option to 'subscribed' method Fix a typo
* revert changes to monotonic timesKevin Solorio2019-04-301-4/+3
| | | | | | | | | | The change to monotonic times causes failures for applications where the subscribed block is expecting Time objects as described in this issue: https://github.com/rails/rails/issues/36145 The original PR (https://github.com/rails/rails/pull/35984) was concerned with errors on the cpu_time. Test was edited to reflect changes to initializer using 0 values instead of nil
* Add test coverageVishal Telangre2019-04-161-4/+13
|
* use a proxy matcher for AS::N fanoutzvkemp2019-02-111-0/+19
|
* ActiveSupport typo fixes.alkesh262019-02-011-1/+1
|
* Extend documentation of `ActiveSupport::Notifications.subscribe` (#34721)Bogdan2018-12-171-1/+1
| | | | | | | | | | | * Extend documentation of `ActiveSupport::Notifications.subscribe` Add mention that a block with only one argument passed to the method will yield an event object. Related to #33451 * Emphasize that `SubscribeEventObjects` is a test class by adding suffix `Test`
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
|
* Always subscribe to event objects via `AS::Notifications.subscribe`Aaron Patterson2018-07-261-9/+16
| | | | | | | We don't need to have a special subscribe method for objects. The regular `subscribe` method is more expensive than a specialized method, but `subscribe` should not be called frequently. If that turns out to be a hotspot, we can introduce a specialized method. :)
* Subscribe to event objects via `subscribe`Aaron Patterson2018-07-261-0/+12
|
* Subscribe to event objects via `subscribe_event`Aaron Patterson2018-07-261-0/+17
| | | | | | Fanout notifier can send event objects to subscribers now. Also moved `end` lower in the `finish!` method to guarantee that CPU time is shorter than real time.
* Replace `assert !` with `assert_not`Daniel Colson2018-04-191-3/+3
| | | | | This autocorrects the violations after adding a custom cop in 3305c78dcd.
* Remove extra whitespaceDaniel Colson2018-01-251-2/+2
|
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Privatize unneededly protected methods in Active Support testsAkira Matsuda2016-12-241-1/+1
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* modernizes hash syntax in activesupportXavier Noria2016-08-061-13/+13
|
* applies new string literal convention in activesupport/testXavier Noria2016-08-061-14/+14
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Adds exception object to instrumenter's payloadRyan T. Hosford2015-12-311-1/+1
| | | | | | | - Adds new key/value pair to payload when an exception is raised e.g. `:exception_object=> #<RuntimeError: FAIL>` - Updates relevant test - Adds CHANGELOG entry
* Subscribing to notifications while inside the said instrumented section.thedarkone2015-11-281-0/+15
| | | | | | | | | | | | | The issue is that on the exit from Instrumenter#instrument section, an Evented listener will run into an error because its thread local (Thread.current[:_timestack]) has not been set up by the #start method (this obviously happens because the Evented listeners didn't exist at the time, since no subscribtion to that section was made yet). Note: support for subscribing to instrumented sections, while being inside those instrumented sections, might be removed in the future. Maybe fixes #21873.
* Bug fix: Evented notification subscribers can handle published eventsCarl Lerche2013-05-171-0/+22
|
* Fix Typo existant -> existent [ci skip]Prathamesh Sonpatki2013-05-081-1/+1
|
* ActiveSupport::Notifications::Instrumenter#instrument should yieldstopdropandrew2013-03-021-1/+1
| | | | its payload the same way that ActiveSupport::Notifications does. Fix spelling in test name.
* make events not use date and time to determine parent_of. fixes #5932タコ焼き仮面2012-06-181-1/+3
|
* implements AS::Notifications.subscribed, which provides subscriptions to ↵Xavier Noria2011-11-051-0/+20
| | | | events while a block runs
* Requiring delegate.Arun Agrawal2011-08-161-0/+1
|
* Replace references to ActiveSupport::SecureRandom with just SecureRandom, ↵Jon Leighton2011-05-231-1/+1
| | | | and require 'securerandom' from the stdlib when active support is required.
* just use an attr_accessor so we do not pay ||= on every notification callAaron Patterson2011-02-091-2/+7
|
* Revert the previous three commits.José Valim2010-07-251-9/+0
| | | | | | * AS::Notifications#instrument should not measure anything, it is not its responsibility; * Adding another argument to AS::Notifications#instrument API needs to be properly discussed;
* use a hash to collect optional statistics about the instrumentationAaron Patterson2010-07-251-0/+9
|
* Get rid of instrumenter.elapsed.José Valim2010-07-241-9/+0
|
* Add a test for elapsed and require missing benchmark file.José Valim2010-07-201-17/+13
|
* Float comparison adjustmentSantiago Pastorino2010-07-181-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* We shouldn't rely on float comparison, delta added just in case float ↵Santiago Pastorino2010-07-121-3/+3
| | | | representation of this values aren't equal
* Event should be aware if yielded block failed or not.José Valim2010-05-021-0/+2
|
* Make notifications go off even when an error is raised, so that we capture ↵Justin George2010-05-021-2/+2
| | | | | | | | | | | | | | the underlying performance data [#4505 state:resolved] This is important when trying to keep track of many layers of interrelated calls i.e.: ActiveRecord::Base.transaction do MyModel.find(1) #ActiveRecord::NotFound end # should capture the full time until the error propagation Signed-off-by: José Valim <jose.valim@gmail.com>
* allow unsubscribe by name or subscription [#4433 state:resolved]David Chelimsky2010-04-241-0/+22
| | | | Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Mark bang instrumentations as something that you shuold not be listening to.José Valim2010-03-171-3/+3
|
* Optimize AS::Notifications to remember which subscribers don't match and not ↵Carlhuda2010-03-011-2/+29
| | | | run them. This will allow notifications that are only useful in dev or testing to run efficiently in production.
* You can unsubscribe a subscriberCarlhuda2010-03-011-1/+13
|
* Rename Rails::Subscriber to Rails::LogSubscriberPrem Sichanugrist2010-02-161-3/+3
|
* Remove instrument! and require thread from AS::Notifications.José Valim2010-02-041-17/+1
|
* deOMGifying Railties, Active Support, and Action PackMikel Lindsaar2010-01-311-3/+3
|
* Default to sync instrumentation.José Valim2010-01-211-17/+1
|