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

Rails Instrumentation

Brooke Kuhlmann
April 18, 2024
310

Rails Instrumentation

Learn how to unleash the power of instrumentation already baked into your Rails application for monitoring, metrics, logging, and many other purposes. In this presentation, you'll learn how Rails uses the Observer Pattern to asynchronously instrument events for which you can subscribe to and even customize for your specific business needs.

Brooke Kuhlmann

April 18, 2024
Tweet

Transcript

  1. Instrumenter ActiveSupport::Noti fi cations.instrument "my.event.library", example: "data" Event Name Format

    guides.rubyonrails.org/active_support_instrumentation.html alchemists.io
  2. Instrumenter ActiveSupport::Noti fi cations.instrument "increment.metrics", key: "stripe.failure" Event Library Payload

    Example guides.rubyonrails.org/active_support_instrumentation.html alchemists.io
  3. Instrumenter ActiveSupport::Noti fi cations.instrument "duration.metrics", key: "stripe.transaction" do adapter.charge amount

    end Block guides.rubyonrails.org/active_support_instrumentation.html alchemists.io
  4. Instrumenter ActiveSupport::Noti fi cations.instrument "duration.metrics", key: "stripe.transaction" do adapter.charge amount

    end Block guides.rubyonrails.org/active_support_instrumentation.html alchemists.io
  5. Instrumenter ActiveSupport::Noti fi cations.instrument "duration.metrics", key: "stripe.transaction" do adapter.charge amount

    end Start Finish Block guides.rubyonrails.org/active_support_instrumentation.html alchemists.io
  6. Guidelines • Use for light weight ancillary tasks only. •

    Use for logging, metrics, etc. guides.rubyonrails.org/active_support_instrumentation.html alchemists.io
  7. Guidelines • Use for light weight ancillary tasks only. •

    Use for logging, metrics, etc. • Keep subscribers small and simple. guides.rubyonrails.org/active_support_instrumentation.html alchemists.io