From 1da94325023aabe74c0944efc02e2deb35e77662 Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Mon, 9 Mar 2026 15:37:23 -0600 Subject: [PATCH] healthcheck improvements --- config/config.exs | 3 +-- lib/elixir_ai/application.ex | 36 ------------------------------------ lib/elixir_ai_web/router.ex | 2 +- 3 files changed, 2 insertions(+), 39 deletions(-) diff --git a/config/config.exs b/config/config.exs index 6faa410..98ba630 100644 --- a/config/config.exs +++ b/config/config.exs @@ -20,8 +20,7 @@ config :elixir_ai, ElixirAiWeb.Endpoint, layout: false ], pubsub_server: ElixirAi.PubSub, - live_view: [signing_salt: "4UG1IVt+"], - log: false + live_view: [signing_salt: "4UG1IVt+"] # Configure esbuild (the version is required) config :esbuild, diff --git a/lib/elixir_ai/application.ex b/lib/elixir_ai/application.ex index de14ab3..dae08e4 100644 --- a/lib/elixir_ai/application.ex +++ b/lib/elixir_ai/application.ex @@ -4,14 +4,6 @@ defmodule ElixirAi.Application do @impl true def start(_type, _args) do - # Attach custom logger that filters health checks - :telemetry.attach( - "phoenix-endpoint-logger", - [:phoenix, :endpoint, :stop], - &__MODULE__.log_request/4, - %{} - ) - children = [ ElixirAiWeb.Telemetry, ElixirAi.Repo, @@ -47,32 +39,4 @@ defmodule ElixirAi.Application do ElixirAiWeb.Endpoint.config_change(changed, removed) :ok end - - # Custom request logger that filters health check endpoint - require Logger - - def log_request(_event, measurements, %{conn: conn}, _config) do - # Skip logging for health check endpoint - if conn.request_path != "/health" do - duration = System.convert_time_unit(measurements.duration, :native, :microsecond) - - Logger.info( - fn -> - [conn.method, " ", conn.request_path] - end, - request_id: conn.assigns[:request_id] - ) - - Logger.info( - fn -> - ["Sent ", to_string(conn.status), " in ", format_duration(duration)] - end, - request_id: conn.assigns[:request_id] - ) - end - end - - defp format_duration(μs) when μs < 1000, do: "#{μs}µs" - defp format_duration(μs) when μs < 1_000_000, do: "#{div(μs, 1000)}ms" - defp format_duration(μs), do: "#{Float.round(μs / 1_000_000, 2)}s" end diff --git a/lib/elixir_ai_web/router.ex b/lib/elixir_ai_web/router.ex index bd6c330..22a4d8c 100644 --- a/lib/elixir_ai_web/router.ex +++ b/lib/elixir_ai_web/router.ex @@ -14,7 +14,7 @@ defmodule ElixirAiWeb.Router do plug :accepts, ["json"] end - scope "/", ElixirAiWeb do + scope "/", ElixirAiWeb, log: false do pipe_through :api get "/health", HealthController, :index