Skip Menu |

This queue is for tickets about the Net-Statsd CPAN distribution.

Report information
The Basics
Id: 74432
Status: resolved
Priority: 0/
Queue: Net-Statsd

People
Owner: Nobody in particular
Requestors: mellery [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.02
Fixed in: (no value)



Subject: sample rate is not sent to the statsd server
I've been writing some tests and I believe that all non-unity sample rates are not being sent to the server. I think the bug might be on line 127: my $value = $data->{$stat}; ..and I think that should be my $value = $sampled_data->{$stat}; since $sampled_data is the hashref with munged value data. In addition, I'm trying to understand this code (in _sample_data): if ($sample_rate < 1) { if (rand() <= $sample_rate) { while (my ($stat, $value) = each %{ $data }) { $sampled_data->{$stat} = sprintf "%s|@%s", $value, $sample_rate; } } } If I understand this correctly, then I think it says that the sample rate will only be added to the message SOME OF THE TIME, depending on the value of rand() and $sample_rate. How can this be right? Furthermore, since the assignment to the sampled_data hash also happens in that block, the data never gets assigned. Let's say I have a sample_rate of 0.1..then only 1 out of 10 times, you will decide to append the @SAMPLE_RATE and assign it to the sampled_data hash. Otherwise, the hash is empty and the module croaks when you try to send. This seems wrong to me -- or at the very least the documentation doesn't make any mention of this behavior. Unless I'm misunderstanding the intent of this code, I would propose always sending the sample rate value when it is provided by the caller, as well as always sending the data. Please let me know if anything in my report is unclear. Thank You.
I just noticed that your project is on github. I can make a fix for the first issue and send you a pull request. As for the second issue I mentioned (stats only sent sometimes when sample_rate is given), I'm not sure if you want those changes or if the current behavior is actually as intended. Thanks. -Mike
A fix was released in 0.03 (now there's 0.08 up on CPAN). Closing.