Elixir Agent
Requirements
Our Elixir agent supports Phoenix 1.2.0+, Ecto 2.0+, and Elixir 1.4+.
Installation
Tailored instructions are provided within our user interface. General instructions for a Phoenix 1.3+ app:
1. Add the scout_apm
dependency.
Your mix.exs
file:
# mix.exs
def deps do
[{:phoenix, "~> 1.4.0"},
...
{:scout_apm, "~> 1.0"}]
end
If your Mixfile manually specifies applications
, :scout_apm
must be added:
# mix.exs
def application do
[mod: {YourApp, []},
applications: [..., :scout_apm]]
end
Shell:
mix deps.get
2. Download your customized config file, placing it at config/scout_apm.exs
.
Your customized config file is available within your Scout account. Inside the file, replace "YourApp"
with the app name you’d like to appear within Scout.
3. Integrate into your Phoenix app.
Instrument Controllers. In lib/your_app_web.ex
:
# lib/your_app_web.ex
defmodule YourApp.Web do
def controller do
quote do
use Phoenix.Controller
use ScoutApm.Instrumentation
...
Instrument Templates. In config/config.exs
:
# config/config.exs
config :phoenix, :template_engines,
eex: ScoutApm.Instruments.EExEngine,
exs: ScoutApm.Instruments.ExsEngine
4. Integrate Ecto
Using Ecto 2.x?. In config/config.exs
:
# config/config.exs
import_config "scout_apm.exs"
config :your_app, YourApp.Repo,
loggers: [{Ecto.LogEntry, :log, []},
{ScoutApm.Instruments.EctoLogger, :log, []}]
Using Ecto 3.x?. In lib/my_app/application.ex
:
# lib/my_app/application.ex
defmodule MyApp.Application do
use Application
def start(_type, _args) do
import Supervisor.Spec
children = [
# ...
]
:ok = ScoutApm.Instruments.EctoTelemetry.attach(MyApp.Repo)
# ...
Supervisor.start_link(children, opts)
end
end
5. Restart your app.
mix phx.server
Updating to the Newest Version
1. Ensure your mix.exs
dependency entry for scout_apm
is: {:scout_apm, "~> 0.0"}`
2.
mix deps.get scout_apm
3. Recompile and deploy.
Auto-Instrumented Libraries
Our install instructions walk through instrumenting the following libraries:
- Phoenix
- controllers
- views
- templates
- Ecto 2.0/3.0
- Slime Templates
See instrumenting common libraries for guides on instrumenting other Elixir libraries.