DataDog / datadogpy

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

Changing Statsd to UDS does not reset telemetry labels / max payload size #794

Open paulkirby-hotjar opened 10 months ago

paulkirby-hotjar commented 10 months ago

Describe the bug The docs currently suggest that the way to start using UDS instead of UDP for statsd communication is to call datadog.initialize(statsd_socket_path='/some/path')

While this does change the socket to communicate over UDS, there are two issues here.

  1. Any consumers of the global datadog.statsd object will be sending over UDP before this initialize call is run. Not that big of a deal as you shouldn't be sending metrics before running initialize but it's a bit confusing
  2. The larger issue - because initialize() does not re-run DogStatsd's __init__(), changing from UDP to UDS does not cause the telemetry tags to be reset, so the telemetry still suggests you're sending over UDP even though you aren't. It also does not reset the _max_payload_size for the DogStatsd object, so the optimal payload length for UDS is never set which is highly sub-optimal.

To Reproduce

Expected behavior When changing to UDS, the telemetry tags should reflect this, and the proper payload length should be set.

Environment and Versions (please complete the following information): datadogpy v 0.44.0 Python 3.10

Additional context As a hacky method of solving this, prior to running datadog.initialize(), we run datadog.statsd.__init__(statsd_socket_path='/some/path') and that reinitializes things properly. Almost seems as if the statsd global should be initialized in datadog's initialization instead of at import time by DogStatsd?

github-actions[bot] commented 9 months ago

Thanks for your contribution!

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. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

paulkirby-hotjar commented 9 months ago

Still present in datadogpy v0.47.0