zenstruck / messenger-monitor-bundle

Batteries included UI to monitor your Messenger workers, transports, schedules, and messages.
MIT License
152 stars 16 forks source link

Per message type statistics #74

Open bendavies opened 6 months ago

bendavies commented 6 months ago

Hi Kevin!

We're looking at moving from https://github.com/SymfonyCasts/messenger-monitor-bundle/ to this bundle.

One screen we like in the above is the displaying a table of Per message type statistics like this:

image

Does this bundle have a similar screen? (I couldn't see one)

Thanks!

SherinBloemendaal commented 1 month ago

I've done this by creating a ProcessedMessageRepository and by creating a custom sql query. But it requires some customisation.

Note: I am using PostgreSQL, when using MySQL the statements are different.

        ...

        $sql = $connection->createQueryBuilder()
            ->from('processed_message', 'm')
            ->select('m.message_type')
            ->addSelect('COUNT(m.id) as total_amount')
            ->addSelect(sprintf('AVG(%s) AS average_waiting_time', sprintf('extract(epoch from (%s - %s))', 'received_at', 'dispatched_at')))
            ->addSelect(sprintf('AVG(%s) AS average_handling_time', sprintf('extract(epoch from (%s - %s))', 'finished_at', 'received_at')))
            ->groupBy('m.message_type')
            ->getSQL()
        ;
        $statement = $connection->executeQuery($sql);

        ...
kbond commented 1 month ago

Thanks for posting your solution - this is indeed a great feature!