Skip to content

Update README.md #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ app_http_requests_count{endpoint="catalog/products",code="200",tenant="JBZ-987-H
Такие метрики можно рассчитывать в момент сбора метрик прометеусом.
Для этого вам нужно создать т.н. on demand метрику. Это класс, в котором вы регистрируете метрики и устанавливаете в них значения.
```php
class QueueLengthOnDemandMetric extends OnDemandMetric {
use Ensi\LaravelPrometheus\OnDemandMetrics\OnDemandMetric;

class QueueLengthOnDemandMetric implements OnDemandMetric {
public function register(MetricsBag $metricsBag): void
{
$metricsBag->gauge('queue_length');
Expand All @@ -206,7 +208,9 @@ class QueueLengthOnDemandMetric extends OnDemandMetric {
}
}
```
Затем зарегистрируйте метрику через `Prometheus::addOnDemandMetric(QueueLengthOnDemandMetric::class);`

Обновление таких метрик происходит в момент обращения прометеуса к эндпоинту получения метрик.

## License
Laravel Prometheus is open-sourced software licensed under the [MIT license](LICENSE.md).
Laravel Prometheus is open-sourced software licensed under the [MIT license](LICENSE.md).