spiral / roadrunner-metrics
RoadRunner: Prometheus metrics RPC
Installs: 128 833
Dependents: 3
Suggesters: 0
Security: 0
Stars: 2
Watchers: 8
Forks: 1
Open Issues: 1
Requires
- php: >=7.4
- spiral/goridge: ^3.0
- symfony/polyfill-php80: ^1.22
Requires (Dev)
- jetbrains/phpstorm-attributes: ^1.0
- phpunit/phpunit: ~8.0
- vimeo/psalm: ^4.4
Suggests
- spiral/roadrunner-cli: Provides RoadRunner installation and management CLI tools
This package is auto-updated.
Last update: 2023-01-18 22:05:48 UTC
README
RoadRunner is an open-source (MIT licensed) high-performance PHP application server, load balancer, and process manager. It supports running as a service with the ability to extend its functionality on a per-project basis.
RoadRunner includes PSR-7/PSR-17 compatible HTTP and HTTP/2 server and can be used to replace classic Nginx+FPM setup with much greater performance and flexibility.
Official Website | Documentation
Repository:
This repository contains the codebase used to publish Prometheus metrics from PHP application. Check spiral/roadrunner to get application server.
Installation:
To install RoadRunner extension:
$ composer require spiral/roadrunner-http spiral/roadrunner-metrics nyholm/psr7 $ vendor/bin/rr get-binary
Enable metrics service in your .rr.yaml
file:
rpc: listen: tcp://127.0.0.1:6001 server: command: "php worker.php" http: address: "0.0.0.0:8080" metrics: address: "0.0.0.0:8081"
Example:
To publish metrics from your application worker:
<?php use Spiral\Goridge; use Spiral\RoadRunner; use Nyholm\Psr7\Factory; ini_set('display_errors', 'stderr'); include "vendor/autoload.php"; $worker = new RoadRunner\Http\PSR7Worker( RoadRunner\Worker::create(), new Factory\Psr17Factory(), new Factory\Psr17Factory(), new Factory\Psr17Factory() ); $metrics = new RoadRunner\Metrics\Metrics( Goridge\RPC\RPC::create(RoadRunner\Environment::fromGlobals()->getRPCAddress()) ); $metrics->declare( 'test', RoadRunner\Metrics\Collector::counter()->withHelp('Test counter') ); while ($req = $worker->waitRequest()) { try { $rsp = new \Nyholm\Psr7\Response(); $rsp->getBody()->write("hello world"); $metrics->add('test', 1); $worker->respond($rsp); } catch (\Throwable $e) { $worker->getWorker()->error((string)$e); } }
Testing:
This codebase is automatically tested via host repository - spiral/roadrunner.
License:
The MIT License (MIT). Please see LICENSE
for more information. Maintained
by Spiral Scout.