I want to evaluate $\int_\gamma \frac{z^2+1}{(z+1)(z+4)}dz$ if $\gamma = \alpha + \beta$, where $\alpha(t)=te^{it}$ for $0 \leq t \leq 4\pi$ and $\beta$ is a parametrization of the line segment joining $4 \pi$ and $0$.
I did the graph of $\alpha$ and $\beta$:
So $\gamma$ is a closed curve.
First, I tried to use the Cauchy's Theorem with $f(z)=\frac{z^2+1}{(z+1)(z+4)}$, but the conditions $\lim_{z \to -1} (z+1)f(z)=0$ and $\lim_{z \to -4} (z+4)f(z)=0$ are not satisfied.
Then, I tried to decomopose $\frac{z^2+1}{(z+1)(z+4)}$ into partial fractions $\frac{A}{z+1}+\frac{B}{z+4}$ to separate the integral into two integrals to use Cauchy's integral formula for each integral, but I failed to find $A$ and $B$.

HINT:
You had the right idea to use partial fraction expansion. So, note that we can write
$$\begin{align} \frac{z^2+1}{(z+1)(z+4)}&=1-\frac{5z+3}{(z+1)(z+4)}\\\\ &=1+\frac{2/3}{z+1}-\frac{17/3}{z+4} \end{align}$$
Can you finish now?