# File lib/new_relic/agent/sampled_buffer.rb, line 29
      def append_event(x = nil, &blk)
        raise ArgumentError, "Expected argument or block, but received both" if x && blk

        if @items.size < @capacity
          x = blk.call if block_given?
          @items << x
          @captured_lifetime += 1
          return x
        else
          m = rand(@seen) # [0, @seen)
          if m < @capacity
            x = blk.call if block_given?
            @items[m] = x
            return x
          else
            # discard current sample
            return nil
          end
        end
      end