PHP code example of flownative / prometheus
1. Go to this page and download the library: Download flownative/prometheus library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flownative / prometheus example snippets
/**
* @Flow\Inject
* @var \Flownative\Prometheus\CollectorRegistry\DefaultCollectorRegistry
*/
protected $collectorRegistry;
$this->collectorRegistry->getCounter('acme_myproject_controller_hits_total')
->inc();
$this->collectorRegistry->getCounter('acme_myproject_controller_hits_total')
->inc(1, ['result' => 'success']);
…
$this->collectorRegistry->getCounter('acme_myproject_controller_hits_total')
->inc(1, ['result' => 'failed']);
$this->collectorRegistry->getGauge('neos_flow_sessions')
->set(count($this->sessionManager->getActiveSessions()),
[
'state' => 'active'
]
);
$registry = new CollectorRegistry(new InMemoryStorage());
$registry->register('flownative_prometheus_test_calls_total', Counter::TYPE, 'a test call counter', ['tests', 'counter']);
$counter = $registry->getCounter('flownative_prometheus_test_calls_total');
$counter->inc(5.5);
$sampleCollections = $registry->collect();
$renderer = new Renderer();
echo ($renderer->render($sampleCollections));