LogFilter misses Ranch :killed reports because Ranch emits a charlist format
Bug report
Realtime.LogFilter does not suppress the Ranch :killed report produced by Ranch 2.2.1 because the filter matches a binary format string while Ranch emits a charlist.
Realtime v2.129.13 defines:
@ranch_format "Ranch listener ~p had connection process started with ~p:start_link/3 at ~p exit with reason: ~0p~n"
def filter(%{msg: {:format, @ranch_format, [_, _, _, :killed]}}, _), do: :stop
Ranch 2.2.1 calls ranch:log/4 with an Erlang double-quoted string in ranch_conns_sup.erl, so Logger receives the format as a charlist. ranch:log/4 forwards Format unchanged. The rendered message looks identical, but the exact pattern does not match.
The current test helper uses the same Elixir binary module attribute as the implementation, so it does not reproduce the runtime event shape.
Reproducer
binary_format = "Ranch listener ~p had connection process started with ~p:start_link/3 at ~p exit with reason: ~0p~n"
charlist_format = String.to_charlist(binary_format)
event = %{msg: {:format, charlist_format, [:listener, :cowboy_clear, self(), :killed]}, meta: %{}}
assert :stop = Realtime.LogFilter.filter(event, [])
This assertion fails on v2.129.13 and the event falls through to the primary logger.
Suggested fix
Accept the Ranch format in both binary and charlist form, or normalize the format before comparing it. Please add the charlist-shaped event as the regression test; keeping only the binary fixture will continue to miss the shape Ranch actually emits.
This matters operationally because Realtime intentionally terminates transports with no joined channels, so the failed filter can turn routine tracker cleanup into large error-log bursts.
@ernestombaez thanks for the super detailed report! Happy to accept a PR to fix this
Just opened #2167 with a fix for this.
:tada: This issue has been resolved in version 2.135.4 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket: