This commit is contained in:
@@ -46,7 +46,12 @@ config :tailwind,
|
||||
# Configures Elixir's Logger
|
||||
config :logger, :console,
|
||||
format: "$time $metadata[$level] $message\n",
|
||||
metadata: [:request_id]
|
||||
metadata: [:request_id],
|
||||
filters: [:health_check_filter]
|
||||
|
||||
config :logger, :health_check_filter,
|
||||
module: ElixirAiWeb.HealthCheckFilter,
|
||||
function: :filter
|
||||
|
||||
# Use Jason for JSON parsing in Phoenix
|
||||
config :phoenix, :json_library, Jason
|
||||
|
||||
@@ -4,14 +4,6 @@ defmodule ElixirAi.Application do
|
||||
|
||||
@impl true
|
||||
def start(_type, _args) do
|
||||
# Attach telemetry handler to filter health check logs
|
||||
:telemetry.attach(
|
||||
"filter-health-logs",
|
||||
[:phoenix, :endpoint, :stop],
|
||||
&filter_health_logs/4,
|
||||
nil
|
||||
)
|
||||
|
||||
children = [
|
||||
ElixirAiWeb.Telemetry,
|
||||
ElixirAi.Repo,
|
||||
@@ -47,14 +39,4 @@ defmodule ElixirAi.Application do
|
||||
ElixirAiWeb.Endpoint.config_change(changed, removed)
|
||||
:ok
|
||||
end
|
||||
|
||||
# Filter health check requests from telemetry logs
|
||||
defp filter_health_logs(_event, _measurements, %{conn: %{request_path: "/health"}}, _config) do
|
||||
:ok
|
||||
end
|
||||
|
||||
defp filter_health_logs(event, measurements, metadata, config) do
|
||||
# Forward to default Phoenix logger
|
||||
:telemetry.execute(event, measurements, metadata)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,6 +38,7 @@ defmodule ElixirAiWeb.Endpoint do
|
||||
cookie_key: "request_logger"
|
||||
|
||||
plug Plug.RequestId
|
||||
plug ElixirAiWeb.Plugs.HealthCheckLogger
|
||||
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
|
||||
|
||||
plug Plug.Parsers,
|
||||
|
||||
Reference in New Issue
Block a user