async def METHOD_NAME(session: DbSession, node_cache: NodeCache) -> Metrics:
    sync_messages_reference_total = await fetch_reference_total_messages()
    eth_reference_height = await fetch_eth_height()
    # select count(*) can be slow but estimates are not refreshed often enough to give
    # a meaningful sense of progress for the node main page on /.
    sync_messages_total: int = MessageDb.count(session=session)
    peers_count = PeerDb.count(session=session)
    eth_last_committed_height = get_last_height(
        session=session, chain=Chain.ETH, sync_type=ChainEventType.SYNC
    )
    if not (sync_messages_reference_total is None or sync_messages_total is None):
        sync_messages_remaining_total = (
            sync_messages_reference_total - sync_messages_total
        )
    else:
        sync_messages_remaining_total = None
    if eth_reference_height is not None and eth_last_committed_height is not None:
        # Some blocks may not contain Aleph messages, and therefore the last committed height
        # may be higher than the height of the last block containing Aleph messages.
        eth_remaining_height = max(eth_reference_height - eth_last_committed_height, 0)
    else:
        eth_remaining_height = None
    retry_message_job_tasks = await node_cache.get("retry_messages_job_tasks")
    nb_message_jobs = int(retry_message_job_tasks) if retry_message_job_tasks else 0
    return Metrics(
        pyaleph_build_info=pyaleph_build_info,
        pyaleph_status_peers_total=peers_count,
        pyaleph_processing_pending_messages_tasks_total=nb_message_jobs,
        pyaleph_status_sync_messages_total=sync_messages_total,
        pyaleph_status_sync_permanent_files_total=FilePinDb.count(session=session),
        pyaleph_status_sync_messages_reference_total=sync_messages_reference_total,
        pyaleph_status_sync_messages_remaining_total=sync_messages_remaining_total,
        pyaleph_status_sync_pending_messages_total=PendingMessageDb.count(
            session=session
        ),
        pyaleph_status_sync_pending_txs_total=PendingTxDb.count(session=session),
        pyaleph_status_chain_eth_last_committed_height=eth_last_committed_height,
        pyaleph_status_chain_eth_height_reference_total=eth_reference_height,
        pyaleph_status_chain_eth_height_remaining_total=eth_remaining_height,
    )