# 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/perf_agent) [![circle.ci builds](https://circleci.com/gh/perflabs/phoenix-perf/tree/master.svg?style=shield&circle-token=21f056185e48e4d08cc62909f972ae235affacd8)](https://circleci.com/gh/perflabs/phoenix-perf)
`perf_agent` is a plug that will record timing and status codes 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
* Add the agent to your list of dependencies in `mix.exs` via Hex
```elixir
def deps do
[{:perf_agent, "~> 0.1.6"}]
end
```
* Run `mix deps.get` in your Terminal to install all dependencies
* Ensure `perf_agent` is started before your application
```elixir
def application do
[applications: [:perf_agent]]
end
```
* Add your Perf API Key to your `config.exs`
```elixir
config :perf_agent, api_key: "PERF_API_KEY"
```
* Add the plug to a pipeline in your router
```elixir
defmodule MyApp.Router do
use MyApp.Web, :router
pipeline :api do
plug :accepts, ["json"]
plug PerfAgent.Plug.Phoenix
end
scope "/api/v1", MyApp do
pipe_through :api
end
end
```
* In this example we've added it to an API pipeline