mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 02:05:12 +00:00
Set up telemetry and prometheus
This commit is contained in:
parent
b655a8ea83
commit
bc3618a38d
|
@ -8,6 +8,10 @@ use Mix.Config
|
||||||
# General application configuration
|
# General application configuration
|
||||||
config :pleroma, ecto_repos: [Pleroma.Repo]
|
config :pleroma, ecto_repos: [Pleroma.Repo]
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.Repo,
|
||||||
|
types: Pleroma.PostgresTypes,
|
||||||
|
loggers: [Pleroma.Repo.Instrumenter, Ecto.LogEntry]
|
||||||
|
|
||||||
config :pleroma, Pleroma.Captcha,
|
config :pleroma, Pleroma.Captcha,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
seconds_valid: 60,
|
seconds_valid: 60,
|
||||||
|
@ -87,6 +91,7 @@ websocket_config = [
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
|
instrumenters: [Pleroma.Web.Endpoint.Instrumenter],
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
http: [
|
http: [
|
||||||
dispatch: [
|
dispatch: [
|
||||||
|
|
|
@ -25,6 +25,7 @@ defmodule Pleroma.Application do
|
||||||
import Cachex.Spec
|
import Cachex.Spec
|
||||||
|
|
||||||
Pleroma.Config.DeprecationWarnings.warn()
|
Pleroma.Config.DeprecationWarnings.warn()
|
||||||
|
setup_instrumenters()
|
||||||
|
|
||||||
# Define workers and child supervisors to be supervised
|
# Define workers and child supervisors to be supervised
|
||||||
children =
|
children =
|
||||||
|
@ -140,6 +141,13 @@ defmodule Pleroma.Application do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp setup_instrumenters() do
|
||||||
|
Pleroma.Web.Endpoint.MetricsExporter.setup()
|
||||||
|
Pleroma.Web.Endpoint.PipelineInstrumenter.setup()
|
||||||
|
Pleroma.Web.Endpoint.Instrumenter.setup()
|
||||||
|
Pleroma.Repo.Instrumenter.setup()
|
||||||
|
end
|
||||||
|
|
||||||
if Mix.env() == :test do
|
if Mix.env() == :test do
|
||||||
defp streamer_child, do: []
|
defp streamer_child, do: []
|
||||||
defp chat_child, do: []
|
defp chat_child, do: []
|
||||||
|
|
|
@ -8,6 +8,10 @@ defmodule Pleroma.Repo do
|
||||||
adapter: Ecto.Adapters.Postgres,
|
adapter: Ecto.Adapters.Postgres,
|
||||||
migration_timestamps: [type: :naive_datetime_usec]
|
migration_timestamps: [type: :naive_datetime_usec]
|
||||||
|
|
||||||
|
defmodule Instrumenter do
|
||||||
|
use Prometheus.EctoInstrumenter
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Dynamically loads the repository url from the
|
Dynamically loads the repository url from the
|
||||||
DATABASE_URL environment variable.
|
DATABASE_URL environment variable.
|
||||||
|
|
|
@ -70,6 +70,26 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
extra: "SameSite=Strict"
|
extra: "SameSite=Strict"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Note: the plug and its configuration is compile-time this can't be upstreamed yet
|
||||||
|
if proxies = Pleroma.Config.get([__MODULE__, :reverse_proxies]) do
|
||||||
|
plug(RemoteIp, proxies: proxies)
|
||||||
|
end
|
||||||
|
|
||||||
|
defmodule Instrumenter do
|
||||||
|
use Prometheus.PhoenixInstrumenter
|
||||||
|
end
|
||||||
|
|
||||||
|
defmodule PipelineInstrumenter do
|
||||||
|
use Prometheus.PlugPipelineInstrumenter
|
||||||
|
end
|
||||||
|
|
||||||
|
defmodule MetricsExporter do
|
||||||
|
use Prometheus.PlugExporter
|
||||||
|
end
|
||||||
|
|
||||||
|
plug(PipelineInstrumenter)
|
||||||
|
plug(MetricsExporter)
|
||||||
|
|
||||||
plug(Pleroma.Web.Router)
|
plug(Pleroma.Web.Router)
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
Loading…
Reference in a new issue