Measuring speed of DC motor using rotary encoder and UNO

Do you have an external pull up resistor to 5v on pin 2?

If not, try setting the pin mode of pin 2 as INPUT_PULLUP.

If the interrupt is only one one pin RISING, you can expect to see 1024/4 = 256 counts per revolution