use Supervisor
import Telemetry.Metrics
alias Pleroma.Stats
+ alias Pleroma.Config
def start_link(arg) do
Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
@impl true
def init(_arg) do
- children = [
- {:telemetry_poller, measurements: periodic_measurements(), period: 10_000},
- {TelemetryMetricsPrometheus, metrics: prometheus_metrics(), plug_cowboy_opts: [ip: {127, 0, 0, 1}]}
- ]
+ children =
+ [
+ {:telemetry_poller, measurements: periodic_measurements(), period: 10_000}
+ ] ++
+ prometheus_children()
Supervisor.init(children, strategy: :one_for_one)
end
- @doc """
- A seperate set of metrics for distributions because phoenix dashboard does NOT handle
- them well
- """
+ 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
[
distribution(
summary("vm.total_run_queue_lengths.total"),
summary("vm.total_run_queue_lengths.cpu"),
summary("vm.total_run_queue_lengths.io"),
-
-
last_value("pleroma.local_users.total"),
last_value("pleroma.domains.total"),
- last_value("pleroma.local_statuses.total")
+ last_value("pleroma.local_statuses.total"),
+ last_value("pleroma.remote_users.total")
]
end
:telemetry.execute([:pleroma, :local_users], %{total: stats.user_count}, %{})
:telemetry.execute([:pleroma, :domains], %{total: stats.domain_count}, %{})
:telemetry.execute([:pleroma, :local_statuses], %{total: stats.status_count}, %{})
+ :telemetry.execute([:pleroma, :remote_users], %{total: stats.remote_user_count}, %{})
end
end