diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 9d1bdc05..ffdb4e62 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -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 diff --git a/lib/towerops_web/telemetry_filter.ex b/lib/towerops_web/telemetry_filter.ex index 44fde02a..25d5fcd0 100644 --- a/lib/towerops_web/telemetry_filter.ex +++ b/lib/towerops_web/telemetry_filter.ex @@ -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.