Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore logging for web requests from the Sentry uptime bot #1919

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions lib/nerves_hub/logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,22 @@ defmodule NervesHub.Logger do

@doc false
def log_event([:phoenix, :endpoint, :stop], %{duration: duration}, %{conn: conn}, _) do
Logger.info("Request completed", %{
duration: duration(duration),
method: conn.method,
path: request_path(conn),
status: conn.status,
remote_ip: formatted_ip(conn)
})
conn.req_headers
|> List.keyfind("user-agent", 0)
|> case do
{"user-agent", "SentryUptimeBot"} ->
# ignore User-Agent: SentryUptimeBot, its just noise
:ok

_ ->
Logger.info("Request completed", %{
duration: duration(duration),
method: conn.method,
path: request_path(conn),
status: conn.status,
remote_ip: formatted_ip(conn)
})
end
end

def log_event([:nerves_hub, :devices, :invalid_auth], _, metadata, _) do
Expand Down
Loading