-
Notifications
You must be signed in to change notification settings - Fork 586
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
@callback get_host_data to rhyme with get_peer_data? #948
Comments
@garthk if you have the whole |
In the process of building out https://github.com/mtrudel/bandit I've also implemented a @josevalim in a somewhat related question, is there an example of a caller for the newly introduced |
You should be able to build the URI by hand by building the URI struct directly: Other than that, this is a very separate discussion from get_local_data because we need the URI information when building the connection, its info is used on all requests, while the get_local_data is only needed in certain cases. |
Yep, sounds good to me. I haven't gotten around to updating bandit to use the the new My worries were / are centered around concerns that web servers usually don't have a 100% canonical view of the URI requested, and typically build it based using heuristics against a number of sources. For example, the hostname of a request may be any of:
There are similar concerns surrounding canonicalizing requests (Do you include the port number if it's a standard port? Do you URL encode an otherwise invalid URI for the purposes of comparison? Does SNI trump the Host header? What about information that's just straight up not known like hostnames in HTTP 1.0? Can you guess?). Exposing a URI as the primary way for web servers to get that information into Plug glosses over many of these concerns, making it easy for a Plug to have fragile dependencies on the behaviour of a particular server implementation without even knowing it. Seeing as all of the relevant input data is available via Plug, my thought is that it may be better to have Plug provide a single heuristic to build URIs from constituent parts rather than leaving it up to the discretion of the underlying web server. To the extent that the All of this is rather off topic from the content of this PR (which I think makes sense regardless of the above). That being said, if this makes sense to you I'm happy to open an issue for discussion along with an accompanying PR. I'm going to be doing the work to build out bandit's currently very rudimentary request canonicalization anyway; I'd be happy to do it within Plug instead. |
Right now, the only adapter that we use does the heuristic itself, that's why we don't do it. So my recommendation for now would be for you to do it and then in the future we can move it to Plug if there is more need. About URI, you are correct you are not allowed to build it by hand, but that's something I want to change short term. Just don't worry about the authority field. |
Closing this. If still relevant, please let me know! |
It'd help us fill in the
net.host
block of these OpenTelemetry general network connection attributes ifPlug.Conn.Adapter
declared ac:get_host_data/1
callback matchingc:get_peer_data/1
:net.transport
net.peer.ip
net.peer.port
80
.net.peer.name
net.host.ip
net.peer.ip
but for the host IP. Useful in case of a multi-IP host.net.host.port
net.peer.port
but for the host port.net.host.name
I can see what I need in
conn.adapter
thanks to Phoenix' call to:telemetry.execute([:phoenix, :router_dispatch, :start], …)
:sock
would be very handy, though looking atPlug.Cowboy.Conn
I've no idea how it got in there:The text was updated successfully, but these errors were encountered: