Skip to content

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

@garthk

Description

@garthk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions