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 deficiency in scurvy. This unusual amino acid is also present in considerable amounts in the major glycoprotein of primary plant cell walls.