def _record_new_keys(self) -> set[str]:
        """Records new keys that have not been logged before."""
        current_keys = set().union(*self.metrics)
        new_keys = current_keys - set(self.metrics_keys)
        self.metrics_keys.extend(new_keys)
        self.metrics_keys.sort()
        return new_keys
Records new keys that have not been logged before.
src/lightning/fabric/loggers/csv_logs.py