GithubHelp home page GithubHelp logo

classicvalues / aroi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from instructure/aroi

0.0 1.0 0.0 18 KB

(A)ctive (R)ecord (O)bject (I)nstrumenter

License: MIT License

Ruby 95.40% Shell 4.60%

aroi's Introduction

aroi

Build Status

(A)ctive (R)ecord (O)bject (I)nstrumenter

Adds ActiveSupport::Notifications instrument calls to the creation of any ActiveRecord object.

Usage

Include the gem

gem 'aroi'
```

Bundle your app and add a rails initializer

```` ruby
# config/initializers/aroi.rb

Aroi::Instrumentation.instrument_creation!

ActiveSupport::Notifications.subscribe(/instance.active_record/) do |name, start, finish, id, payload|
  # name, start, finish, id are all the same as usual for notifications
  puts "Created a #{payload[:name]} object"
end

aroi will dispatch 'instance.active_record' any time an ActiveRecord object is instantiated.

See the ActiveSupport::Notifications docs for more information on how to subscribe to instrumented notifications.

Why

Rails 3 brought about ActiveSupport::Notifications as a way to subscribe to different actions that happen within your rails application. You can use it to instrument how long a controller action takes, how much of that time was spent creating views verses querying the DB. At times it may be worth instrumenting the number of ActiveRecord objects that have been created per controller action. This gem provides the foundation to doing so.

Credit

Heavily inspired by Oink. oink does some great things with logging. We borrow some of those ideas but fire off ActiveSupport::Notifications instead of logging.

Contributing

  1. Fork it ( https://github.com/instructure/aroi/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

aroi's People

Contributors

ccutrer avatar crwang avatar knomedia avatar maneframe avatar simonista avatar tierra avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.