Implement stats command
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3579442. -->
Reported by: [dpi](https://www.drupal.org/user/81431)
Related to !52
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>When debugging a queue, sometimes its difficult, especially for some transports, to inspect the overall size of a queue. Especially for non SQL-like, or if CLI tools for the transport backend in question are not available.</p>
<p>Determining the size of the queue is also useful for autoscaling workers. For example, <a href="https://fly.io/docs/launch/autoscale-by-metric/">https://fly.io/docs/launch/autoscale-by-metric/</a></p>
<p>And programmatically retrieving the size (as an integer) simply becomes <code>sm messenger:stats asynchronous --format=json | jq '.transports.asynchronous.count // empty' || exit 1</code></p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Implement the stats command, as provided by Messenger component.</p>
<p>Add basic integration tests.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>Do it.</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>Only the `sm` CLI interface.</p>
<h3 id="summary-api-changes">API changes</h3>
<p>New services</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>None</p>
issue