Magnetometer - definitely no, those things will pick up all sorts of interference like there is no tomorrow, including Earth's magnetic field. Oh and the field changes depending on the direction the sensor is facing so you would get different values depending on in which direction you are riding, including up and down hill, so you would have to compensate for that. And you need to calibrate them before use.
Hall sensors are not good for distance sensing, most cheap and common ones are designed for on/off operation (e.g. as an end stop), even if you could find one that would trigger at 3cm range. Also the magnetic flux is highly non-linear with distance, so this would require quite a bit of math and/or calibration.
You could use an industrial inductive sensor, but you likely don't have the required voltage on your bike - most need at least 12V.
Alternatively I would go for either a mechanical position sensor or an optical encoder. If it is for a motocycle, you want something that is robust and idiot-proof, so that a random interference from the ignition or weather won't throw your system off (and potentially cause you to crash, depending on what exactly are you trying to use the sensor for).