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.

F4d4e7e12544f6e3c660481f3bcccb0f?s=128

Matt Sanders

April 25, 2012
Tweet

Transcript

  1. 2.

    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. 4.

    • 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. 8.

    How It Works • #subscribe - ask to receive instrument

    data • #instrument - signal event or track data about operation (duration / exceptions) Wednesday, April 25, 12
  4. 10.

    #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Wednesday, April 25, 12
  5. 11.

    #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Wednesday, April 25, 12
  6. 12.

    #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Time Objects Wednesday, April 25, 12
  7. 13.

    #instrument Message Name (what you #subscribe to) Extra Arguments (passed

    as payload to #subscribe) Time Objects Unique Message ID Wednesday, April 25, 12
  8. 14.

    #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. 48.

    ...and more • Google Analytics events • Camp re /

    HipChat alerts • Schedule background jobs • Fire web hooks • etc Wednesday, April 25, 12
  10. 49.

    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. 69.

    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. 78.

    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