Apparatus is provided for detecting an analyte, configured to be implanted in a body of a subject. The apparatus includes an optical fiber having a distal portion and also a membrane permeable to the analyte. The membrane is coupled to the distal portion of the fiber and surrounding a sampling region at least in part, by being fitted over the distal portion of the fiber. Other embodiments are also described.