-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Ecto parallel preloads #915
Conversation
✔️ All good! |
I was wondering if there would be an easy way for (This is not a blocker, just a thought) |
Add the `Appsignal.Ecto.Repo` module to fix the Ecto parallel preload issue, making it easy to apply the workaround that was already found by [Elixir Forums][solution] users. After this change, customers can replace `use Ecto.Repo` in their Ecto repositories with `use Appsignal.Ecto.Repo`. This will configure Ecto so that it passes through the current span at invocation time as the telemetry options for the query, fixing the issue where parallel preload queries were lost because they took place in parallel processes where there was no current span. For customers who wish to customise their Ecto repo default options, which would override the `default_options/1` function implemented by `Appsignal.Ecto.Repo`, a workaround is provided by also exposing this function as `Appsignal.Ecto.Repo.default_options`, so customers can call it manually and merge its output with their own default options. [solution]: https://elixirforum.com/t/help-understanding-ecto-telemetry-events-according-to-appsignal/35957/3
cdb305d
to
ae09d17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a nice patch! I'm very excited that this is an add-on instead of a completely new implementation. 👍
.changesets/add-appsignal-ecto-repo-to-fix-parallel-preloads.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Tom de Bruijn <tom@tomdebruijn.com>
Fixes #603. See also https://github.com/appsignal/appsignal-docs/pull/1715. Use appsignal/test-setups#184 to test it.
Add the
Appsignal.Ecto.Repo
module to fix the Ecto parallel preload issue, making it easy to apply the workaround that was already found by Elixir Forums users.After this change, customers can replace
use Ecto.Repo
in their Ecto repositories withuse Appsignal.Ecto.Repo
. This will configure Ecto so that it passes through the current span at invocation time as the telemetry options for the query, fixing the issue where parallel preload queries were lost because they took place in parallel processes where there was no current span.For customers who wish to customise their Ecto repo default options, which would override the
default_options/1
function implemented byAppsignal.Ecto.Repo
, a workaround is provided by also exposing this function asAppsignal.Ecto.Repo.default_options
, so customers can call it manually and merge its output with their own default options.