Plug.Cowboy.Translator - add Plug.Conn to metadata?
darrenclark opened this issue · 5 comments
I'm currently working on a custom Logger
backend to report crashes to a 3rd party service. For HTTP requests, I'd like to pull some metadata from the Plug.Conn
and attach that to the report.
To get access to the conn
in the Logger
backend, I think it could be added to the metadata
here:
plug_cowboy/lib/plug/cowboy/translator.ex
Lines 40 to 44 in a01f629
Thoughts?
If this change makes sense, I can open a PR.
We could and a PR would be welcome (<3) but keep in mind that connection is the connection at the beginning of the request so it has limited amount of information.
Cool, will do!
keep in mind that connection is the connection at the beginning of the request so it has limited amount of information
Good to know, thanks.
I came across phoenixframework/phoenix#2791 (comment) as well, I get the feeling I'll end up with duplicate crash reports though:
- one from my
Sentry.stuff(...)
in the linked comment - one from my custom Logger backend
Is there a way I could de-duplicate those? Maybe comparing the Plug.Conn
's owner
pid? Is it always 1 pid per request?
Recent Sentry skips this particular logging based on the current metadata (it has an option that does so), so you should not see double logging (unless your custom logger backend also sends it to sentry :P)
Not using Sentry at the moment, but maybe I should be! :D
You can just replicate their behavior too. They have a plug that wraps the request life-cycle, so they don't rely on this particular Cowboy report and instead they just ignore it. Handling this from the request life-cycle has benefits as you generally have a more up-to-date connection.