This study focuses on the precise modeling and frequency analysis of a mass-sensing nanobeam, utilizing the nonlocal elasticity theory while accounting for longitudinal discontinuities. It is posited that the beam can absorb both lumped and distributed masses, leading to the establishment of an innovative general formulation for the system. The energy Eqs. for the beam are formulated with the consideration of the longitudinal discontinuities and the arbitrary absorbed masses, leading to the derivation of vibration Eqs. and boundary conditions for the non-uniform nanobeam through Hamilton's principle. An analytical solution is employed, assuming the number of shape functions matches the longitudinal discontinuities present. By defining the compatibility and boundary conditions, we derive and resolve the frequency Eq. pertinent to the discontinuous nanobeam. The investigation explores the effects of various parameters, including the sensed mass and size effects, on the frequency characteristics of the nanobeam across different vibrational modes. The results highlight the importance of accurately modeling the discontinuous nanobeam. Notably, relocating the sensed mass towards the free end of the cantilever beam enhances the sensing performance, whereas size effects generally reduce it. Furthermore, the findings reveal that the mass-sensing capabilities of the nanobeam are more pronounced at higher vibrational modes, suggesting a preference for deploying the nanobeam mass sensor in these modes.