Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions lib/sentry/phoenix_endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ defmodule Sentry.Phoenix.Endpoint do
request = Sentry.Plug.build_request_interface_data(conn, [])
exception = Exception.normalize(kind, reason, stacktrace)

Sentry.capture_exception(
exception,
stacktrace: stacktrace,
request: request,
event_source: :endpoint,
error_type: kind
)
_ =
Sentry.capture_exception(
exception,
stacktrace: stacktrace,
request: request,
event_source: :endpoint,
error_type: kind
)

:erlang.raise(kind, reason, stacktrace)
end
Expand Down
12 changes: 1 addition & 11 deletions lib/sentry/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,14 @@ if Code.ensure_loaded?(Plug) do
headers: handle_data(conn, header_scrubber),
env: %{
"REMOTE_ADDR" => remote_address(conn.remote_ip),
"REMOTE_PORT" => remote_port(conn),
"REMOTE_PORT" => Plug.Conn.get_peer_data(conn).port,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function was added in #326 as Plug.Conn.get_peer_data was returning an :error tuple, but I'm not sure if that's possible looking at Plug docs as it is now, and the typespecs seem to confirm that.

I'm going to assume it's good now though 🙂

"SERVER_NAME" => conn.host,
"SERVER_PORT" => conn.port,
"REQUEST_ID" => Plug.Conn.get_resp_header(conn, request_id) |> List.first()
}
}
end

defp remote_port(conn) do
case Plug.Conn.get_peer_data(conn) do
%{port: port} ->
port

_ ->
""
end
end

defp remote_address(address) do
address
|> :inet.ntoa()
Expand Down