TrackerHub::Request
Part of TrackerHub, Request is a gem tracking every requests on the backend side. Some keys will be filtered and the request data will finally be saved into a logfile. This logfile will be automatically managed and rotated by the logging gem.
Installation
Add this line to your application's Gemfile:
gem 'tracker_hub-request', git: '[email protected]:SparkHub/gs-tracking-requests.git'
And then execute:
$ bundle
Configuration (optional)
In an initializer, you can configure the tracker:
# ./config/initializers/request_tracker.rb
TrackerHub::Request.setup do |config|
config.app_version = '1.0'
config.required_keys = %w(my rack env keys to log)
config.logger = ActiveSupport::Logger.new('requests.log')
config.notification = TrackerHub::Request::Notification.new(TrackerHub::Request::Notification::HipChat.new('my_token', 'my_room', 'my_username'))
end
Note:
- logger
Here you can define your own configured logger. The default logger is logging. Feel free to add your own, or use another gem!
- notification
If an error occure, it will be catched and a notification will be sent to the service of your choice. The list of available services are defined here.
Usage
Add the middleware to your environment:
config.middleware.insert_after ActionDispatch::DebugExceptions, TrackerHub::Request::Middleware
Activate the TrackerHub by adding to your environment (or .env
):
$ TRACKER=true
Get your request logs:
$ tail -f ./log/tracker/requests.log
Running tests
To run tests:
$ bundle exec rake spec
Contributing
Bug reports and pull request are welcome on GitHub at https://github.com/SparkHub/gs-tracking-requests. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.