Closed gilbsgilbs closed 2 years ago
@gilbsgilbs I'll take a look to confirm but from your well-written issue description it does seem like there's a bug to be fixed here.
@gilbsgilbs Just as a sidenote though: once buffering is enabled, there should be no need to do any buffering management except maybe the occasional flush. In all likelihood once buffering gets turned on by default (in some future version), we will very quickly deprecate all manual buffer operation probably.
Thanks for the clarification, I'm in line.
try: … finally: client.flush()
).@gilbsgilbs Fix landed on master so you should have the fix when the next release rolls out.
Thanks @sgnn7. Much appreciated work!
@gilbsgilbs v0.44.0 is out on Pypi. Give it a try and let me know if you encounter any issues.
Describe the bug
When using the context manager on a client with buffering enabled, the buffering gets disabled globally as soon as a context manager exits.
To Reproduce
Outputs:
Buffer after
increment again
should be empty.Expected behavior
The buffering configuration of the client shouldn't be changed by the context manager.
Screenshots
N/A
Environment and Versions (please complete the following information):
Additional context
The bug seems to be caused by this: https://github.com/DataDog/datadogpy/blob/ee5ac16744407dcbd7a3640ee7b4456536460065/datadog/dogstatsd/base.py#L522
The
close_buffer()
function (which is called when the context manager exits) always sets the_send
function to_send_to_server
independently of the client buffering.