The chemical reactions and pathways involving 4-hydroxyproline, C5H9NO3, a derivative of the amino acid proline. The presence of hydroxyproline is essential to produce stable triple helical tropocollagen, hence the problems caused by ascorbate defici.