romul / newrelic.ex

NewRelic agent for Elixir
MIT License
64 stars 19 forks source link

Circular declaration #2

Closed renews closed 7 years ago

renews commented 7 years ago

I think you need to change

use NewRelic.Plug.Repo, repo: MyApp.Repo`

Looks like it is conflicting with the defined module.

defmodule MyApp.Repo do
  use Ecto.Repo, otp_app: :my app

  defmodule NewRelic do
    use NewRelic.Plug.Repo, repo: MyApp.Repo
  end
end

Gives this error

Compiling 36 files (.ex)                                                                                                               

== Compilation error on file lib/myapp/repo.ex ==                                                                                      
** (CompileError) lib/myapp/repo.ex:5: module MyApp.Repo.NewRelic.Plug.Repo is not loaded and could not be found                       
    (elixir) expanding macro: Kernel.use/2                                                                                             
    lib/olars/repo.ex:5: MyApp.Repo.NewRelic (module)                                                                                  
    (elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1    
romul commented 7 years ago

@renews Thank you for the report. Please, try to replace it with the following code:

  defmodule NewRelic do
    use Elixir.NewRelic.Plug.Repo, repo: MyApp.Repo
  end