fix/suppress-health-check-logs (#47)
Reviewed-on: graham/towerops-web#47
This commit is contained in:
parent
26c7b0b993
commit
0fa1fa800b
3 changed files with 12 additions and 10 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -99,3 +99,6 @@ profiles.json
|
||||||
# Stride API credentials (contains secrets - never commit)
|
# Stride API credentials (contains secrets - never commit)
|
||||||
.stride_auth.md
|
.stride_auth.md
|
||||||
|
|
||||||
|
|
||||||
|
# Generated by nix, machine-specific paths
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
|
|
||||||
|
|
@ -66,16 +66,15 @@ defmodule ToweropsWeb.Endpoint do
|
||||||
|
|
||||||
plug Plug.Telemetry,
|
plug Plug.Telemetry,
|
||||||
event_prefix: [:phoenix, :endpoint],
|
event_prefix: [:phoenix, :endpoint],
|
||||||
log: :info,
|
log: {__MODULE__, :telemetry_log_level, []}
|
||||||
metadata_filter: &__MODULE__.telemetry_metadata_filter/1
|
|
||||||
|
|
||||||
# Filter function for Plug.Telemetry - don't log health checks and uptime monitors
|
# Dynamic log level for Plug.Telemetry — suppresses logging for
|
||||||
def telemetry_metadata_filter(metadata) do
|
# health checks and uptime monitors (filtered by FilterNoisyLogs plug).
|
||||||
case metadata do
|
def telemetry_log_level(conn) do
|
||||||
%{conn: %{method: "GET", path_info: ["health"]}} -> false
|
if conn.private[:plug_skip_telemetry] do
|
||||||
%{conn: %{method: "GET", path_info: ["health", "time"]}} -> false
|
false
|
||||||
%{conn: %{method: "HEAD", path_info: []}} -> false
|
else
|
||||||
_ -> metadata
|
:info
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ defmodule ToweropsWeb.Router do
|
||||||
|
|
||||||
# Health check endpoint for Kubernetes probes (no authentication required)
|
# Health check endpoint for Kubernetes probes (no authentication required)
|
||||||
scope "/", ToweropsWeb do
|
scope "/", ToweropsWeb do
|
||||||
get "/health", HealthController, :index
|
get "/health", HealthController, :index, log: false
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", ToweropsWeb do
|
scope "/", ToweropsWeb do
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue