-
Notifications
You must be signed in to change notification settings - Fork 602
Description
This may not be possible because it might collide with existing private or assigns assignments, but trying to use the :request_id right now is a bit of a pain:
def sentry_request_id(conn) do
if request_id = Keyword.get(Logger.metadata(), :request_id) do
Sentry.Context.set_request_context(%{request_id: request_id})
end
conn
endThis would be much easier if Plug.RequestId also wrote the retrieved or generated request_id in either :private or :assigns (I know that:private is the correct place). It need not be called request_id (plug_request_id seems unlikely to have been used by anyone), but it could also be a configurable option.
plug Plug.RequestId, store_as: :request_idIf it were set up that way, the current behaviour would hold unless store_as (someone please give me a better name) and would do Conn.put_private(store_as_key, request_id or something similar.
I’d be happy to create a PR for this, but I wanted to gauge the temperature and get feedback before developing this.