{"id":24624865,"url":"https://github.com/agencypmg/queue-cloudwatch","last_synced_at":"2025-03-19T07:37:30.365Z","repository":{"id":57043072,"uuid":"78772348","full_name":"AgencyPMG/queue-cloudwatch","owner":"AgencyPMG","description":"Track your pmg/queue with CloudWatch metrics","archived":false,"fork":false,"pushed_at":"2024-01-05T15:45:29.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-01-25T04:11:54.021Z","etag":null,"topics":["aws","cloudwatch-metrics","metrics","php","pmg-queue","pmg-queue-driver","queue"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AgencyPMG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-12T18:02:54.000Z","updated_at":"2024-02-06T15:13:57.000Z","dependencies_parsed_at":"2023-02-09T12:46:27.298Z","dependency_job_id":null,"html_url":"https://github.com/AgencyPMG/queue-cloudwatch","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgencyPMG%2Fqueue-cloudwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgencyPMG%2Fqueue-cloudwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgencyPMG%2Fqueue-cloudwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgencyPMG%2Fqueue-cloudwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgencyPMG","download_url":"https://codeload.github.com/AgencyPMG/queue-cloudwatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244382632,"owners_count":20443871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cloudwatch-metrics","metrics","php","pmg-queue","pmg-queue-driver","queue"],"created_at":"2025-01-25T04:11:58.743Z","updated_at":"2025-03-19T07:37:30.345Z","avatar_url":"https://github.com/AgencyPMG.png","language":"PHP","readme":"# Queue CloudWatch\n\nA `pmg/queue` driver decorator that dispatches cloudwatch metrics when messages\nare sent through.\n\n## Example\n\n```php\nuse AWS\\CloudWatch\\CloudWatchClient;\nuse PMG\\Queue\\Driver;\nuse PMG\\Queue\\CloudWatch\\MetricsDriver;\n\n/** @var Driver $driver */\n$driver = createAnActualDriverSomehow();\n\n// this is the default metric namespace, change if desired.\n$metricNamespace = 'PMG/Queue';\n$finalDriver = new MetricsDriver($driver, CloudWatchClient::factory([\n    'region' =\u003e 'us-east-1',\n    'version' =\u003e 'latest',\n]), $metricNamespace);\n\n// now use $finalDriver in your consumers/producers\n```\n\n## Metrics\n\nAll metrics have the dimensions...\n\n- `QueueName` - The name of the queue to which the metrics belong\n- `MessageName` - The value returned from `Message::getName`. When a message is\n  not present for logging the metric, this dimension will be set to `__none__`.\n\n### Driver Metrics\n\n- `DriverError` - A `Count` metric unit fired when the wrapped driver throws a\n  `DriverError` exception. This will have an `ErrorClass` dimension that contains\n  the exception class name that was thrown.\n\n### Message Counts\n\nThere's a metric for each method on the driver, essentially. They all use\n`Count` as the metric unit.\n\n- `MessageEnqueue` - Fired on `Driver::enqueue`\n- `MessageDequeue` - Fired on `Driver::dequeue`. This is only fired when a\n  message is returned from the wrapped `Driver::dequeue`.\n- `MessageSuccess ` - Fired on `Driver::ack`\n- `MessageFailure` - Fired on `Driver::fail`\n- `MessageRetry` - Fired on `Driver::retry`\n- `MessageRelease` - Fired on `Driver::release`\n\nYou might use these message counts to alert on a high volume of message\nfailures or retries.\n\n### Message Timers\n\nThe metrics driver will time dequeued jobs until they are acked, failed, or\nretried. These all use `Milliseconds` as their metric unit.\n\n- `MessageTime` - The amount of time a message took, tracked for every message\n  regardless of how it finished.\n\nThe `MessageTime` metric will have an additional dimension named `MessageStatus`\nwhich is how the given message finished when the timer completed. This will be:\n\n- `Success` when the message was passed to `Driver::ack`\n- `Failure` when the message was passed to `Driver::fail`\n- `Retry` When the message was passed to `Driver::retry`\n- `Release` When the message was passed to `Driver::release`\n\n## Error Handling\n\nFirst up, the wrapped driver is *always* called first. If an error occurs from\nthe wrapped driver it's tracked and rethrown before any further metrics can be\nlogged. The idea here is that driver errors invalidate any processes acting on a\nmessage anyway.\n\nErrors from the cloudwatch client are caught and logged, however. You can pass a\nfourth `$logger` argument to `MetricsDriver` if you wish to see these errors,\nbut a `NullLogger` is used by default.\n\n```php\nuse AWS\\CloudWatch\\CloudWatchClient;\nuse PMG\\Queue\\Driver;\nuse PMG\\Queue\\CloudWatch\\MetricsDriver;\n\n/** @var Driver $driver */\n$driver = createAnActualDriverSomehow();\n\n// this is the default metric namespace, change if desired.\n$metricNamespace = 'PMG/Queue';\n$finalDriver = new MetricsDriver($driver, CloudWatchClient::factory([\n    'region' =\u003e 'us-east-1',\n    'version' =\u003e 'latest',\n]), $metricNamespace, $yourLoggerFromSomeplace);\n\n// now use $finalDriver in your consumers/producers\n```\n\n## Testing\n\n```\n./vendor/bin/phpunit\n```\n\nThe tests include a set of integration tests that actually talk to CloudWatch.\nBe sure to have [set up credentials](http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html).\nin order to run those tests. Otherwise you may exclude them with...\n\n```\n./vendor/bin/phpunit --exclude-group integration\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagencypmg%2Fqueue-cloudwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagencypmg%2Fqueue-cloudwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagencypmg%2Fqueue-cloudwatch/lists"}