Application error related to telemetry

I’m using elixir version

Elixir 1.10.3 (compiled with Erlang/OTP 21)

And

Phoenix

{:phoenix, "~> 1.4.16"}

I’m getting error related to telemetry I think. What should I do in this case

12:57:13.406 [info]  Application phoenix exited: exited in: Phoenix.start(:normal, [])
    ** (EXIT) exited in: :gen_server.call(:telemetry_handler_table, {:insert, {Phoenix.Logger, [:phoenix, :channel_handled_in]}, [[:phoenix, :channel_handled_in]], #Function<8.24565029/4 in Phoenix.Logger.install/0>, :ok})
        ** (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

12:57:13.408 [info]  Application eex exited: :stopped
** (MatchError) no match of right hand side value: {:error, {:phoenix, {:bad_return, {{Phoenix, :start, [:normal, []]}, {:EXIT, {:noproc, {:gen_server, :call, [:telemetry_handler_table, {:insert, {Phoenix.Logger, [:phoenix, :channel_handled_in]}, [[:phoenix, :channel_handled_in]], #Function<8.24565029/4 in Phoenix.Logger.install/0>, :ok}]}}}}}}}
    (phoenix 1.4.17) lib/mix/tasks/compile.phoenix.ex:11: Mix.Tasks.Compile.Phoenix.run/1
    (mix 1.10.3) lib/mix/task.ex:330: Mix.Task.run_task/3
    (mix 1.10.3) lib/mix/tasks/compile.all.ex:76: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.10.3) lib/mix/tasks/compile.all.ex:56: Mix.Tasks.Compile.All.do_compile/4
    (mix 1.10.3) lib/mix/tasks/compile.all.ex:27: anonymous fn/2 in Mix.Tasks.Compile.All.run/1
    (mix 1.10.3) lib/mix/tasks/compile.all.ex:43: Mix.Tasks.Compile.All.with_logger_app/2
    (mix 1.10.3) lib/mix/task.ex:330: Mix.Task.run_task/3
    (mix 1.10.3) lib/mix/tasks/compile.ex:96: Mix.Tasks.Compile.run/1
    (mix 1.10.3) lib/mix/task.ex:330: Mix.Task.run_task/3
    (mix 1.10.3) lib/mix/cli.ex:82: Mix.CLI.run_task/2
    (elixir 1.10.3) lib/code.ex:926: Code.require_file/2

Does your application.ex add the Telemetry child process in the start function? You should have something like this:

defmodule MyApp.Application do
use Application

  def start(_type, _args) do
    children = [
      # Start the Ecto repository
      MyApp.Repo,
      # Start the Telemetry supervisor
      MyApp.Telemetry, #<--- YOU NEED SOMETHING LIKE THIS.
      # Start the PubSub system
      {Phoenix.PubSub, name: MyApp.PubSub},
      # Start the Endpoint (http/https)
      MyAppWeb.Endpoint
      # Start a worker by calling: MyApp.Worker.start_link(arg)
      # {MyApp.Worker, arg}
    ]

    # See https://hexdocs.pm/elixir/Supervisor.html
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end

I haven’t added telemetry in my child process but if I do should I clean my deps and build and then do mix compile?

Because I added this

MyApp.Telemetry

But it did not change anything

Apologies - it should be MyAppWeb.Telemetry where MyApp depends on what you named the project when you created it. You should have a file called telemetry.ex in your web application folder (next to router.ex). If not, it is probably easier to create a new web application using the latest version of the Phoenix generators with the -live option. This will set up all the right files. You can then look through them and work out how to bring it back into your own application.

EDIT: This article explains it step by step: https://medium.com/@marcdel/adding-custom-metrics-to-a-phoenix-1-5-live-dashboard-1b21a8df5cf1

Thanks. I think it was related to old phoenix version. I installed it with new phoenix app and it worked

1 Like