Get match path in Phoenix

plug
phoenix
metrics

#1

Is there some way in Phoenix to see what path was used to match a route?
This would be very useful for metrics and logging (and probably other things). We would like to have the match path as a label in prometheus and as a log field so we can aggregate on that in kibana.

In Plug this was added a while ago in this PR https://github.com/elixir-plug/plug/pull/630

I’ve check that there are no equivalent field in conn.private from Phoenix, but is it accessible in some other way?


#2

What version of plug are you using according to mix.exs and mix.lock?


#3

In general that field should only get accessed through Plug.Router.match_path, which is available since 1.5 as far as I can tell.


#4

Plug is version 1.7.1, but I don’t think the Phoenix.Router uses the Plug.Router to match under the hood.
It works fine in a regular Plug.Router outside of Phoenix.


#5

I always thought Phoenix.Router where just wrapping Plug.Router.