A justice before whom there is any proceeding in a criminal case, preliminary to prosecution in a circuit court or other court of record having jurisdiction in criminal cases, shall certify to the clerk of such court all the expenses incident to such proceeding which are payable out of the treasury.