In the first expression (judging purely on the basis of the formal expression), the index $a$ would normally represent some internal degree of freedom such as spin. In that case, it is not an index of a discrete set of functions. A path integral involves a continuous set of functions ("paths"). Therefore you would need the functional integration over all these functions in addition to the summation over the spins.
The result of your expressions would then only be valid in the case where you have a discrete set of orthogonal functions and the index would label all these functions. That would not be the case for your first expression.
However, there is a way that people represent functional integrals so that they come closer to ordinary integrals. This approach seems to be what the text in the linked book does. The assumption is that the elements of functional space can be expanded in terms of some orthonormal basis of functions
$$ \psi(\mathbf{x}) = \sum_n \phi_n \Phi_n(\mathbf{x}) . $$
Here $\Phi_n(\mathbf{x})$ represents an element of a discrete (countable) infinite set of functions and $\phi_n$ denotes the coefficients. The functional integration measure is then represented as
$$ \mathcal{D}[\psi] = \Pi_n \text{d} \phi_n . $$
In other words, a functional integral would be represented by
$$ \int W[\psi] \mathcal{D}[\psi] = \int W(\phi_n) \Pi_n \text{d} \phi_n . $$
So the integral runs over all the (infinite number of) coefficients.
To evaluate a trace in this context, we need to assume that there are complete sets of states associated with each element of the basis. In other words, if we pick $\Phi_n(\mathbf{x})$ with a specific $n$, then we have a complete orthogonal basis $|\phi_n\rangle$ associated with this chosen function. The different values of the associated coefficient parameterizes the respective elements of this basis. Since the coefficient vary continuously, the associated basis must also be a continuous basis. The trace is now evaluated by performing the overlap of the functional with all the elements of all these bases. For each basis, we need to integrate over the coefficient that labels the elements of the continuous basis. Then we also need to sum over all the different basis. Therefore, such a trace takes the form of the OP's first expression.