README.md in coach-0.5.2 vs README.md in coach-1.0.0

- old
+ new

@@ -11,10 +11,20 @@ - **Guarantees** - Work with a simple `provide`/`require` interface to guarantee that your middlewares load data in the right order when you first boot your app. - **Testability** - Test each middleware in isolation, with effortless mocking of test data and natural RSpec matchers. +# Installation + +To get started, just add Coach to your `Gemfile`, and then run `bundle`: + +```ruby +gem 'coach' +``` + +Coach works with Ruby versions 2.2 and onwards. + ## Coach by example The best way to see the benefits of Coach is with a demonstration. ### Mounting an endpoint @@ -282,21 +292,35 @@ [here](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html). | Event | Arguments | |-------------------------------|------------------------------------------------------- | -| `coach.handler.start` | `event(:middleware, :request)` | -| `coach.middleware.start` | `event(:middleware, :request)` | -| `coach.middleware.finish` | `start`, `finish`, `id`, `event(:middleware, :request)`| -| `coach.handler.finish` | `start`, `finish`, `id`, `event(:middleware, :request)`| -| `coach.request` | `event` containing request data and benchmarking | +| `start_handler.coach` | `event(:middleware, :request)` | +| `start_middleware.coach` | `event(:middleware, :request)` | +| `finish_middleware.coach` | `start`, `finish`, `id`, `event(:middleware, :request)`| +| `finish_handler.coach` | `start`, `finish`, `id`, `event(:middleware, :request)`| +| `request.coach` | `event` containing request data and benchmarking | -Of special interest is `coach.request`, which publishes statistics on an entire +Of special interest is `request.coach`, which publishes statistics on an entire middleware chain and request. This data is particularly useful for logging, and is our solution to Rails `process_action.action_controller` event emitted on controller requests. The benchmarking data includes information on how long each middleware took to process, along with the total duration of the chain. + +You can add additional metadata to the notifications published by Coach by calling the +`log_metadata` method from inside your Coach middlewares. + +``` +class Tracking < Coach::Middleware + requires :user + + def call + log_metadata(user_id: user.id) + next_middleware.call + end +end +``` # License & Contributing * Coach is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). * Bug reports and pull requests are welcome on GitHub at https://github.com/gocardless/coach.