Fix prometheus-ecto error when not configured
authorAaron Tinio <aptinio@gmail.com>
Mon, 20 May 2019 23:30:18 +0000 (07:30 +0800)
committerAaron Tinio <aptinio@gmail.com>
Mon, 20 May 2019 23:30:18 +0000 (07:30 +0800)
lib/pleroma/application.ex

index eeb415084041cdec1e212942a9d75f9b6e94a38e..dab45a0b2b66bc47a2d6de25e760235ae6fd06a9 100644 (file)
@@ -131,19 +131,22 @@ defmodule Pleroma.Application do
   defp setup_instrumenters do
     require Prometheus.Registry
 
-    :ok =
-      :telemetry.attach(
-        "prometheus-ecto",
-        [:pleroma, :repo, :query],
-        &Pleroma.Repo.Instrumenter.handle_event/4,
-        %{}
-      )
+    if Application.get_env(:prometheus, Pleroma.Repo.Instrumenter) do
+      :ok =
+        :telemetry.attach(
+          "prometheus-ecto",
+          [:pleroma, :repo, :query],
+          &Pleroma.Repo.Instrumenter.handle_event/4,
+          %{}
+        )
+
+      Pleroma.Repo.Instrumenter.setup()
+    end
 
     Prometheus.Registry.register_collector(:prometheus_process_collector)
     Pleroma.Web.Endpoint.MetricsExporter.setup()
     Pleroma.Web.Endpoint.PipelineInstrumenter.setup()
     Pleroma.Web.Endpoint.Instrumenter.setup()
-    Pleroma.Repo.Instrumenter.setup()
   end
 
   def enabled_hackney_pools do