Diesel isn't as flammable/explosive as gasoline, but here in my state, an in-cab fuel gauge, by law, will not pass safety inspection.
One must isolate the fuel line with an adapter or snubber as some call it - it allows the preassure to be sent to the gauge without pumping fuel to it.
It also adds life to the gauge - without a snubber the mechanical fuel pump will pulse the gauge with each stroke.
It wasn't fuel, but one time while cruising at about 8,000 feet (in the air), I had a mechanical oil gauge wear through the line right at the firewall in a rented Comanche. 'Till we found a place to put down the engine was toast, and the entire cabin, including myself and passenger, thoroughly oiled! The principle is the same. It is always a good rule to keep hot flammable liquids outside where they belong.
Bob