Time-stretch spectroscopy has established as a viable technique with high resolution and single-shot capability. However, it generally requires ultra-wideband photodetectors and electronics, and its performance is often restricted by a fundamental tradeoff between spectral resolution and signal-to-noise ratio. Here, we report a time-stretch spectrometer based on the concept of optical sampling by laser cavity tuning. A kilometer-scale dual-function fiber-optic link serves as both a pulse stretcher and a long delay line in an imbalanced Mach–Zehnder interferometer. Measurement results based on several device and atomic samples are presented. Theoretical forms of the total spectral range and spectral resolution are derived and compared with experimental data. A spectral resolution as small as 8 GHz has been achieved. Resolution-limiting factors are discussed and possible solutions are presented.