I get pretty annoyed by repairable parts being binned. Brake pad wear sensors often get replaced when they could still work perfectly well, and at up to 50% of the price of the brake pads they’re really expensive to start with. So remove it and look at it, and work out how it works. In the case of this one off a Range Rover, for example:
It’s easy to see that one of the two wires coming into this sensor are really one loop, exposed at the “sensor” end. When this side of the sensor gets close enough to the brake disc, the metal is worn away, breaking the loop and preventing current from flowing. This is what the ECU senses as it will show a brake warning symbol on the dash. Clean it up and solder it together again:
Solder is very soft and will wear just as nicely as the metal that was there before, so the “sensor” will still work. Just refit.