There are two devices I'm familiar with which could be relevant to your question:
Nima - uses detection strips for gluten https://nimasensor.com/
SCIO - can measure the concentration of fat and other ingredients in foods. But just for high contents, not ppm/ppb. https://www.consumerphysics.com/
Limit of detection is dependent on instrument and method used. Desktop spectrometer works only with visible light, so for detection of substance you need selective reaction with another substance that makes colour. Try searching: spectrophotometric determination of mercury. Common problems are big limit of detection, rare and expensive chemicals, influence of other substances. There are some interesting method using chemically modified carbon nanotubes...