How Sampler creates one single Sample from multiple collected stat? #97
-
As I understood, there is a collector that collects stats. And a sampler that makes samples from multiple collected stats. Is it correct? My question is: How it's making a single sample? Does it average some data or using max/min? or just the last stat is used? monitor = createClientMonitor({
collectingPeriodInMs: 3000,
samplingPeriodInMs: 10000,
sendingPeriodInMs: 20000, After 10s the first Sample is created but there are 3 different collected stats! Does Sampler combine these three collections? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Short answer: In your example what happens is that the sampler creates a Sample after 10s, 20s, which means it makes a snapshot after the 3rd, 6th, and 9th collected stats. After 20s it will send 2 Samples, and after 40s it sends 2 Samples again. Longer reply: monitor.events.onStatsCollected(() => {
const storage = monitor.storage;
let congested = false;
for (const outboundRtp of storage.outboundRtps()) {
if (myAwesomeDetector(outboundRtp)) congested = true
}
if (congested) {
monitor.sample();
}
}); In this case you detect congestion with your |
Beta Was this translation helpful? Give feedback.
Short answer:
no aggregation, the collecting period and sampling period are separated for different reasons.
A Sample is a snapshot of the stats at the moment it is invoked.
In your example what happens is that the sampler creates a Sample after 10s, 20s, which means it makes a snapshot after the 3rd, 6th, and 9th collected stats. After 20s it will send 2 Samples, and after 40s it sends 2 Samples again.
Longer reply:
The reason for the separation is to decide what the granuality you want to work on the client-side and what is the granuality you want to save at the server side.
Most or almost every measurement is accumulated in the stats (bytesReceived, packetsReceived, etc), so for those …