I want to prove the following statement:
Let $f:X \to Y$ be a continuous function between metric spaces, and suppose there is a dense subset $Z$ of $X$ such that $f|_Z : Z \to Y$ is an isometry. Then $f$ is also an isometry.
This is my attempt:
Let $x_1,x_2 \in X.$ (I will write the metric as $| ~~|$ for convenience.) We have to show that $|x_1-x_2|=|f(x_1)-f(x_2)|$. Let $\epsilon >0$. Since $f$ is continuous, there is a $\delta_1>0$ such that $|x-x_1|<\delta_1 \implies |f(x)-f(x_1)|<\epsilon$, and similarly there is a $\delta_2$ for $x_2$. Put $\delta=\min \{ \delta_1, \delta_2, \epsilon \}$. Since $Z$ is dense in $X$ we can choose $z_1,z_2 \in Z$ so that $|x_i-z_i|<\delta ~(i=1,2)$. Now we have
$$ |f(x_1)-f(x_2)|\leq |f(x_1)-f(z_1)|+|f(z_1)-f(z_2)|+|f(z_2)-f(x_2)| <2 \epsilon +|z_1-z_2|\leq 2\epsilon +|z_1-x_1|+|x_1-x_2|+|x_2-z_2|<4\epsilon +|x_1-x_2|$$
so we conclude $|f(x_1)-f(x_2)|\leq |x_1-x_2|$. Similarly we can obtain the opposite inequality.
Is my argument fine?
You can argue as follows: given $x_1,x_2\in X$, by density you have $(x_{1n})\subset Z$ and $(x_{2n})\subset Z$ such that $x_{1n}\to x_1$ and $x_{2n}\to x_2$. Since $f$ is an isometry on $Z$, $dist_Y(f(x_{1n}),f(x_{2n}))=dist_X(x_{1n},x_{2n})$ for all $n$. At this point you resort to the continuity of $f$ and that of the metric to conclude.