Like the rotation of a robot arm, or the direction a camera is facing.
Usually a potentiometer is used. A resolver is another device that is used.
The most commonly used device in the industrial world is an optical encoder. A quadrature encoder to be more precise. This is the device that is present on virtually all industrial robots.
They are relatively precise and can detect which direction they are turning.
They can not determine absolute position however. An absolute encoder or resolver is typically used in this case.
They are also relatively expensive. If precision and/or direction are not important other devices are cheaper. A proximity sensor and a gear are a common solution in this case.