pmg / metrics
通用的指标,PHP 风格。
v0.2.0
2021-10-26 20:53 UTC
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-08-27 02:36:57 UTC
README
警告:目前这是一个非常不稳定的软件。PMG 正在根据需要添加功能。
核心概念
- 收集器 在应用程序生命周期过程中收集指标,并将它们存储在本地(通常仅在内存中)。
- 报告器 从收集器中清除的 指标集,并将其发送到真正的指标后端(如 cloudwatch)。
- 指标 是对应用程序进行的一种测量。有多种类型。
- 仪表 是在某个时间点获取的静态值。
使用示例
use PMG\Metrics\Metrics; use PMG\Metrics\Gauge; $collector = Metrics::collector(); // track `someName` with a count gauge with a value of 10 $collector->gauge('someName', Gauge::count(10)); // Same as the above but tag `someName` with dimensions $collector->gauge( Metrics::name('someName')->dimension('example', '1'), Gauge::count(10) ); /* @var Reporter $reporter **/ $reporter->reportOn($collector->flush()); // $collector is now empty and ready to go