Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Digging Deep with ActiveSupport::Notifications

Digging Deep with ActiveSupport::Notifications

ActiveSupport::Notifications is a powerful, under-utilized library which makes it easy to instrument and monitor your code. Rails exposes a tons of performance information which is easy to access and you can create your own events with a single line of code. This talk explores the basics of ActiveSupport::Notifications and gets into powerful techniques you can use to super-charge your monitoring and instrumentation.

Matt Sanders

April 25, 2012
Tweet

Other Decks in Programming

Transcript

  1. Let’s Talk... • What is ActiveSupport::Noti cations? • Why you

    should care • How it works • What you can do with it Wednesday, April 25, 12
  2. • AS::Noti cations provides a simple, exible messaging system for

    instrumenting • Lots of valuable data is already exposed by Rails’ built-in instrumentation • Provides an easy path for performance monitoring what you care about in your application • Log & track what matters to you! Why you should care Wednesday, April 25, 12
  3. How It Works • #subscribe - ask to receive instrument

    data • #instrument - signal event or track data about operation (duration / exceptions) Wednesday, April 25, 12
  4. #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Wednesday, April 25, 12
  5. #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Wednesday, April 25, 12
  6. #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Time Objects Wednesday, April 25, 12
  7. #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Time Objects Unique Message ID Wednesday, April 25, 12
  8. #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Time Objects Payload Unique Message ID Wednesday, April 25, 12
  9. ...and more • Google Analytics events • Camp re /

    HipChat alerts • Schedule background jobs • Fire web hooks • etc Wednesday, April 25, 12
  10. Performance Notes • By default Rails calls subscribers in the

    thread where instrumentation took place • Consider backgrounding slow subscribers • Dispatcher can be replaced by your own queue system (set AS::Noti cations.noti er) Wednesday, April 25, 12
  11. Use Outside of Rails • activesupport/noti cations can be required

    by itself, only needs securerandom to work • provides a good abstract interface for instrumentation • activesupport/log_subscriber is a separate library, can be required if needed Wednesday, April 25, 12
  12. In closing... • AS::Noti cations provides a simple message-based system

    for instrumentation • Use what Rails gives you, create what it doesn’t • Track what you want, track what matters to you! Wednesday, April 25, 12