scoutapp / scout_apm_elixir

ScoutAPM Elixir Agent. Supports Phoenix and other frameworks.
https://scoutapm.com
Other
36 stars 20 forks source link

Ecto 3 / Phoenix 1.4 Issue #71

Closed john-griffin closed 5 years ago

john-griffin commented 5 years ago

We get the following error when booting the app using the new Ecto 3 telemetry integration.

remote: ** (exit) exited in: GenServer.call(Telemetry.HandlerTable, {:get_and_update, #Function<1.77997741/1 in Telemetry.HandlerTable.insert/5>}, 5000)
remote:     ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
remote:     (elixir) lib/gen_server.ex:914: GenServer.call/3
cschneid commented 5 years ago

It looks like the Telemetry application isn't started at the point the Scout integration call happens. This is odd, since I think the dependencies between apps should be YourApp -> EctoSql -> Telemetry, so they all should be started before the Scout register call happens.

Can you check for the telemetry app running at the startup of your app, and see if that's not starting for some reason?

@mitchellhenke - any other ideas?

john-griffin commented 5 years ago

How do I know if the Telemetry app is running? The only changes we made were to upgrade the packages and switch to the new style integration as suggested in the docs.

cschneid commented 5 years ago

Application.loaded_applications() and Application.started_applications() can tell you what the VM knows about, and has actually started.

It sounds like you upgraded your application - can you paste the list of applications you have in your mix.exs file? applications and deps and so on.

This elixir forum thread may be relevant: https://elixirforum.com/t/upgrading-to-ecto-3-and-ecto-sql-no-ecto-sql-otp-application-running/17760/4

etehtsea commented 5 years ago

The same problem here. Didn't dig into it much but it seems to work when I run mix phx.server and not for db tasks (like mix ecto.migrate) nor mix test.

telemetry appears in the list for mix phx.server and not when I run mix test.

mitchellhenke commented 5 years ago

@etehtsea can you gist your dependencies and extra_applications in your mix.exs?

if you don't have ecto_sql or telemetry in your direct dependencies and they aren't being started in extra_applications, you may see the above issue.

john-griffin commented 5 years ago

We recently upgraded to elixir 1.8.1 and scout_apm 0.4.11. The telemetry and ecto_sql apps are running but we are still not seeing any database traces in Scout.

cschneid commented 5 years ago

@john-griffin would you mind emailing support@scoutapp.com with your Scout ecto instrumentation call. It'll be easier to give support there, rather than here on Github.

mitchellhenke commented 5 years ago

Closing this issue for now as there haven't been any recent reports. If you do run into this, please let us know!

wcpines commented 5 years ago

I seem to also be hitting this error.

I have :telemetry, :ecto_sql and :new_relic_agent in my Application.loaded_applications() and Application.started_applications() when run from iex -S mix.

I can post a gist with my setup or email. @cschneid any preferences? Please and thank you 😄

mitchellhenke commented 5 years ago

@wcpines Do you have the handler being added in your Repo's init callback or in your Application's start callback? I think previous documentation suggested putting it in the Repo callback, but it should be in the Application start. 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
wcpines commented 5 years ago

Solved. Thank you 😍