chore(logs): suppress Phoenix Sent log for /live liveness probe
/live fires every 10s per pod; the request line and Sent 200 response from Plug.Telemetry drowned out real requests. log_level/1 now returns false for /live too, same treatment /health already got.
This commit is contained in:
parent
29962d62a4
commit
8ec5d895ee
3 changed files with 21 additions and 2 deletions
|
|
@ -68,6 +68,7 @@ defmodule MicrowavepropWeb.Endpoint do
|
||||||
# `path_info` never matches. `request_path` is set once by the adapter
|
# `path_info` never matches. `request_path` is set once by the adapter
|
||||||
# and is stable across forward, so it's the reliable discriminator.
|
# and is stable across forward, so it's the reliable discriminator.
|
||||||
def log_level(%{request_path: "/health"}), do: false
|
def log_level(%{request_path: "/health"}), do: false
|
||||||
|
def log_level(%{request_path: "/live"}), do: false
|
||||||
def log_level(%{request_path: "/metrics"}), do: false
|
def log_level(%{request_path: "/metrics"}), do: false
|
||||||
def log_level(%{request_path: "/metrics/" <> _}), do: false
|
def log_level(%{request_path: "/metrics/" <> _}), do: false
|
||||||
def log_level(%{method: "HEAD"}), do: false
|
def log_level(%{method: "HEAD"}), do: false
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@ defmodule Microwaveprop.PropagationTest do
|
||||||
|
|
||||||
:ets.match_delete(
|
:ets.match_delete(
|
||||||
:microwaveprop_cache,
|
:microwaveprop_cache,
|
||||||
{{Microwaveprop.Propagation.ProfilesFile, :_, :_, :_}, :_, :_}
|
{{ProfilesFile, :_, :_, :_}, :_, :_}
|
||||||
)
|
)
|
||||||
|
|
||||||
:ets.match_delete(
|
:ets.match_delete(
|
||||||
:microwaveprop_cache,
|
:microwaveprop_cache,
|
||||||
{{Microwaveprop.Propagation.ProfilesFile, :_, :_}, :_, :_}
|
{{ProfilesFile, :_, :_}, :_, :_}
|
||||||
)
|
)
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,24 @@ defmodule MicrowavepropWeb.MetricsLogSuppressionTest do
|
||||||
refute log =~ "Sent 200"
|
refute log =~ "Sent 200"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "GET /live does not emit a Phoenix endpoint Sent log line", %{conn: conn} do
|
||||||
|
log =
|
||||||
|
capture_log([level: :info], fn ->
|
||||||
|
conn = get(conn, "/live")
|
||||||
|
assert conn.status == 200
|
||||||
|
end)
|
||||||
|
|
||||||
|
refute log =~ "Sent 200"
|
||||||
|
refute log =~ "GET /live"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "log_level/1 returns false for /live", %{conn: _conn} do
|
||||||
|
assert MicrowavepropWeb.Endpoint.log_level(%{
|
||||||
|
request_path: "/live",
|
||||||
|
method: "GET"
|
||||||
|
}) == false
|
||||||
|
end
|
||||||
|
|
||||||
test "log_level/1 returns false for the rewritten conn shape produced by forward", %{
|
test "log_level/1 returns false for the rewritten conn shape produced by forward", %{
|
||||||
conn: _conn
|
conn: _conn
|
||||||
} do
|
} do
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue