Most probably this question has more standard explanation, but you may use that for continuous Kernels $K(x,y)$ on a standard metric measure space $(X,\mu,\rho)$ ($(X,\mu)$ is a standard probabilistic space, $\rho$ an admissible metric, where admissiblity means that $\rho(x,y)$ is measurable on $X\times X$ and separable on a set of full measure) we have $\int K(x,x)\,d\mu(x)= \operatorname{tr}\mathcal{K}$ provided that the integral operator $\mathcal{K}$ with kernel $K$ is of trace class.
This may be proved by approximating $\mathcal{K}$ in a trace class by finite rank operators with kernels $\sum_{i=1}^N f_i(x)g_i(y)$, $f_i,g_i\in L^2(X)$ (such a possibility follows from a representation of $\mathcal K$ as an infinite convergent sum $\sum s_i \langle v_i,\cdot \rangle u_i$ for unit vectors $v_i,u_i$, where $s_i$ are singular numbers of $\mathcal K$) and the check that convergence in $S^1$-norm implies the convergence of the integral of kernels over diagonal to $\int K(x,x)\,d\mu(x)$. It may be deduced from Theorem 15 in [A. M. Vershik, P. B. Zatitskiy, and F. V. Petrov. Virtual continuity of measurable functions and its applications. Russian Mathematical Surveys 69:6 (2014), 1031–1063]: the convergence in $S^1$ implies the convergence in $VC^1$ which implies the convergence of the integral over diagonal (defined both for finite rank kernels and for cotinuous kernels.)