I was solving the exercises and got stuck when trying to solve this with tools of residual calculus $$ \int_{0}^{2 \pi} \frac{\cos (z)}{2 + \cos (z)} \, dz = \int_{0}^{2 \pi} f(z) \, dz. $$
Isolated singularities are at $z = \pi (2k+1) - i \log(2 \pm \sqrt{3}),\ k \in \mathbb{Z}$. Also I noticed that constructing a rectangular path (let's say a positively oriented square of length $2 \pi$) has a nice property that vertical parts cancel each other out which leaves me with $$ \int_{0}^{2 \pi} f(z) \, dz + \int_{2 \pi}^{0} f(z+2 \pi i) \, dz = 2 \pi i \cdot \operatorname{Res} \left[ f(z), z = \pi- i \log(2 - \sqrt{3}) \right]; \\ \int_{0}^{2 \pi} \frac{\cos (z)}{2 + \cos (z)} \, dz = \frac{-4 \pi}{\sqrt{3}} + \int_{0}^{2 \pi} \frac{\cos (z+2 \pi i)}{2 + \cos (z+2 \pi i)} \, dz. $$
Numerical calculation reveals that the last integral is just $2 \pi$... Am I missing something obvious? Or maybe there is a smarter way to obtain this result?
If we substitute $w = e^{iz}$, we obtain
$$\int_0^{2\pi} \frac{\cos z}{2+\cos z}\,dz = \int_{\lvert w\rvert = 1} \frac{\frac{1}{2}(w+w^{-1})}{2+\frac{1}{2}(w+w^{-1})}\, \frac{dw}{iw} = -i\int_{\lvert w\rvert = 1} \frac{w^2+1}{w(w^2+4w+1)}\,dw,$$
which can be evaluated directly with the residue theorem. We get something that can be evaluated with a little less work if we first note that
$$\int_0^{2\pi} \frac{\cos z}{2+\cos z}\,dz = \int_0^{2\pi} \frac{e^{iz}}{2+\cos z}\,dz$$
by periodicity and parity (the denominator is even, the imaginary part of the numerator is odd), then substituting $w = e^{iz}$ yields
$$-i\int_{\lvert w\rvert = 1} \frac{2w}{w^2+4w+1}\,dw.$$
The zeros of the denominator are $-2\pm\sqrt{3}$, hence for the residue inside the unit disk we obtain the value
$$\frac{2(\sqrt{3}-2)}{2(\sqrt{3}-2)+4} = \frac{\sqrt{3}-2}{\sqrt{3}} = 1 - \frac{2}{\sqrt{3}},$$
and
$$\int_0^{2\pi} \frac{\cos z}{2+\cos z}\,dz = 2\pi \left(1 - \frac{2}{\sqrt{3}}\right).$$
To integrate rational functions of $\sin$ and $\cos$ from $0$ to $2\pi$, it is usually a good strategy to substitute $w = e^{it}$. Sometimes, some symmetry considerations before the substitution can make things easier.