Let $X$ be an arbitrary metric space and $f:X\to\mathbb R$ a bounded continuous function. Is it possible to choose a countable sequence $(A_n)_{n\in\mathbb N}$ of (preferably open or closed) subsets of $X$ such that $X=\bigcup_{n\in\mathbb N} A_n$ and $f$ is uniformly continuous on $A_n$ for each $n\in\mathbb N$?
That is, is every bounded continuous real-valued function on a metric space “$\sigma$-uniformly continuous?” I would prefer an answer without further assumptions (e.g., compactness, $\sigma$-compactness, local compactness, separability, completeness, total boundedness, etc.).
Thank you.
As a partial answer, here's an example where you can't take all of the $A_n$ to be open. Essentially, the idea is to diagonalize against a countable sequence of moduli of continuity.
Let $\Omega$ be the set of all continuous nondecreasing functions $\omega : [0,1] \to [0,1]$ with $\omega(0)=0$. Let $X = \Omega \times [0,1]$ with the metric $$d((\omega_1, x_1), (\omega_2, x_2)) = \begin{cases} |x_1 - x_2|, & \omega_1 = \omega_2 \\ 1, & \omega_1 \ne \omega_2 \end{cases}$$ That is, $X$ looks like a disjoint union of $|\Omega|$ many copies of $[0,1]$. Define $f : X \to \mathbb{R}$ by $f(\omega, x) = \omega(x)$, which is continuous and bounded.
Suppose now that $A_n$ is a sequence of open sets such that $f$ is uniformly continuous on $A_n$. Without loss of generality, we have $A_1 \subset A_2 \subset \dots$. Then for each $n$ there is a modulus of continuity $\omega_n : [0,1] \to [0,1]$, which can be taken to be continuous and nondecreasing, such that $d(f(p), f(q)) \le \omega_n(d(p,q))$ for all $p,q \in A_n$.
Now inductively construct numbers $x_n, y_n$ as follows. To start, let $x_0 = y_0 = 1$. Set $\epsilon_n = \min(y_n, 1/n)$ and choose $\delta_n$ such that $\omega_n(x) < \epsilon_n$ for $x < \delta_n$. Choose $x_n < \min(x_{n-1}, 1/n, \delta_n)$ and choose $y_n \in (\omega(x_n), \epsilon_n)$. Define $\omega$ by $\omega(x_n) = y_n$ with $\omega$ piecewise linear between $x_n$ and $x_{n+1}$, and $\omega(0)=0$, so $\omega$ is nondecreasing. Since $x_n \to 0$ and $y_n \to 0$, $\omega$ is continuous, thus $\omega \in \Omega$. Moreover, $\omega(x_n) > \omega_n(x_n)$.
By compactness, $\{\omega\} \times [0,1]$ is contained in some $A_N$. Now $|f(\omega,0) - f(\omega, x_N)| = \omega(x_N) > \omega_N(|0-x_N|)$ which is a contradiction.
Edit: I think we can even get a contradiction using this space without any assumptions on the $A_n$, essentially by constructing an $\omega$ that does not have modulus of continuity $\omega_n$ on any interval, and then using Baire category. The details are a bit tedious though, so I will skip it since the example of Izzo (see other answer) is better anyway (for instance it is separable).