PHPackages                             pmg/queue-cloudwatch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. pmg/queue-cloudwatch

ActiveLibrary[Queues &amp; Workers](/categories/queues)

pmg/queue-cloudwatch
====================

Track your queue with CloudWatch metrics

v8.0.0(4mo ago)08.3kApache-2.0PHPPHP ^8.3CI passing

Since Aug 31Pushed 3mo ago15 watchersCompare

[ Source](https://github.com/AgencyPMG/queue-cloudwatch)[ Packagist](https://packagist.org/packages/pmg/queue-cloudwatch)[ RSS](/packages/pmg-queue-cloudwatch/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (5)Versions (11)Used By (0)

Queue CloudWatch
================

[](#queue-cloudwatch)

A `pmg/queue` driver decorator that dispatches cloudwatch metrics when messages are sent through.

Example
-------

[](#example)

```
use AWS\CloudWatch\CloudWatchClient;
use PMG\Queue\Driver;
use PMG\Queue\CloudWatch\MetricsDriver;

/** @var Driver $driver */
$driver = createAnActualDriverSomehow();

// this is the default metric namespace, change if desired.
$metricNamespace = 'PMG/Queue';
$finalDriver = new MetricsDriver($driver, CloudWatchClient::factory([
    'region' => 'us-east-1',
    'version' => 'latest',
]), $metricNamespace);

// now use $finalDriver in your consumers/producers
```

Metrics
-------

[](#metrics)

All metrics have the dimensions...

- `QueueName` - The name of the queue to which the metrics belong
- `MessageName` - The value returned from `Message::getName`. When a message is not present for logging the metric, this dimension will be set to `__none__`.

### Driver Metrics

[](#driver-metrics)

- `DriverError` - A `Count` metric unit fired when the wrapped driver throws a `DriverError` exception. This will have an `ErrorClass` dimension that contains the exception class name that was thrown.

### Message Counts

[](#message-counts)

There's a metric for each method on the driver, essentially. They all use `Count` as the metric unit.

- `MessageEnqueue` - Fired on `Driver::enqueue`
- `MessageDequeue` - Fired on `Driver::dequeue`. This is only fired when a message is returned from the wrapped `Driver::dequeue`.
- `MessageSuccess ` - Fired on `Driver::ack`
- `MessageFailure` - Fired on `Driver::fail`
- `MessageRetry` - Fired on `Driver::retry`
- `MessageRelease` - Fired on `Driver::release`

You might use these message counts to alert on a high volume of message failures or retries.

### Message Timers

[](#message-timers)

The metrics driver will time dequeued jobs until they are acked, failed, or retried. These all use `Milliseconds` as their metric unit.

- `MessageTime` - The amount of time a message took, tracked for every message regardless of how it finished.

The `MessageTime` metric will have an additional dimension named `MessageStatus`which is how the given message finished when the timer completed. This will be:

- `Success` when the message was passed to `Driver::ack`
- `Failure` when the message was passed to `Driver::fail`
- `Retry` When the message was passed to `Driver::retry`
- `Release` When the message was passed to `Driver::release`

Error Handling
--------------

[](#error-handling)

First up, the wrapped driver is *always* called first. If an error occurs from the wrapped driver it's tracked and rethrown before any further metrics can be logged. The idea here is that driver errors invalidate any processes acting on a message anyway.

Errors from the cloudwatch client are caught and logged, however. You can pass a fourth `$logger` argument to `MetricsDriver` if you wish to see these errors, but a `NullLogger` is used by default.

```
use AWS\CloudWatch\CloudWatchClient;
use PMG\Queue\Driver;
use PMG\Queue\CloudWatch\MetricsDriver;

/** @var Driver $driver */
$driver = createAnActualDriverSomehow();

// this is the default metric namespace, change if desired.
$metricNamespace = 'PMG/Queue';
$finalDriver = new MetricsDriver($driver, CloudWatchClient::factory([
    'region' => 'us-east-1',
    'version' => 'latest',
]), $metricNamespace, $yourLoggerFromSomeplace);

// now use $finalDriver in your consumers/producers
```

Testing
-------

[](#testing)

```
./vendor/bin/phpunit

```

The tests include a set of integration tests that actually talk to CloudWatch. Be sure to have [set up credentials](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html). in order to run those tests. Otherwise you may exclude them with...

```
./vendor/bin/phpunit --exclude-group integration

```

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance80

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 65.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~510 days

Recently: every ~529 days

Total

7

Last Release

122d ago

Major Versions

1.0.0 → v5.0.02020-03-31

v5.1.0 → v6.0.02023-01-12

v6.0.0 → v7.0.02025-06-12

v7.0.0 → v8.0.02026-01-15

PHP version history (5 changes)1.0.0PHP ~7.0

v5.0.0PHP ^7.3

v5.1.0PHP ^7.4 || ^8.0

v6.0.0PHP ^8.0

v7.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/d396af79150164dd4d28f3e816b377e2f3c04df431d8338477517efa0013664c?d=identicon)[chrisguitarguy](/maintainers/chrisguitarguy)

---

Top Contributors

[![chrisguitarguy](https://avatars.githubusercontent.com/u/1010392?v=4)](https://github.com/chrisguitarguy "chrisguitarguy (25 commits)")[![jrughani9](https://avatars.githubusercontent.com/u/108751272?v=4)](https://github.com/jrughani9 "jrughani9 (10 commits)")[![WebCu](https://avatars.githubusercontent.com/u/3429093?v=4)](https://github.com/WebCu "WebCu (3 commits)")

---

Tags

awscloudwatch-metricsmetricsphppmg-queuepmg-queue-driverqueuequeuecloudwatch

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pmg-queue-cloudwatch/health.svg)

```
[![Health](https://phpackages.com/badges/pmg-queue-cloudwatch/health.svg)](https://phpackages.com/packages/pmg-queue-cloudwatch)
```

###  Alternatives

[php-amqplib/rabbitmq-bundle

Integrates php-amqplib with Symfony &amp; RabbitMq. Formerly emag-tech-labs/rabbitmq-bundle, oldsound/rabbitmq-bundle.

1.3k20.1M65](/packages/php-amqplib-rabbitmq-bundle)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[swarrot/swarrot

A simple lib to consume RabbitMQ queues

3654.4M8](/packages/swarrot-swarrot)[shiftonelabs/laravel-sqs-fifo-queue

Adds a Laravel queue driver for Amazon SQS FIFO queues.

1556.0M3](/packages/shiftonelabs-laravel-sqs-fifo-queue)[koco/messenger-kafka

Symfony Messenger Kafka Transport

931.1M1](/packages/koco-messenger-kafka)[enqueue/sqs

Message Queue Amazon SQS Transport

376.3M14](/packages/enqueue-sqs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
