From ee2db3e9b70fd87a6529eba9ea8a5aef07861241 Mon Sep 17 00:00:00 2001 From: Kieran Date: Mon, 17 Mar 2025 14:48:07 -0700 Subject: [PATCH] Stopped logging healthcheck requests (#659) --- lib/pinchflat_web/endpoint.ex | 9 ++++++++- lib/pinchflat_web/router.ex | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pinchflat_web/endpoint.ex b/lib/pinchflat_web/endpoint.ex index 908699e..bf094ed 100644 --- a/lib/pinchflat_web/endpoint.ex +++ b/lib/pinchflat_web/endpoint.ex @@ -39,7 +39,10 @@ defmodule PinchflatWeb.Endpoint do cookie_key: "request_logger" plug Plug.RequestId - plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] + + plug Plug.Telemetry, + event_prefix: [:phoenix, :endpoint], + log: {__MODULE__, :log_level, []} plug Plug.Parsers, parsers: [:urlencoded, :multipart, :json], @@ -55,6 +58,10 @@ defmodule PinchflatWeb.Endpoint do plug PinchflatWeb.Router + # Disables logging in Plug.Telemetry for healthcheck requests + def log_level(%Plug.Conn{path_info: ["healthcheck"]}), do: false + def log_level(_), do: :info + # URLs need to be generated using the host of the current page being accessed # for things like Podcast RSS feeds to contain links to the right location. # diff --git a/lib/pinchflat_web/router.ex b/lib/pinchflat_web/router.ex index bdbb17e..9586f13 100644 --- a/lib/pinchflat_web/router.ex +++ b/lib/pinchflat_web/router.ex @@ -68,7 +68,7 @@ defmodule PinchflatWeb.Router do scope "/", PinchflatWeb do pipe_through :api - get "/healthcheck", HealthController, :check + get "/healthcheck", HealthController, :check, log: false end scope "/dev" do