Inline and online measurements of contamination