…many subtle bugs from interesting intersections between Rails (I'm looking at you, ActiveSupport) and the various flavors of Ruby. Running the unit tests under Rails helps flush out these odd interactions. For example, we found one problem with subtly incompatible versions of the to_json method floating around during the 2.x versions of ActiveSupport.
Which version of Rails do we run against? Well, if you download the agent source and run the unit tests, you'll see …
…diagnostic code I whipped up yesterday to add ActiveRecord callbacks to the development log.
activerecord-callback_notification - This one didn't do quite what I want, but I borrowed some of its code to start from.
Instrument Anything in Rails 3 - A good introduction to ActiveSupport::Notifications.
callback_skipper - Short-circuit things in your unit tests.
…rails 4.0.0.beta1 . Rails 4 provides updated versions of the ActiveSupport::Notifications libraries, which generate a queue of events containing performance timing information. The latest versions of the Ruby agent subscribe to these event streams, allowing us to integrate more seamlessly into the framework and avoid excessive monkey-patching. The highlights for Rails 4 include strong parameters, turbolinks, and Russion doll caching. See the Rails 4 release notes for …
…should. While this might make a lot of sense for libraries that extend the Ruby stdlib (like ActiveSupport ), monkeypatching someone else constant might bite you back later. Overusing monkeypatches might be a serious block when updating your application to newer versions of a big dependency of your project (for example, Rails).
When you monkey patch, you are usually messing with a very internal piece of a component that might be far from it's public API. So, you can't predict …
…check for the development environment appears to be necessary, because Rails uses some of ActiveSupport's test-related classes in the development environment!
Option 2 - Use "edge" Rails or one of the relevant "stable" branches of Rails # Gemfile gem "rails", git: "git://github.com/rails/rails.git", branch: "3-2-stable" group :test do gem "mocha", :require => false end
# test/test_helper.rb require …
…to this.
RailsCasts: Notifications in Rails 3
Digging Deep with ActiveSupport Notifications
Instrument Anything in Rails 3
On Notifications, Log Subscribers and Bringing Sanity to Rails Logs
Fin
Go forth and instrument all the things!
…that is all over Google search. Here's the equivalent code before I extracted to a ActiveSupport::Concern module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class Foo < ActiveRecord :: Base after_commit :clear_id_cache # class method def self . lookup_by_id (id) Rails .cache.fetch( " Foo:id: #{ id } " ) do where( :id => id).first …
…rails allows arbitrary code execution on an affected server. The vulnerable code is in rails's ActiveSupport library. Though the current versions of Chef server use Merb instead of rails, Merb uses an ActiveSupport fork called extlib that includes the same vulnerability to provide many of the same features as ActiveSupport. According to the currently available information about the vulnerability, there are several additional conditions that must be satisfied for the vulnerability …
…that, on the surface, make it easier for Rails to extend the Ruby language via ActiveSupport. I think that's too shallow of a reading. The new tools in Ruby 2.0 (excepting the highly-controversial refinements) make it easier to cleanly add functionality to Ruby's core objects and library. Reducing the cost of extending the core make it possible for more libraries and applications to judiciously make high-leverage additions to the lower levels of Ruby. That seems like a pretty …
…could start by adding optional instrumentation based on AS::Notifications. That'd ensure that ActiveSupport itself doesn't turn into a direct dependency. I'd love to see the notifications bit being extracted into a separate library that's easier to integrate than pulling in the entire ActiveSupport ball of mud.
Node.js has EventEmitters , which are similar to AS::Notifications, and they lend themselves quite nicely for this purpose.
I've dabbled with …