DataDog / datadogpy

The Datadog Python library
https://datadoghq.com/
Other
609 stars 303 forks source link

Add IPv6 support #783

Open phil-scale opened 1 year ago

phil-scale commented 1 year ago

What does this PR do?

Adds IPv6 support to the DogStatsd class

Description of the Change

Adds a method to detect if a hostname can be resolved as an IPv6 hostname, and if so, uses the socket.AF_INET6 family of sockets

Alternate Designs

Possible Drawbacks

Verification Process

Before PR:

>>> from datadog.dogstatsd.base import DogStatsd
>>> DogStatsd._get_udp_socket("0.0.0.1", 8126)
<socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('10.254.0.78', 57605), raddr=('0.0.0.1', 8126)>
>>> DogStatsd._get_udp_socket("::", 8126)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/miniconda3/envs/hmi/lib/python3.8/site-packages/datadog/dogstatsd/base.py", line 544, in _get_udp_socket
    sock.connect((host, port))
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

After:

>>> from datadog.dogstatsd.base import DogStatsd
>>> DogStatsd._get_udp_socket("0.0.0.1", 8126)
<socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('10.254.0.78', 57605), raddr=('0.0.0.1', 8126)>
>>> DogStatsd._get_udp_socket("::", 8126)
<socket.socket fd=5, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_DGRAM, proto=0, laddr=('::1', 63924, 0, 0), raddr=('::1', 8126, 0, 0)>

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)

github-actions[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity.

nextmat commented 11 months ago

I'm running into issues with IPv6 support as well, any change of getting this merged?