Sensor based on an integrated optical microcavity