https://github.com/taskrabbit/route_counter
Count on your Rails routes.
https://github.com/taskrabbit/route_counter
Last synced: 9 months ago
JSON representation
Count on your Rails routes.
- Host: GitHub
- URL: https://github.com/taskrabbit/route_counter
- Owner: taskrabbit
- License: mit
- Created: 2014-12-17T01:19:09.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-17T04:24:37.000Z (about 11 years ago)
- Last Synced: 2025-05-25T02:19:44.832Z (10 months ago)
- Language: Ruby
- Size: 191 KB
- Stars: 2
- Watchers: 36
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RouteCounter
When you want to know how much your routes are being used.
This is particularly useful if you are wondering if they are used at all.
## Installation
Add this line to your application's Gemfile:
gem 'route_counter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install route_counter
Enable the recording in an initializer and insert the middleware:
```ruby
RouteCounter.config.enabled = true
Rails.application.config.middleware.use RouteCounter::Middleware
```
Add to Rakefile:
```ruby
require "route_counter/tasks"
```
## Usage
Check what's been used.
```bash
$ bundle exec rake routes:count:local
```
All of this gets stored on your disk. If you want to clear it out.
```bash
$ bundle exec rake route_counter:local:clear
```
## Global Usage
You might want to see the counts across your servers.
This will use Redis to aggregate info from across all of them.
First, you'll need to tell it where Redis is:
```ruby
RouteCounter.config.redis = Redis.new(connection_hash)
```
Then, you can clear out the remote store.
Or not to be cumulative to last time you took a snapshot
```bash
$ bundle exec rake route_counter:global:clear
```
Then take a snapshot. You can do this in parallel on all of your servers (with Capistrano for example).
```bash
$ bundle exec rake route_counter:snapshot
```
Then on one of the servers you can run to use the global numbers
```bash
$ bundle exec rake routes:count:global
```
## TODO
* could make a middleware (or config option) that wrote directly to Redis
* should it record more info about the request?
* configurable error handler