4. Let the complex number $z=x+y i$ satisfy the ratio of the real part to the imaginary part of $\frac{z+1}{z+2}$ is $\sqrt{3}$, where $\mathrm{i}$ is the imaginary unit, $x, y \in \mathbb{R}$, then the range of $\frac{y}{x}$ is . $\qquad$
4. $\left[\frac{-3 \sqrt{3}-4 \sqrt{2}}{5}, \frac{-3 \sqrt{3}+4 \sqrt{2}}{5}\right]$

Analysis: $\frac{z+1}{z+2}=\frac{x+1+y i}{x+2+y i}=\frac{\left(x^{2}+3 x+2+y^{2}\right)+y i}{(x+2)^{2}+y^{2}}$, from the problem, we get $x^{2}+3 x+2+y^{2}=\sqrt{3} y$ which is: $\left(x+\frac{3}{2}\right)^{2}+\left(y-\frac{\sqrt{3}}{2}\right)^{2}=1$, let $y=k x$, then $\left(k^{2}+1\right) x^{2}+(3-\sqrt{3} k) x+2=0$. By $\Delta \geq 0$, we have $9+3 k^{2}-6 \sqrt{3} k \geq 8 k^{2}+8 \Leftrightarrow y \in\left[\frac{-3 \sqrt{3}-4 \sqrt{2}}{5}, \frac{-3 \sqrt{3}+4 \sqrt{2}}{5}\right]$.