README.md

# PerfAgent [![Hex pm](http://img.shields.io/hexpm/v/perf_agent.svg?style=flat)](https://hex.pm/packages/perf_agent) [![hex.pm downloads](https://img.shields.io/hexpm/dt/perf_agent.svg?style=flat)](https://hex.pm/packages/httpoison)

`perf_agent` is a plug that will record timing and status of the connections in the phoenix framework and send the data to Perf.
We then run analytics on that data to generate metrics and alerts.

Right now perf is in private beta but if you're interested in an API key, feel free to email us at [hi@perf.sh](hi@perf.sh)

## Installation

Perf agent is available via Hex.

  1. Add `perf_agent` to your list of dependencies in `mix.exs`:

    ```elixir
    def deps do
      [{:perf_agent, "~> 0.1.1"}]
    end
    ```

Then run `$ mix deps.get`

  2. Ensure `perf_agent` is started before your application:

    ```elixir
    def application do
      [applications: [:perf_agent]]
    end
    ```

Last step is to add the plug to a pipeline in your router, in this example we've added to an api pipeline.

  A plug that instruments Phoenix controllers and records their status and response times in Perf.
  ```elixir
  defmodule MyApp.Router do
    use Perf.Web, :router

    pipeline :api do
      plug :accepts, ["json"]
      plug PerfAgent.Plug.Phoenix
    end

    scope "/api/v1", MyApp do
        pipe_through :api
    end

  end
  ```