storage = new BucketStorage($size); $this->size = $size; } public function offer($index, $value, AttributesInterface $attributes, ContextInterface $context, int $timestamp): void { $bucket = random_int(0, $this->measurements); $this->measurements++; if ($bucket < $this->size) { $this->storage->store($bucket, $index, $value, $attributes, $context, $timestamp); } } public function collect(array $dataPointAttributes): array { $this->measurements = 0; return $this->storage->collect($dataPointAttributes); } }