Download the PHP package skukunin/messenger-stats-bundle without Composer

On this page you can find all versions of the php package skukunin/messenger-stats-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package messenger-stats-bundle

Messenger Stats Bundle for Symfony

CI

A Symfony bundle that adds queue statistics, a health check and Prometheus metrics for Symfony Messenger transports. Install it with Composer, register it in config/bundles.php, and it works with Symfony 5.4, 6.4 and 7.x on PHP 8.1+.

The bundle reads the state of every Messenger transport configured in your application and exposes it four ways:

Route / command Format Meant for
GET /_messenger/stats JSON humans, dashboards, custom monitors
GET /_messenger/health 200 or 503 uptime checkers (Uptime Kuma, Pingdom, Better Stack)
GET /_messenger/metrics Prometheus text Prometheus, Grafana, Alertmanager
bin/console messenger:stats table or JSON SSH sessions, cron checks

It only reads. It never consumes, retries or removes messages.

What you get

For every Doctrine transport (doctrine://…), per queue:

For the failure transport, the message count, the class breakdown and the last N failed messages with message class, exception class and message, failure time, retry count and original transport. It has no per-state breakdown: nothing consumes it automatically, so every message would only show up as "pending". Message bodies and stack traces are never exposed.

For any other transport (AMQP, Redis, SQS, Beanstalkd, …) the bundle reports the message count when the transport supports it, and nothing else.

A transport that cannot be read (database down, broker unreachable) is reported as unavailable with the exception class. The rest of the report is still returned.

Requirements

Installation

Register the bundle if Flex did not:

Import the routes under a prefix of your choice:

Configure a token:

That is all. Transports are discovered from framework.messenger.transports.

Security

The bundle authenticates its own routes. You do not need a firewall entry in security.yaml for them. If a catch-all firewall in your application would otherwise demand a login or HTTP basic credentials on the prefix, give the prefix its own firewall with security: false, so the bearer token is the only check:

The report exposes message class names, queue depths and exception messages. Treat the token like any other operational secret. If exception messages in your application may contain personal data, set failures.expose_message: false.

Configuration reference

storage_timezone is the timezone the Doctrine transport writes its timestamps in. Messenger 6.3 and later write UTC; Messenger 5.4 to 6.2 write PHP's default timezone (date.timezone). auto picks the right one from the installed symfony/doctrine-messenger version when the container is compiled, and falls back to the default timezone when the version cannot be read. On Messenger < 6.3 the web server, the CLI and the workers must share one date.timezone (Messenger already requires that); set storage_timezone explicitly if they do not, or if the container is compiled under a different timezone than the workers run in.

sync:// and in-memory:// transports are always skipped.

The report also carries app (from app_name) and env (the kernel environment), so several applications and environments can share one Prometheus or one monitor.

Thresholds and health

Without thresholds the report's status is always ok and /health always answers 200. Alerting is then the job of whatever reads /stats or /metrics.

With thresholds the bundle evaluates the report itself:

A level is breached when the value is greater than or equal to the threshold. The report gains status (ok, warning, critical) and a problems list, /health answers 503 on critical, and messenger:stats exits with code 1.

Available metrics per transport: pending, delayed, in_progress, stuck, oldest_pending_age_seconds, failed (only meaningful on the failure transport) and count (the only one available for non-Doctrine transports). On the failure transport only failed and count are allowed. A threshold on a transport that does not exist, or a pending, delayed, in_progress, stuck or oldest_pending_age_seconds threshold on the failure transport, fails container compilation.

An unavailable transport counts as critical when it has thresholds configured and as warning otherwise.

The JSON report

schema_version changes only when a field is removed or renamed.

Uptime checkers

Point any HTTP monitor at /_messenger/health with the header Authorization: Bearer <token>. It answers 503 when a threshold is critical, so the checker's normal "site down" alert becomes your queue alert.

Uptime Kuma: monitor type HTTP(s), URL https://example.com/_messenger/health, Headers {"Authorization": "Bearer <token>"}. Attach your usual Slack, Teams or e-mail notification.

For a rule without host-side thresholds, use Uptime Kuma's HTTP(s) - Json Query type against /_messenger/stats with an expression such as $.transports.failed.count and the condition < 10.

Prometheus and Grafana

Exposed families, all gauges with app and env labels:

Metric Labels Meaning
messenger_transport_up transport 1 when the transport could be read
messenger_transport_messages transport total messages
messenger_queue_messages transport, queue, state messages per state
messenger_queue_oldest_pending_age_seconds transport, queue age of the oldest pending message
messenger_queue_class_messages transport, queue, class messages per class, sampled
messenger_failed_messages transport messages in the failure transport
messenger_failed_class_messages transport, class messages per class in the failure transport, sampled
messenger_health_status 0 ok, 1 warning, 2 critical

Example alert rules:

Console

--format=json prints the same document as /stats. The exit code is 1 when the status is critical, which makes the command usable from cron on hosts without any HTTP monitoring.

Troubleshooting

UnexpectedSessionUsageException: Session was used while the request was declared stateless. The bundle's routes are stateless, and something in your application reads or writes the session on every request, typically a kernel.response subscriber. In debug mode Symfony turns that into a 500. In production it only logs a warning, but every poll by a monitor then starts a session and sends a cookie. Skip stateless requests in that subscriber:

How it works

Throughput (messages processed per minute), worker process liveness, and non-Doctrine transport details beyond the message count. The report is computed on every request; put a scrape interval or an uptime interval in front of it rather than expecting caching.

Contributing

GrumPHP installs a pre-commit hook that runs the same checks on the unit suite. Integration tests run on SQLite by default and against MySQL when DATABASE_URL is set.

License

Released under the MIT License.


All versions of messenger-stats-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
doctrine/dbal Version ^2.13 || ^3.0 || ^4.0
doctrine/persistence Version ^2.2 || ^3.0 || ^4.0
psr/container Version ^1.1 || ^2.0
psr/log Version ^1 || ^2 || ^3
symfony/config Version ^5.4 || ^6.4 || ^7.0
symfony/console Version ^5.4 || ^6.4 || ^7.0
symfony/dependency-injection Version ^5.4 || ^6.4 || ^7.0
symfony/doctrine-messenger Version ^5.4 || ^6.4 || ^7.0
symfony/event-dispatcher Version ^5.4 || ^6.4 || ^7.0
symfony/framework-bundle Version ^5.4 || ^6.4 || ^7.0
symfony/http-foundation Version ^5.4 || ^6.4 || ^7.0
symfony/http-kernel Version ^5.4 || ^6.4 || ^7.0
symfony/messenger Version ^5.4 || ^6.4 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package skukunin/messenger-stats-bundle contains the following files

Loading the files please wait ...