fix: suppress health check logs and downgrade CI artifacts to v3
Health Check Logging: - Update TelemetryFilter to catch both request and response logs - Filter /health and /health/time endpoints completely - Check phoenix_log metadata to suppress response logs - Prevents log flooding from Kubernetes probes (every 5s) - Refactor to reduce cyclomatic complexity (Credo compliant) CI Artifact Actions: - Downgrade upload-artifact from v4 to v3 - Downgrade download-artifact from v4 to v3 - v4 is not supported on Forgejo/GHES Fixes: - Production logs no longer flooded with health check entries - CI pipeline works on self-hosted Forgejo instance
This commit is contained in:
parent
b21f913078
commit
ab24a3100e
2 changed files with 24 additions and 16 deletions
|
|
@ -97,7 +97,7 @@ jobs:
|
|||
run: mix compile --warnings-as-errors
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: build-artifacts
|
||||
path: |
|
||||
|
|
@ -126,7 +126,7 @@ jobs:
|
|||
version-type: strict
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: build-artifacts
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ jobs:
|
|||
run: sudo apt-get install -y --no-install-recommends libsnmp-dev snmp-mibs-downloader postgresql-client
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: build-artifacts
|
||||
|
||||
|
|
|
|||
|
|
@ -19,25 +19,33 @@ defmodule ToweropsWeb.TelemetryFilter do
|
|||
def filter_health_checks(log_event, _opts) do
|
||||
case log_event do
|
||||
{_level, _gl, {Logger, msg, _ts, metadata}} ->
|
||||
# Check if this is a Phoenix request log with conn metadata
|
||||
cond do
|
||||
# Filter based on request_path in metadata (Phoenix endpoint logs)
|
||||
Keyword.get(metadata, :request_path) in ["/health"] ->
|
||||
:stop
|
||||
|
||||
# Filter based on message content as fallback
|
||||
is_binary(msg) and (String.contains?(msg, "GET /health") or String.contains?(msg, "HEAD /")) ->
|
||||
:stop
|
||||
|
||||
true ->
|
||||
:ignore
|
||||
end
|
||||
if should_filter_log?(msg, metadata), do: :stop, else: :ignore
|
||||
|
||||
_ ->
|
||||
:ignore
|
||||
end
|
||||
end
|
||||
|
||||
defp should_filter_log?(msg, metadata) do
|
||||
filter_by_path?(metadata) or filter_by_phoenix_log?(metadata) or filter_by_message?(msg)
|
||||
end
|
||||
|
||||
defp filter_by_path?(metadata) do
|
||||
Keyword.get(metadata, :request_path) in ["/health", "/health/time"]
|
||||
end
|
||||
|
||||
defp filter_by_phoenix_log?(metadata) do
|
||||
Keyword.get(metadata, :phoenix_log) == false
|
||||
end
|
||||
|
||||
defp filter_by_message?(msg) when is_binary(msg) do
|
||||
String.contains?(msg, "GET /health") or
|
||||
String.contains?(msg, "/health/time") or
|
||||
String.contains?(msg, "HEAD /")
|
||||
end
|
||||
|
||||
defp filter_by_message?(_), do: false
|
||||
|
||||
@doc """
|
||||
Dummy attach function for compatibility with existing code.
|
||||
The actual filtering happens via logger configuration, not telemetry.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue