A spectral survey of an ultra-hot Jupiter. Detection of metals in the transmission spectrum of KELT-9 b