Skip to content

ufirstgroup/spandex_ecto

 
 

Repository files navigation

SpandexEcto

CircleCI Inline docs Coverage Status Hex pm SourceLevel

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
# If your repo is called `MyApp.Repo`, use `[:my_app, :repo, :query]`
# If your repo is called `Foo.Bar.Baz`, use `[:foo, :bar, :baz, :query]`
:ok = :telemetry.attach("spandex-query-tracer-repo_name", [:my_app, :repo, :query], &SpandexEcto.TelemetryAdapter.handle_event/4, nil)

NOTE: If you are upgrading from Ecto 2, make sure to remove the loggers entry from your configuration after adding the :telemetry.attach.

About

Tools for integrating Ecto with Spandex

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%