  Let $(M,g)$ be a smooth Anosov Riemannian manifold and $\mathcal{C}^\sharp$
the set of its primitive closed geodesics. Given a Hermitian vector bundle
$\mathcal{E}$ equipped with a unitary connection $\nabla^{\mathcal{E}}$, we
define $\mathcal{T}^\sharp(\mathcal{E}, \nabla^{\mathcal{E}})$ as the sequence
of traces of holonomies of $\nabla^{\mathcal{E}}$ along elements of
$\mathcal{C}^\sharp$. This descends to a homomorphism on the additive moduli
space $\mathbb{A}$ of connections up to gauge $\mathcal{T}^\sharp: (\mathbb{A},
\oplus) \to \ell^\infty(\mathcal{C}^\sharp)$, which we call the
$\textit{primitive trace map}$. It is the restriction of the well-known
$\textit{Wilson loop}$ operator to primitive closed geodesics.
  The main theorem of this paper shows that the primitive trace map
$\mathcal{T}^\sharp$ is locally injective near generic points of $\mathbb{A}$
when $\dim(M) \geq 3$. We obtain global results in some particular cases: flat
bundles, direct sums of line bundles, and general bundles in negative curvature
under a spectral assumption which is satisfied in particular for connections
with small curvature. As a consequence of the main theorem, we also derive a
spectral rigidity result for the connection Laplacian.
  The proofs are based on two new ingredients: a Liv\v{s}ic-type theorem in
hyperbolic dynamical systems showing that the cohomology class of a unitary
cocycle is determined by its trace along closed primitive orbits, and a theorem
relating the local geometry of $\mathbb{A}$ with the Pollicott-Ruelle resonance
near zero of a certain natural transport operator.
