new_relic v0.1.2 NewRelic.Plug.Repo

Defines a module that provides instrumented methods for a standard Ecto.Repo.

defmodule MyApp.Repo do
  use Ecto.Repo, otp_application: :my_app

  defmodule NewRelic do
    use NewRelic.Plug.Repo, repo: MyApp.Repo
  end
end

Anywhere that the original repository is used to make a database call, the wrapper module can be used by adding a Plug.Conn as the first argument. For example, MyApp.Repo.all(User) can be replaced with MyApp.Repo.NewRelic.all(conn, User). No changes are needed for transaction() and rollback(). The Plug.Conn that's used with query methods must be one that was setup by NewRelic.Plug.Phoenix.