- Add retry: false to VISP Client HTTP requests - Add retry: false to ReleaseChecker GitHub API requests - Remove unused Plug.Conn import from RemoteIpLogger - Remove unused default parameter from req_get/2 Results: - VISP sync test: 7007ms → 113ms (62x faster) - ReleaseChecker test: 7004ms → 17ms (402x faster) - UserResetPasswordLive test: 1495ms → 284ms (5x faster) Req's default retry behavior (1s, 2s, 4s exponential backoff) was causing 7-second delays for HTTP 500/503 error responses in tests. For these clients, immediate failure is preferred over retries.
24 lines
662 B
Elixir
24 lines
662 B
Elixir
defmodule ToweropsWeb.Plugs.RemoteIpLogger do
|
|
@moduledoc """
|
|
Plug that extracts the remote IP address and adds it to Logger metadata.
|
|
|
|
When behind a proxy/load balancer (like Traefik in Kubernetes), the real client IP
|
|
is in the X-Forwarded-For or X-Real-IP headers. This plug extracts the IP and
|
|
adds it to Logger metadata so it appears in all logs for the request.
|
|
"""
|
|
|
|
alias ToweropsWeb.RemoteIp
|
|
|
|
require Logger
|
|
|
|
def init(opts), do: opts
|
|
|
|
def call(conn, _opts) do
|
|
remote_ip = RemoteIp.from_conn(conn)
|
|
|
|
# Add to Logger metadata so it appears in all logs for this request
|
|
Logger.metadata(remote_ip: remote_ip)
|
|
|
|
conn
|
|
end
|
|
end
|