Recall the basic formula for the expectation value of an observable $$A$$:
$\langle A \rangle = {1 \over Q(\beta)}{\rm Tr}(Ae^{-\beta H})$