+ defp setup_instrumenters do
+ require Prometheus.Registry
+
+ 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
+
+ Pleroma.Web.Endpoint.MetricsExporter.setup()
+ Pleroma.Web.Endpoint.PipelineInstrumenter.setup()
+ Pleroma.Web.Endpoint.Instrumenter.setup()
+ end
+
+ def enabled_hackney_pools do
+ [:media] ++
+ if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
+ [:federation]
+ else
+ []
+ end ++
+ if Pleroma.Config.get([Pleroma.Upload, :proxy_remote]) do
+ [:upload]
+ else
+ []
+ end
+ end
+
+ if Pleroma.Config.get(:env) == :test do
+ defp streamer_child, do: []
+ defp chat_child, do: []
+ else
+ defp streamer_child do
+ [%{id: Pleroma.Web.Streamer, start: {Pleroma.Web.Streamer, :start_link, []}}]
+ end
+
+ defp chat_child do
+ if Pleroma.Config.get([:chat, :enabled]) do
+ [
+ %{
+ id: Pleroma.Web.ChatChannel.ChatChannelState,
+ start: {Pleroma.Web.ChatChannel.ChatChannelState, :start_link, []}
+ }
+ ]
+ else
+ []
+ end
+ end
+ end
+
+ defp hackney_pool_children do
+ for pool <- enabled_hackney_pools() do
+ options = Pleroma.Config.get([:hackney_pools, pool])
+ :hackney_pool.child_spec(pool, options)
+ end