Slic3r and Kisslicer (and probably others too) put the volume of the filament that will be used into comments in the gcode file. I usually take that value (specified in cm3) and multiply it by the density of the filament (g/cm3) to get the mass of the filament that will be used.

Length of filament is difficult to measure when you have a partial spool. You can keep track by maintaining a running length of filament, but in order to verify what you have left, you'd have to unwind your spool. So I use mass -- I can just weigh the spool before I print anything and weigh it periodically to know how much is left. This is particularly helpful on larger prints or when the spool is running low.

If I don't have enough, I can estimate how long it will last in a print. When I get to the tail end I can pause the print (through whatever host software I am using), pull out the tail end of what's left, and load up a new spool before resuming the print. I also raise the nozzle so it won't melt what I am in the middle of printing while I am changing filament. I don't know if it's necessary, but I set the temp on the nozzle manually when I pause the print so that when it resumes it for sure hasn't lost heat.