X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Ftelemetry.ex;h=b0385060004cebed9b1083adec11e626d9feccea;hb=99775886126ba35476db47ae116afb0f1dc2f0e6;hp=acb649421a8a8a217bd58eb2681dbd5607fc46f9;hpb=afab5585a08fb4402211c04fc7964ac27caca365;p=akkoma diff --git a/lib/pleroma/web/telemetry.ex b/lib/pleroma/web/telemetry.ex index acb649421..b03850600 100644 --- a/lib/pleroma/web/telemetry.ex +++ b/lib/pleroma/web/telemetry.ex @@ -2,6 +2,7 @@ defmodule Pleroma.Web.Telemetry do use Supervisor import Telemetry.Metrics alias Pleroma.Stats + alias Pleroma.Config def start_link(arg) do Supervisor.start_link(__MODULE__, arg, name: __MODULE__) @@ -9,14 +10,28 @@ defmodule Pleroma.Web.Telemetry do @impl true def init(_arg) do - children = [ - {:telemetry_poller, measurements: periodic_measurements(), period: 10_000}, - {TelemetryMetricsPrometheus.Core, metrics: prometheus_metrics()} - ] + children = + [ + {:telemetry_poller, measurements: periodic_measurements(), period: 10_000} + ] ++ + prometheus_children() Supervisor.init(children, strategy: :one_for_one) end + defp prometheus_children do + config = Config.get([:instance, :export_prometheus_metrics], true) + + if config do + [ + {TelemetryMetricsPrometheus.Core, metrics: prometheus_metrics()}, + Pleroma.PrometheusExporter + ] + else + [] + end + end + # A seperate set of metrics for distributions because phoenix dashboard does NOT handle them well defp distribution_metrics do [