{"id":13463274,"url":"https://github.com/pboling/rack-insight","last_synced_at":"2025-03-25T06:31:51.482Z","repository":{"id":4140502,"uuid":"5253462","full_name":"pboling/rack-insight","owner":"pboling","description":"Debugging toolbar for Rack applications implemented as middleware","archived":false,"fork":true,"pushed_at":"2016-04-27T20:46:14.000Z","size":1287,"stargazers_count":151,"open_issues_count":5,"forks_count":22,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-29T13:50:53.695Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://railsbling.com/retired_projects/rack-insight/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"LRDesign/logical-insight","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pboling.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-01T00:57:07.000Z","updated_at":"2024-10-19T18:28:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pboling/rack-insight","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboling%2Frack-insight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboling%2Frack-insight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboling%2Frack-insight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pboling%2Frack-insight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pboling","download_url":"https://codeload.github.com/pboling/rack-insight/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245414219,"owners_count":20611357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T13:00:49.487Z","updated_at":"2025-03-25T06:31:51.080Z","avatar_url":"https://github.com/pboling.png","language":"Ruby","funding_links":[],"categories":["Maintenance \u0026 Monitoring","Middleware","Ruby","Middlewares"],"sub_categories":["App Instrumentation"],"readme":"rack-insight will be merging back home into Rack Bug.\n\n@brynary and I have discussed it, and I will do the work to re-namespace Rack Insight.  Rack Insight, née Rack Bug, will be the basis of the next major release of Rack Bug.\n\nI will be the new maintainer of the project.\n\nRack::Insight\n=============\n\nSummary\n-----------\n\nRack::Insight adds a diagnostics toolbar to Rack apps. When enabled, it injects a floating div\nallowing exploration of logging, database queries, template rendering times, etc.  Rack::Insight\nstores debugging info over many requests, incuding AJAX requests.\n\n\n| Project                 |  Rack Insight   |\n|------------------------ | ----------------- |\n| gem name                |  rack-insight   |\n| license                 |  MIT              |\n| expert support          |  [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/peterboling?utm_source=github\u0026utm_medium=button\u0026utm_term=peterboling\u0026utm_campaign=github) |\n| download rank               |  [![Total Downloads](https://img.shields.io/gem/rt/rack-insight.svg)](https://rubygems.org/gems/rack-insight) |\n| version                 |  [![Gem Version](https://badge.fury.io/rb/rack-insight.png)](http://badge.fury.io/rb/rack-insight) |\n| dependencies            |  [![Dependency Status](https://gemnasium.com/pboling/rack-insight.png)](https://gemnasium.com/pboling/rack-insight) |\n| code quality            |  [![Code Climate](https://codeclimate.com/github/pboling/rack-insight.png)](https://codeclimate.com/github/pboling/rack-insight) |\n| inline documenation     |  [![Inline docs](http://inch-ci.org/github/pboling/rack-insight.png)](http://inch-ci.org/github/pboling/rack-insight) |\n| continuous integration  |  [![Build Status](https://secure.travis-ci.org/pboling/rack-insight.png?branch=master)](https://travis-ci.org/pboling/rack-insight)|\n| test coverage           |  [![Coverage Status](https://coveralls.io/repos/pboling/rack-insight/badge.png)](https://coveralls.io/r/pboling/rack-insight) |\n| homepage                |  [https://github.com/pboling/rack-insight][homepage] |\n| documentation           |  [http://rdoc.info/github/pboling/rack-insight/frames][documentation] |\n| author                  |  [Peter Boling](https://coderbits.com/pboling) |\n| Spread ~♡ⓛⓞⓥⓔ♡~      |  [![Endorse Me](https://api.coderwall.com/pboling/endorsecount.png)](http://coderwall.com/pboling) |\n| Working Example         | [On Rails 3.2.20](https://github.com/pboling/x-cascade_header_rails/tree/rails3) |\n\nFeatures\n--------\n\n* Password-based security\n* IP-based security\n* Rack::Insight instrumentation/reporting is broken up into panels.\n    * Panels in default configuration:\n        * Rails Info\n        * Timer\n        * Request Variables\n        * Cache\n        * Templates\n        * Log               (can configure which loggers to watch!)\n        * Memory\n        * SQL\n        * Active Record     (Thanks to [Kevin Glowacz](https://github.com/kjg) for the fix!)\n    * Other bundled panels:\n        * Sphinx (thanks to Oggy for updating this to the rack-insight panel API)\n        * Redis\n        * Speedtracer\n    * Panels under construction:\n        * Mongo\n    * The API for adding your own panels is simple and very powerful\n        * Consistent interface to instrument application code\n        * Consistent timing across panels\n        * Easy to add sub-applications for more detailed reports (c.f. SQLPanel)\n        * Ask me (pboling) if you need help with this.\n\nRails quick start\n---------------------------\n\nAdd this to your Gemfile:\n\n    gem \"rack-insight\"\n\nIn config/environments/development.rb, add:\n\n    config.middleware.use 'Rack::Insight::App',\n      :secret_key =\u003e 'someverylongandveryhardtoguesspreferablyrandomstring'\n\nAny environment with Rack::Insight loaded will have a link to \"Rack::Insight\" added to as\nthe last child of `\u003cbody\u003e` to normal responses.  Clicking that link will load the\ntoolbar.  It's set with an id of \"rack-insight-enabler\", so it can be styled\nto go somewhere more noticeable.  E.g. \"position: absolute; top: 0; left: 0\"\n\nUsing with non-Rails Rack apps\n------------------------------\n\nJust `use Rack::Insight::App` as any other middleware.  See the `SampleApp` in the\n`spec/fixtures` folder for an example Sinatra app.\n\nThis is a minimal setup:\n\n```\nclass SinatraExample \u003c Sinatra::Base\n  get '/' do\n    \u003c\u003c-HTML\n      \u003chtml\u003e\n        \u003chead\u003e\n        \u003c/head\u003e\n        \u003cbody\u003e\n          \u003cp\u003eStink o' Man\u003c/p\u003e\n        \u003c/body\u003e\n      \u003c/html\u003e\n    HTML\n  end\n\n  use Rack::Insight::App\n\nend\n```\n\n\nConfigure Rack::Insight\n---------------------\n\nPattern:\n\n    Rack::Insight::Config.configure do |config|\n      config[:option] = value\n    end\n\nOptions:\n\n    :logger - Can be set to any Ruby-esque Logger, examples include the Rails Logger, or the Ruby Logger (default).\n            If you do not set logger Rack::Insight defaults to the Ruby Logger.\n            You can configure it with additional options:\n            :log_file - The logdev parameter for the Ruby Logger (a file path, an IO, like STDOUT, or STDERR, etc)\n            :log_level - The maximum severity at which things should be logged.\n\n    :rails_log_copy - If you are setting :logger to the Rails Logger, you should set this to false (default is true).\n\n    :verbosity - true is default.\n               true is equivalent to relying soley on the logger's log level to determine if a message is logged.\n               Other potential values are:\n                  anything falsey =\u003e no logging at all\n                  Rack::Insight::Config::VERBOSITY[*level*] where *level* is one of:\n                    :debug, :high, :med, :low, :silent\n\n    :panel_load_paths =\u003e [File::join('rack', 'insight', 'panels')] (default)\n                         See *Configuring custom panels* section for example usage\n\n    :panel_configs =\u003e This is a nested config, se below:\n\n      Panel level configuration options for all panels, including extension gems.\n      Currently this is implemented in the log_panel, and configured as:\n\n        Rack::Insight::Config.configure do |config|\n          # The following two lines have the same result\n          config[:panel_configs][:log] = {:probes =\u003e {'Logger' =\u003e [:instance, :add]}}\n          config[:panel_configs][:log] = {:probes =\u003e ['Logger', :instance, :add]}\n        end\n\n      Example:  If you want all of your log statements in Rails to be traced twice by Rack::Insight,\n                this will do that because ActiveSupport::BufferedLogger utilizes Logger under the hood:\n\n        config[:panel_configs][:log_panel] = {:probes =\u003e {\n                \"ActiveSupport::BufferedLogger\" =\u003e [:instance, :add],\n                \"Logger\" =\u003e [:instance, :add]\n        }}\n\n    :database =\u003e a hash.  Keys :raise_encoding_errors, and :raise_decoding_errors are self explanatory\n                 :raise_encoding_errors\n                     When set to true, if there is an encoding error (unlikely)\n                     it will cause a 500 error on your site.  !!!WARNING!!!\n                 :raise_decoding_errors\n                     The bundled panels should work fine with :raise_decoding_errors set to true or false\n                     but custom panel implementations may prefer one over the other\n                     The bundled panels will capture these errors and perform admirably.\n                     Site won't go down unless a custom panel is not handling the errors well.\n\nConfigure Middleware\n--------------------\n\nSpecify the set of panels you want, in the order you want them to appear:\n\n    require \"rack-insight\"\n\n    ActionController::Dispatcher.middleware.use \"Rack::Insight::App\",\n      :secret_key =\u003e \"someverylongandveryhardtoguesspreferablyrandomstring\",\n      :panel_files =\u003e %w(\n        timer_panel\n        active_record_panel\n        request_variables_panel\n        redis_panel\n        templates_panel\n        cache_panel\n        log_panel\n        memory_panel\n        sphinx_panel\n      )\n\nBy default panel files are looked up by prepending \"rack/insight/panels/\" and requiring them.\nSubclasses of Rack::Insight::Panel are loaded and added to the toolbar.  This makes\nit easier to work with the configuration and extend Rack::Insight with plugin gems.\n\nIf you need to customize the load paths where Rack::Insight will look for panels you can configure the load paths in an\ninitializer, or in your gem prior to requiring your panels.  Example config/initializers/rack_insight.rb:\n\n    Rack::Insight::Config.configure do |config|\n\n      # Note: The parent directory of the 'special' directory must already be in Ruby's load path.\n      config[:panel_load_paths] = File.join('special','path')\n\n      # Example 1: Do not load any of the regular Rack::Insight panels:\n      config[:panel_load_paths] = File.join('my','custom','panel','directory')\n\n      # Example 2: Add your custom path to the existing load paths, to have your panels join the party!\n      config[:panel_load_paths] \u003c\u003c 'custom/panels'\n\n    end\n\nWhen you create custom panels use the render_template method and pass it the path to the view to be rendered\n*relative to the panel load path you added above*:\n\n    # with Example #2 from above, will try to render 'custom/panels/thunder_panel/views/thor.html.erb'\n    render_template 'thunder_panel/views/thor'\n\nRunning Rack::Insight in staging or production\n----------------------------------------------\n\nWe have have found that Rack::Insight is fast enough to run in production for specific troubleshooting efforts.\n\n### Configuration ####\n\nAdd the middleware configuration to an initializer or the appropriate\nenvironment files, taking the rest of this section into consideration.\n\n### Security ####\n\nRestrict access to particular IP addresses:\n\n    require \"ipaddr\"\n\n    ActionController::Dispatcher.middleware.use \"Rack::Insight::App\"\n      :secret_key =\u003e \"someverylongandveryhardtoguesspreferablyrandomstring\",\n      :ip_masks   =\u003e [IPAddr.new(\"2.2.2.2/0\")]\n\nRestrict access using a password:\n\n    ActionController::Dispatcher.middleware.use \"Rack::Insight::App\",\n      :secret_key =\u003e \"someverylongandveryhardtoguesspreferablyrandomstring\",\n      :ip_masks   =\u003e false, # Default is 127.0.0.1\n      :password   =\u003e \"yourpassword\"\n\n#### custom file path for the request recording database ####\n\nRack::Insight uses SQLite to store data across requests, and outputs a database\nfile in the root directory. If you need the file to be created at another\nlocation (i.e. Heroku), you can pass a custom file path.\n\nPlease report back if you have success with this on Heroku!\n\n    ActionController::Dispatcher.middleware.use \"Rack::Insight::App\"\n      :secret_key =\u003e \"someverylongandveryhardtoguesspreferablyrandomstring\",\n      :database_path =\u003e \"tmp/my_insight_db.sqlite\"\n\nMagic Panels\n------------\n\nYou can now create a fully functional new panel with a simple class definition:\n\n    module Rack::Insight\n      class FooBarPanel \u003c Panel\n        self.is_magic = true\n      end\n    end\n\nSetup the probes for the magic panel in a `before_initialize` block in your application.rb as follows:\n\n    # Assuming there is a FooBar class with instance methods: foo, bar, cheese, and ducks\n    Rack::Insight::Config.configure do |config|\n      # Not :foo_bar_panel or 'FooBarPanel'... :foo_bar\n      config[:panel_configs][:foo_bar] = {:probes =\u003e {'FooBar' =\u003e [:instance, :foo, :bar, :cheese, :ducks]}}\n    end\n\nCustom Panels\n-------------\n\nSee Magic Panels above, remove the is_magic declaration, and add your own methods.\nLook at the panels bundled with this gem for pointers.  Here are some important methods to watch for:\n\n* initialize\n* after_detect\n* content_for_request(number)\n\nAuthors\n-------\n\n- Maintained by [Peter Boling](mailto:peter.boling@gmail.com)\n  - Contributions from [Kevin Glowacz](https://github.com/kjg) (Fixed Active Record Panel), [Piotr Usewicz](https://github.com/pusewicz) (Use on instead of live), [Nate Greene](https://github.com/natejgreene) (javascript fix), [George Ogata](https://github.com/oggy) (Fixed Redis \u0026 Sphinx panels and added AJAX support to them), and [Alif Rachmawadi](https://github.com/subosito) (persistent toolbar position)\n- Based on LogicalInsight by Judson Lester\n  - Contributions from Luke Melia, Joey Aghion, Tim Connor, and more\n  - Which in turn was based on Rack::Bug by Bryan Helmkamp\n\nA History of Forking\n--------------------\n\nRack::Insight began life as an fork of Logical::Insight by LRDesign.\n\n* I started a fork because:\n    * LogicalInsight was namespaced as \"Insight\"\n        * Causing namespace collisions everywhere I have an Insight model.  I had to re-namespace all the code.\n    * I also needed to build a few extension gems with additional panels, which didn't fully work in LI\n        * Added the Config class to allow for custom panel load paths\n          and many other extensions that don't work in the *use Middleware* declaration.\n\nIt should be *even* easier to extend than LogicalInsight was, because extension gems can access the Config class\nand truly bolt-on cleanly.\n\nHaving made really significant architectural changes, I'll be keeping Rack::Insight\na separate project for the foreseeable future.\n\n* Forked From: [logical-insight](http://github.com/LRDesign/logical-insight)\n* Which Was Forked From: [rack-bug](http://github.com/brynary/rack-bug)\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.\n6. Create new Pull Request\n\n## Versioning\n\nThis library aims to adhere to [Semantic Versioning 2.0.0][semver].\nViolations of this scheme should be reported as bugs. Specifically,\nif a minor or patch version is released that breaks backward\ncompatibility, a new version should be immediately released that\nrestores compatibility. Breaking changes to the public API will\nonly be introduced with new major versions.\n\nAs a result of this policy, you can (and should) specify a\ndependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.\n\nFor example:\n\n    spec.add_dependency 'rack-insight', '~\u003e 0.5'\n\nThanks\n------\n\nRack::Insight owes a lot to both LogicalInsight and Rack::Bug, as the basis projects.  There's a lot of smart\nin there.  Many thanks to Judson, and Bryan for building them.\n\nInspiration for Rack::Bug is primarily from the Django debug toolbar.\nAdditional ideas from Rails footnotes, Rack's ShowException middleware, Oink,\nand Rack::Cache\n\nLicense\n-------\n\nMIT. See LICENSE in this directory.\n\nNotes\n-----\n\nLegacy files: would like to re-include them, but they need work\n\n    lib/rack/insight/views/panels/mongo.html.erb\n    lib/rack/insight/panels/mongo_panel/mongo_extension.rb\n    lib/rack/insight/panels/mongo_panel/stats.rb\n    lib/rack/insight/panels/mongo_panel.rb\n\nThis one is mostly just a curiosity\n    lib/rack/insight/panels/speedtracer_panel/profiling.rb\n\n[semver]: http://semver.org/\n[pvc]: http://docs.rubygems.org/read/chapter/16#page74\n[railsbling]: http://www.railsbling.com\n[peterboling]: http://www.peterboling.com\n[documentation]: http://rdoc.info/github/pboling/rack-insight/frames\n[homepage]: https://github.com/pboling/rack-insight\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pboling/rack-insight/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpboling%2Frack-insight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpboling%2Frack-insight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpboling%2Frack-insight/lists"}