Giter Site home page Giter Site logo

notable's Introduction

Notable

๐ŸŒŸ ๐ŸŒŸ ๐ŸŒŸ

Notable tracks notable requests and background jobs and stores them in your database. What makes a request or job notable? There are a number of default situations, but ultimately you decide what interests you.

By default, Notable tracks:

  • errors
  • 404s
  • slow requests and jobs
  • timeouts
  • validation failures
  • CSRF failures
  • unpermitted parameters
  • blocked and throttled requests

You can track custom notes as well.

๐ŸŠ Battle-tested at Instacart

Build Status

Installation

Add this line to your applicationโ€™s Gemfile:

gem "notable"

And run:

rails generate notable:requests
rails generate notable:jobs
rails db:migrate

To explore the data, check out Blazer.

How It Works

A Notable::Request is created for:

A Notable::Job is created for:

  • errors
  • slow jobs
  • validation failures

Create a custom note inside a request or job with:

Notable.track("Note Type", "Optional extra info")

Customization

Disable tracking in certain environments

Notable.enabled = Rails.env.production?

Requests

Set slow threshold

Notable.slow_request_threshold = 5.seconds

Custom user method

Notable.user_method = lambda do |env|
  env["warden"].try(:user) || env["action_controller.instance"].try(:current_visit)
end

Custom track method

Notable.track_request_method = lambda do |data, env|
  Notable::Request.create!(data)
end

Skip tracking CSRF failures

skip_before_action :track_unverified_request

Anonymize IP addresses

Notable.mask_ips = true

Jobs

Set slow threshold

Notable.slow_job_threshold = 60.seconds

To set a threshold for a specific job, use:

class CustomJob < ApplicationJob
  def notable_slow_job_threshold
    5.minutes
  end
end

Custom track method

Notable.track_job_method = lambda do |data|
  Notable::Job.create!(data)
end

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/notable.git
cd notable
bundle install
bundle exec rake test

notable's People

Contributors

0duaht avatar ankane avatar dhnaranjo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notable's Issues

Ruby 2.7 - Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call

With Ruby 2.7 there is a problem using the belongs_to association:

/Users/laykou/.rvm/gems/ruby-2.7.1/gems/notable-0.3.0/app/models/notable/request.rb:5: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/laykou/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.1/lib/active_record/associations.rb:1657: warning: The called method `belongs_to' is defined here

Could not find table 'blazer_connections'

In an attempt to access my admin, I received this error:

"ActiveRecord::StatementInvalid at /
Could not find table 'blazer_connections'"

Here were the codes I used:

gem 'notable'
rails generate notable:requests
rails generate notable:jobs # optional
rake db:migrate

Thanks!

NotableJob blank despite using Sidekiq

Do I have to manually turn on NotableJobs as the table is empty?

I'm using Sidekiq Pro, and have tried testing it by creating errors including validation issues.

relation "requests" does not exist

#6 When we run "rake db:migrate", we get the error:

    PG::UndefinedTable: ERROR:  relation "requests" does not exist
: CREATE TABLE "notable_requests" ("id" serial primary key, "note_type" character varying , "note" text , "user_id" integer , "user_type" character varying , "action" text , "status" integer , "url" text , "request_id" character varying , "ip" character varying , "user_agent" text , "referrer" text , "params" text , "request_time" decimal , "created_at" timestamp , CONSTRAINT fk_notable_requests_user_id FOREIGN KEY ("user_id") REFERENCES "users" ("id"), CONSTRAINT fk_notable_requests_request_id FOREIGN KEY ("request_id") REFERENCES "requests" ("id"))
/Users/andrewkelley/Documents/websites/frontend/db/migrate/20170724194710_create_notable_requests.rb:3:in `change'
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "requests" does not exist
: CREATE TABLE "notable_requests" ("id" serial primary key, "note_type" character varying , "note" text , "user_id" integer , "user_type" character varying , "action" text , "status" integer , "url" text , "request_id" character varying , "ip" character varying , "user_agent" text , "referrer" text , "params" text , "request_time" decimal , "created_at" timestamp , CONSTRAINT fk_notable_requests_user_id FOREIGN KEY ("user_id") REFERENCES "users" ("id"), CONSTRAINT fk_notable_requests_request_id FOREIGN KEY ("request_id") REFERENCES "requests" ("id"))
/Users/andrewkelley/Documents/websites/frontend/db/migrate/20170724194710_create_notable_requests.rb:3:in `change'
PG::UndefinedTable: ERROR:  relation "requests" does not exist
/Users/andrewkelley/Documents/websites/frontend/db/migrate/20170724194710_create_notable_requests.rb:3:in `change'

The issue is being caused by the migration with the line "t.string :request_id"

Mongoid support

I have Rails 4.1.8 with Mongoid 4.0.2. I get this when I rackup:
NoMethodError: undefined method `enabled' for Notable:Module

Does Notable only work with ActiveRecord?

Valid column type for notable_requests.ip column

PostgreSQL is the most popular database choice in the Rails world, as far as I can see you guys also use it extensively.

There are multiple advantages of using the inet column type for IP addresses, those help in the further problems investigations that seem very useful considering what you track with Notable (which is awesome by the way).

You can read some simple examples of those in Using PostgreSQL cidr and inet types, operators, and functions article.

If you decide to go with this, take a look at how it's implemented in the Devise gem.

Cheers, and keep up the good work @ankane, you create one of my favorite open-sourced Ruby gems ๐Ÿ‘

undefined method `verified_request?'

When using Railsโ€™s config.api_only = true feature, you get the error:

undefined method `verified_request?'

app/controllers/application_controller.rb

class ApplicationController < ActionController::API
    protect_from_forgery with: :null_session
end

Default logging not working

Rails 4.2.4, Ruby 2.2.3, running on my production instance of Ubuntu 14.04 at Digital Ocean.

Latest gem version of notable, no settings specified, mounting notable-web at as shown with devise (checks user#admin? == true)

Nothing.. no logging..

Purposefully hitting 404s, etc.

Notable.enabled == true when asked in the console

Feature: Ability to disable features

In the Gem todo list, was it referring to the website's features if they're using Rollbar or the gem's feature? I'm thinking about how to disable a site's feature (ex: one of the payment options) if it's causing errors due to a third party api.

Consider a request-local and/or model-local 'skip noting model validation errors'

We have some GET requests which return meta data which check if certain actions on the returned resources are valid. Since these produce active model validation errors, we are getting false positives on these requests.

Rather than dig into the notable internals to disable these, I took a heavier hammer and added to our base controller.

  after_action :clear_non_notable_notes, on: [:index, :show]

  def clear_non_notable_notes
    Notable.clear_notes
  end

would you accept a PR to conditionally disable the model validations by either/and model-specific flag, request-specific flag?

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.