Coder Social home page Coder Social logo

narutosanjiv / rnotifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jiren/rnotifier

0.0 2.0 0.0 328 KB

Exceptions, Events, Alerts and Benchmarks catcher for ruby applications.

Home Page: www.rnotifier.com

License: MIT License

Ruby 100.00%

rnotifier's Introduction

Rnotifier

Events and Exception catcher libraray.

Build Status Coverage Status Code Climate

Installation

Add this line to your application's Gemfile:

gem 'rnotifier'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rnotifier

Usage

rnotifier install 'API-KEY'  # This will create 'config/rnotifier.yaml' file.

Config file options

environments: development,test #default is production
capture_code: true             #default false
ignore_exceptions: ActiveRecord::RecordNotFound,AbstractController::ActionNotFound,ActionController::RoutingError
ignore_bots: Googlebot

To test config

rnotifier test                 #this will send test exception to rnotifier.

Send exception with request manually

For this ':request' params require

Rnotifier.exception(exception, {:request => request, other_params => 'value'})

Add context data to exception

Rnotifier.context({user_email: current_user.email})

Send events and alerts

Rnotifier.event(:sign_up, {:username => 'Jiren', :email => '[email protected]', :using => 'facebook' })

Rnotifier.alert(:order_fail, {:user => 'Jiren', :product => 'PS3', :order_id => '321' })

You can also sends tags with 'event' and 'alert' i.e

Rnotifier.event(
  :sign_up, 
  {:username => 'Jiren', :email => '[email protected]', :using => 'facebook' },
  {:tags => ['newsletter']}
)

Benchmarking

  1. Code block benchamrking
Rnotifier.benchmark('sum') do
  (1..100).inject(0){|i, result| result =  result + i; result }
end
  1. Method benchmarking

    • For Instance object method
Paragraph.new.benchmark({args: true}).word_count(text)
  • For class method
Paragraph.benchmark({args: true}).word_count(text)
  • Using helper function
class Aggregator

  def error_count(options = {})
    # Code ...
  end
      
  # for instance method
  benchmark_it :error_count, :time_condition => 0.5

  def self.errors_by_date_range(start_date, end_date)
    # Code ...
  end

  # For class method
  benchmark_it :errors_by_date_range, :class_method => true

end
 Options: time_condition and class_method
  - For class method pass option ':class_method => true'
  1. Rails action In controller add following filter.
rnotifier_benchmarking # 

Above will capture benchamrk for all controller action.

For particular action

rnotifier_benchmarking only: [:index, :show]

# or 

rnotifier_benchmarking except: [:destroy]

With time condition
 rnotifier_benchmarking only: [:index, :show], time_condition: 0.8
To capture page load benchmarking on client side add following tag to your view in the end of your view or in footer
rnotifier_tag

Contributing

  1. Fork it
  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 new Pull Request

License

This is released under the MIT license.

rnotifier's People

Watchers

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