I am calculating TTFB (Time to First Byte) and other web vitals on a page using the web-vitals
javascript library.
The flow is like this:
In my page on server B, I measure TTFB.
Will the TTFB I measure include the time it took to get the redirect from server A?
Yes, TTFB as measured by the Chrome UX Report (the dataset that powers Google's Web Vitals program) includes redirect times.
The definition quoted on the Chrome UX Report docs linked above is:
Time to first byte (TTFB) is a measurement used as an indication of the responsiveness of a webserver or other network resource. TTFB measures the duration from the user or client making an HTTP request to the first byte of the page being received by the client's browser. This time is made up of the socket connection time, the time taken to send the HTTP request, and the time taken to get the first byte of the page.
From Wikipedia
The reason why redirects are included in the metric is because that's what end-users experience as they wait for a page to load. Measuring only a subset of that time may paint an unrealistic picture of the UX.
Borrowing a graphic from the Navigation Timing spec, TTFB is represented by the stages in the red box above.