Add encode implementations for SocketAddr and IpAddr
Something I encounter quite often is having metrics based on connection information, so I frequently find myself wanting to use either a SocketAddr or IpAddr in a label.
Friendly ping @rnijveld.
@mxinden Sorry about the slow response, life got in the way a little. I definitely agree with not wanting to use this for high cardinality situations. Although of course such cases could happen just as easily with other label types, I do agree that IP addresses might more quickly result in a cardinality explosion when not used correctly. I've added a little warning text to each of the implementations, I hope that resolves your concerns, let me know if there's anything else I can do!
It is effectively never appropriate to use an address as a label, for reasons of cardinality already discussed.
I don't think "never" is correct. One use-case I can come up with is exposing ones listening address as an info metric. See e.g. https://github.com/kubernetes/kube-state-metrics/issues/498 as an example on how far one can push cardinality in Prometheus with info metrics.