Let's say we have a massless QED theory with a Lagrangian
\begin{equation} L=i\bar{\psi}\not{D}\psi-\frac{1}{4}F_{\mu\nu}F^{\mu\nu} \end{equation}
The symmetric energy-momentum tensor is
\begin{equation} \Theta^{\mu\nu}=\frac{1}{2}\bar{\psi}\Big\{\gamma^\mu D^\nu+\gamma^\nu D^\mu\Big\}\psi-\eta^{\mu\nu}i\bar{\psi}\not{D}\psi-F^{\mu\lambda}F^\nu_{\ \lambda}+\frac{1}{4}\eta^{\mu \nu}F^{\sigma\lambda}F_{\sigma\lambda} \end{equation}
The trace of this operator is
\begin{equation} \Theta^\mu_{\ \mu}=\big(1-d\big)i\bar{\psi}\not{D}\psi+\big(\frac{d}{4}-1\big)F^{\sigma\lambda}F_{\sigma\lambda} \end{equation}
The fermionic part is zero if we use Dirac's equation, which can be stated as "The energy-momentum tensor is traceless on-shell". On the other hand, if we are working on a $d=4$ spacetime, the photon part is inmediately traceless.
The last equation works if $\Theta^\mu _{\ \mu}$ is a quantum operator as well, since the equations of motion work for operators too. My question is: How is the path integral insertion $\langle\Theta^\mu_{\ \mu}\rangle$ not inmediately zero?
My preliminary answer is that when you actually calculate that using
\begin{equation} \langle\Theta^\mu_{\ \mu}\rangle=\int\mathcal{D}\psi\mathcal{D}A_\mu\Theta^\mu_{\ \mu}e^{-S_E} \end{equation}
the operator inside the path integral is not on-shell, which means that it is not zero. However, if we were working only with the photon field in $d=4$ then there's no way $\langle\Theta^\mu_{\ \mu}\rangle$ is not zero.
Is my reasoning correct?