akoutmos / prom_ex

An Elixir Prometheus metrics collection library built on top of Telemetry with accompanying Grafana dashboards
MIT License
577 stars 96 forks source link

Add supervisor start instructions #195

Closed Ninigi closed 1 year ago

Ninigi commented 1 year ago

If you start PromEx before the Endpoint, it will raise an error RuntimeError: ** (RuntimeError) could not find persistent term for endpoint at least once, until the Endpoint started.

It works, but can pollute your logs (and will be very annoying if you have something like AppSignal running in production)

Issue number: #194

coveralls commented 1 year ago

Coverage Status

Coverage: 79.135%. Remained the same when pulling 7fe5e4a7013e90f9b2680a43490b2af457c16ed1 on Ninigi:master into b206d1831dbc7df8c87c51eb9cbb02bbd91d3a4e on akoutmos:master.

ivanovv commented 1 year ago

this is kinda questionable...

Here https://github.com/akoutmos/prom_ex/blob/6a002fb029cf00eeadfcfef7ce984cd7a0f83493/lib/prom_ex/plugins/ecto.ex#L4-L5

we say that PromEx should be started before Repo module.

Yet, this PR suggests staring PromEx after Endpoint which is usually started as the last thing since it quite often depends on other processes being already running.

Even the freshly generated phoenix app (source: https://www.phoenixdiff.org/?source=1.6.15&source_variant=default&target=1.7.2&target_variant=default) looks like this:

  def start(_type, _args) do
    children = [
      # Start the Telemetry supervisor
      SampleAppWeb.Telemetry,
      # Start the Ecto repository
      SampleApp.Repo,
      # Start the PubSub system
      {Phoenix.PubSub, name: SampleApp.PubSub},
      # Start Finch
      {Finch, name: SampleApp.Finch},
      # Start the Endpoint (http/https)
      SampleAppWeb.Endpoint
      # Start a worker by calling: SampleApp.Worker.start_link(arg)
      ...

Am I missing something?