PHP code example of saschahemleb / laravel-prometheus-exporter

1. Go to this page and download the library: Download saschahemleb/laravel-prometheus-exporter 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/ */

    

saschahemleb / laravel-prometheus-exporter example snippets


protected $middleware = [
    \Saschahemleb\LaravelPrometheusExporter\Http\Middleware\ObserveResponseTime::class,
    // [...]
];

[
    'method',
    'route',
    'status_code',
]

[
    'query',
    'query_type',
]



declare(strict_types = 1);

namespace Saschahemleb\LaravelPrometheusExporter;

use Prometheus\Gauge;use Saschahemleb\LaravelPrometheusExporter\Contracts\CollectorInterface;

class ExampleCollector implements CollectorInterface
{
    /**
     * @var Gauge
     */
    protected $usersRegisteredGauge;

    /**
     * Return the name of the collector.
     *
     * @return string
     */
    public function getName() : string
    {
        return 'users';
    }

    /**
     * Register all metrics associated with the collector.
     *
     * The metrics needs to be registered on the exporter object.
     * eg:
     * 
bash
$ php artisan vendor:publish --provider "Saschahemleb\\LaravelPrometheusExporter\\PrometheusServiceProvider"