To an astronomer, oxygen and carbon count as metals
Astronomers lump every element heavier than helium together as metals, even gases like oxygen that chemists would never call metallic. The quirky shorthand hides a useful clock: because stars forge these elements and scatter them into space, a star's metal content reveals roughly which generation it belongs to.
Nearly all ordinary matter is hydrogen or helium. Heavier elements are made inside stars as they age, then returned to space by stellar winds and supernova explosions, enriching the gas from which new stars form. So the first stars, born into a pristine universe, contained almost no metals, while later generations inherited progressively more. Astronomers often summarize a star's makeup with three numbers: X for the mass share of hydrogen, Y for helium, and Z for everything else.
The odd vocabulary dates to the birth of spectroscopy. In 1802 William Hyde Wollaston spotted dark lines in sunlight, and from 1814 Joseph von Fraunhofer measured them carefully, mapping more than 570. About 45 years later Gustav Kirchhoff and Robert Bunsen matched several with the bright lines given off by heated elements and realized that substances in the Sun's atmosphere were absorbing light. The strongest visible lines came from sodium, potassium and iron, and early analyses detected only hydrogen and assorted metals, so metallic stuck as a label for the rest.
Today metallicity is usually quoted as iron relative to hydrogen, compared with the Sun on a logarithmic scale measured in dex. A star at plus 1 has ten times the Sun's proportion of iron; at minus 1, a tenth. Iron is favoured because it builds up fairly steadily over cosmic time and leaves hundreds of sharp absorption lines, even though oxygen is actually the most abundant heavy element.
In 1944 Walter Baade divided stars into population I, young and metal-rich, and population II, older and metal-poor. A third group, population III, was proposed in 1978 for the very first stars, thought to hold under a millionth of the Sun's iron. Even the Sun's own figure proved slippery: a 1998 measurement created a long-running clash between models of the solar interior and observations of its vibrations, finally resolved by a 2022 reanalysis that agreed with pre-1998 values.
Source: Metallicity