aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/notifications
Commit message (Collapse)AuthorAgeFilesLines
* 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-3/+3
| | | | | | | 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-4/+21
| | | | | | | | | | | | | | | | | | | | '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-2/+2
| | | | | | | | | | 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
* Remove @duration instance variable since we're not maintaining instances ↵Vishal Telangre2019-04-161-2/+1
| | | | variables such as @cpu_time, @idle_time and @allocations; this reduces one allocation
* Use monotonic time to record `started` and `finished` time values for an ↵Vishal Telangre2019-04-161-2/+2
| | | | event subscribed by a `ActiveSupport::Notifications::Fanout::Subscribers::Timed` subscriber
* Fix: #cpu_time doesn't work for a ↵Vishal Telangre2019-04-161-2/+2
| | | | `ActiveSupport::Notifications::Fanout::Subscribers::Timed` subscriber
* Update CHANGELOG and docsAli Ibrahim2019-03-221-3/+4
| | | | with change to ActiveSupport::Notifications::Instrumenter#instrument
* Update AS::Notifications::Instrumenter#instrumentAli Ibrahim2019-03-221-1/+1
| | | | | * Update #instrument to make passing a block optional. This will let users leverage #instrument for messaging in addition to instrumentation.
* Ruby 2.7 warning: creating a Proc without a blockutilum2019-02-131-2/+2
| | | | | | | | | | | | | | | | As of [Revision 66772]( https://bugs.ruby-lang.org/projects/ruby-trunk/repository/trunk/revisions/66772) `Proc.new` without giving a block emits `warning: tried to create Proc object without a block`. This commit fixes cases where Rails test suit tickles this warning. See CI logs: https://travis-ci.org/rails/rails/jobs/487205819#L1161-L1190 https://travis-ci.org/rails/rails/jobs/487205821#L1154-1159 https://travis-ci.org/rails/rails/jobs/487205821#L1160-L1169 https://travis-ci.org/rails/rails/jobs/487205821#L1189 https://travis-ci.org/rails/rails/jobs/487254404#L1307-L1416 https://travis-ci.org/rails/rails/jobs/487254405#L1174-L1191
* Merge pull request #32861 from zvkemp/asn-unsubscribe-proxyAaron Patterson2019-02-111-3/+35
|\ | | | | use ProxyPattern to match for ActiveSupport::Notifications fanout/unsubscribe
| * use a proxy matcher for AS::N fanoutzvkemp2019-02-111-3/+35
| |
* | Fix elapsed time calculationsbogdanvlviv2019-02-081-1/+1
|/ | | | | | | | | | | | | | | | | | | I've found a few places in Rails code base where I think it makes sense to calculate elapsed time more precisely by using `Concurrent.monotonic_time`: - Fix calculation of elapsed time in `ActiveSupport::Cache::MemoryStore#prune` - Fix calculation of elapsed time in `ActiveRecord::ConnectionAdapters::ConnectionPool::Queue#wait_poll` - Fix calculation of elapsed time in `ActiveRecord::ConnectionAdapters::ConnectionPool#attempt_to_checkout_all_existing_connections` - Fix calculation of elapsed time in `ActiveRecord::ConnectionAdapters::Mysql2Adapter#explain` See https://docs.ruby-lang.org/en/2.5.0/Process.html#method-c-clock_gettime https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way Related to 7c4542146f0dde962205e5a90839349631ae60fb
* Keep cache for strings in notifications/fanoutJohn Hawthorn2019-02-011-3/+5
| | | | | | | | | When adding/removing a subscription with a string pattern, it isn't necessary to clear the entire cache, only the cache for the key being added. When adding/removing subscriptions for a regex or to match all events, the full cache is still cleared.
* Make Notifications::Fanout#listeners_for fasterJohn Hawthorn2019-02-011-5/+18
| | | | | | | | | | Previously we stored all subscribers in an array, and every time a new message name came in asked each subscriber if they responded to the message. This commit changes Fanout to hash subscribers with a String pattern by their pattern. This way we can look them up directly and only do the O(N) scan over the non-string (Regex or any) patterns.
* Don't expose internal `clock_gettime_supported?` class methodRyuta Kamizono2018-11-301-1/+2
|
* Deprecate `event.end = Time.now` in favor of `event.finish!`Ryuta Kamizono2018-11-201-2/+6
| | | | | | | | Since #33449, `event.end = Time.now` is not used anymore and should use `event.finish!`. We can't use `deprecate :end=` in definition time in this module due to circular require in `active_support/deprecation/behaviors`.
* Windows support for parallelization and instrumenterGannon McGibbon2018-11-081-1/+6
| | | | | Add Windows support for `ActiveSupport::Testing::Parallelization` and `ActiveSupport::Notifications::Instrumenter`.
* Only use CLOCK_PROCESS_CPUTIME_ID if it's definedBart de Water2018-07-291-2/+8
| | | | It's not defined on JRuby and unlike monotonic time, concurrent-ruby doesn't have an cross-platform abstraction for this.
* fix arity check to use "parameters" for backwards compatAaron Patterson2018-07-261-4/+9
|
* Always subscribe to event objects via `AS::Notifications.subscribe`Aaron Patterson2018-07-262-12/+9
| | | | | | | 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_event`Aaron Patterson2018-07-262-1/+39
| | | | | | 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.
* Match the units in `duration` (milliseconds)Aaron Patterson2018-07-261-1/+7
|
* Add cpu_time, idle_time, and allocations to EventEileen Uchitelle2018-07-261-0/+47
| | | | | | | | | | | | | | * Use process clock instead of Time.now This fixes any issues with the system clock changing and also eliminates 2 object allocations per event. * Add start! and finish! methods to the event object so we can record more information * Adds cpu time, idle time, and allocation count for a particular event. Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com>
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-112-0/+2
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-092-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-022-2/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-012-0/+2
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* fixes remaining RuboCop issues [Vipul A M, Xavier Noria]Xavier Noria2016-09-011-1/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-062-3/+3
| | | | | 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-0/+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-282-4/+9
| | | | | | | | | | | | | 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.
* Require only necessary concurrent-ruby classes.Jerry D'Antonio2015-11-041-1/+1
|
* Replaced `ThreadSafe::Map` with successor `Concurrent::Map`.Jerry D'Antonio2015-09-191-3/+3
| | | | | | | The thread_safe gem is being deprecated and all its code has been merged into the concurrent-ruby gem. The new class, Concurrent::Map, is exactly the same as its predecessor except for fixes to two bugs discovered during the merge.
* :nodoc: internal class [ci skip]Godfrey Chan2015-08-101-1/+1
|
* Replace `#=>` with `# =>` [ci skip]claudiob2014-12-171-1/+1
| | | | | | | | @rafaelfranca suggested in f7c7bcd9 that code examples should display the result after `# =>` and not after `#=>`. This commit replaces *all* the occurrences of `#=>` in the code documentation (mostly added by me :sob:) with the suggested `# =>`.
* Fix docs for AS::Notifications::Event#durationclaudiob2014-12-171-2/+2
| | | | | | | | | Stems from comments by @zzak on e07f3dd: * https://github.com/rails/docrails/commit/e07f3ddcac394d2a8dc23fc571318b7e8c2497b1#commitcomment-9015634 * https://github.com/rails/docrails/commit/e07f3ddcac394d2a8dc23fc571318b7e8c2497b1#commitcomment-9015639 [ci skip]
* Add docs for AS::Notifications::Event#durationclaudiob2014-12-171-0/+12
| | | | [ci skip]
* Avoid looping through subscribers when unsubscribing with a subscriber object.Guo Xiang Tan2014-06-011-5/+10
|
* Update documentation to reflect unsubscription with name.Guo Xiang Tan2014-06-011-2/+2
|
* use a thread local rather than a queue so events are in the right orderAaron Patterson2013-10-301-7/+4
|
* use a queue rather than a list. fixes #12069Aaron Patterson2013-10-281-1/+1
|
* duration is called multiple times in dev, so lets cache itAaron Patterson2013-08-181-1/+2
|
* Bug fix: Evented notification subscribers can handle published eventsCarl Lerche2013-05-171-0/+7
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-03-301-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/adapter_test.rb guides/source/testing.md [ci skip]
| * Fix some typosAkira Matsuda2013-03-251-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.
* adding start / finish on the instrumenter, adding tests for the classAaron Patterson2013-01-091-6/+17
|