Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if there are packets to send before sending an empty UDP packet #264

Merged
merged 1 commit into from
Oct 19, 2018
Merged

Check if there are packets to send before sending an empty UDP packet #264

merged 1 commit into from
Oct 19, 2018

Conversation

Tenzer
Copy link
Contributor

@Tenzer Tenzer commented Apr 19, 2018

This avoid cases where the buffer is initialised but then doesn't receive any
packets to send before it's flushed. That can either be because of conditional
sending of metrics or because a sample rate is used which means no packets has
been generated this time around. In those cases an empty UDP packet is still
sent when the buffer is flushed.

This fixes that by checking if there are any packets to send before attempting
to send them off.

@yannmh
Copy link
Member

yannmh commented Oct 18, 2018

Apologies for the late answer @Tenzer.

What do you think of moving this logic into the close_buffer method? This prevents the _send_to_server method from systematically checking the packet when it might not be relevant (hence limit the overhead).

This avoid cases where the buffer is initialised but then doesn't receive any
packets to send before it's flushed. That can either be because of conditional
sending of metrics or because a sample rate is used which means no packets has
been generated this time around. In those cases an empty UDP packet is still
sent when the buffer is flushed.

This fixes that by checking if there are any packets to send before attempting
to send them off.
@Tenzer
Copy link
Contributor Author

Tenzer commented Oct 19, 2018

It sounds fine to me, I have updated the change to do that now.

@yannmh
Copy link
Member

yannmh commented Oct 19, 2018

Thank you @Tenzer !

@yannmh yannmh merged commit 24ed1ef into DataDog:master Oct 19, 2018
@Tenzer Tenzer deleted the avoid-empty-packets branch October 19, 2018 13:47
@Tenzer
Copy link
Contributor Author

Tenzer commented Oct 19, 2018

You're welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants