Skip to content
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

net.peer.* vs net.host.* #8

Open
garthk opened this issue Jun 4, 2020 · 2 comments
Open

net.peer.* vs net.host.* #8

garthk opened this issue Jun 4, 2020 · 2 comments

Comments

@garthk
Copy link
Contributor

garthk commented Jun 4, 2020

lib/opentelemetry_plug.ex reads wrong to me:

    attributes = [{"http.target", conn.request_path},
                  {"http.host",  conn.host},
                  {"http.scheme",  conn.scheme},
                  {"http.user_agent", user_agent},
                  {"http.method", conn.method},
                  {"net.peer.ip", to_string(:inet_parse.ntoa(peer_ip))},
                  {"net.peer.port", adapter.peer_data.port},
                  {"net.peer.name", host},
                  {"net.transport", "IP.TCP"},
                  {"net.host.ip", to_string(:inet_parse.ntoa(conn.remote_ip))},
                  {"net.host.port", conn.port} | optional_attributes(conn)
                  # {"net.host.name", HostName}
                 ]

vs the semantic conventions spec:

Attribute name Notes and examples
net.transport Transport protocol used. See note below.
net.peer.ip Remote address of the peer (dotted decimal for IPv4 or RFC5952 for IPv6)
net.peer.port Remote port number as an integer. E.g., 80.
net.peer.name Remote hostname or similar, see note below.
net.host.ip Like net.peer.ip but for the host IP. Useful in case of a multi-IP host.
net.host.port Like net.peer.port but for the host port.
net.host.name Local hostname or similar, see note below.

… and the semantic conventions for HTTP spec, from which I lack the time to extract the right bit, and Plug.Conn:

remote_ip - the IP of the client, example: {151, 236, 219, 228}. This field is meant to be overwritten by plugs that understand e.g. the X-Forwarded-For header or HAProxy's PROXY protocol. It defaults to peer's IP

If conn.remote_ip has the apparent client IP address from X-Forwarded-For, that should go in http.client_ip, which you did by other means, not in net.host.ip. So there'll be some cleaning up in there.

@garthk
Copy link
Contributor Author

garthk commented Jun 4, 2020

I've raised elixir-plug/plug#948 to see if we can get the sock out of conn.adapter via official means rather than rummaging, matching the use of Plug.Conn.get_peer_data/1 in #4.

@garthk
Copy link
Contributor Author

garthk commented Jun 5, 2020

Aah, I get it now. "host" != "server". For spans sent by an HTTP client, the HTTP client is the host and the HTTP server is the peer. For spans sent by an HTTP server, the HTTP client is the peer and the HTTP server is the host.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant