SpandexEcto
Tools for integrating Ecto with Spandex
Limitations
Due to some recent changes in Ecto, we can no longer effectively trace the execution of parallel preloads. All other queries work fine, but until we figure something out that leverages either telemetry or until the task feature listed here is added to the language, we won't be able to support tracing parallel preloads.
Installation
Add spandex_ecto to your list of dependencies in mix.exs:
def deps do
[
{:spandex_ecto, "~> 0.6.2"}
]
end
Configuration
config :spandex_ecto, SpandexEcto.EctoLogger,
service: :ecto, # Optional
tracer: MyApp.Tracer, # Required
For Ecto 2
# Be aware that this is a *compile* time configuration. As such, if you change this you
# may need to `mix compile --force` and/or `mix deps.compile --force ecto`
config :my_app, MyApp.Repo,
loggers: [{Ecto.LogEntry, :log, [:info]}, {SpandexEcto.EctoLogger, :trace, ["database_name"]}]
For Ecto 3
# in application.ex
:telemetry.attach("spandex-query-tracer", [:my_app, :repo_name, :query], &SpandexEcto.TelemetryAdapter.handle_event/4, nil)
NOTE: If you are upgrading from Ecto 2, make sure to remove the
loggersentry from your configuration after adding the:telemetry.attach.
If your repo is not named like MyApp.Repo, you'll need to set :telemetry_prefix in your repo config:
config :my_app, MyApp.Something.RepoName,
telemetry_prefix: [:my_app, :repo_name]