Does anyone know what the purpose of the sampleRate check and random number is for in the Send method e.g. in the c# sample:
if (sampleRate < 1.0)
{
foreach (var stat in stats)
{
if (Random.NextDouble() <= sampleRate)
{
Just seems to be you would only ever call the code in the else part - loop through stats and send
The code expectes a sample rate between 0.0 and 1.0. It then generates a random value and if it is smaller than the sampleRate the stat gets send. It's a probabilistic approach to sampling out values based on the assumption that you get uniformly distributed random values from Random.NextDouble()
.
This is done because if you have a lot of stats, you might not need to send every one. Sampling should give you a sufficiently good approximation then.