An agricultural baler having a baling chamber and a pre-compression chamber, wherein the pre-compression chamber is adapted to periodically form a slice of crop material and push the slice towards the baling chamber into a first segment of the baling chamber, the baling chamber has a plunger provided for reciprocally moving in the baling chamber thereby compressing slices of crop material into a bale, wherein at least one optical bale length sensor is provided in the baling chamber for measuring the length of the bale.