initial commit
This commit is contained in:
commit
bf1a4e1879
17 changed files with 822 additions and 0 deletions
41
src/MetricsController.php
Normal file
41
src/MetricsController.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Superbalist\LaravelPrometheusExporter;
|
||||
|
||||
use Illuminate\Routing\Controller;
|
||||
use Prometheus\RenderTextFormat;
|
||||
|
||||
class MetricsController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var $prometheusExporter
|
||||
*/
|
||||
protected $prometheusExporter;
|
||||
|
||||
/**
|
||||
* @param PrometheusExporter $prometheusExporter
|
||||
*/
|
||||
public function __construct(PrometheusExporter $prometheusExporter)
|
||||
{
|
||||
$this->prometheusExporter = $prometheusExporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /metrics
|
||||
*
|
||||
* The route path is configurable in the prometheus.metrics_route_path config var, or the
|
||||
* PROMETHEUS_METRICS_ROUTE_PATH env var.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function getMetrics()
|
||||
{
|
||||
$metrics = $this->prometheusExporter->export();
|
||||
|
||||
$renderer = new RenderTextFormat();
|
||||
$result = $renderer->render($metrics);
|
||||
|
||||
return response($result)
|
||||
->header('Content-Type', RenderTextFormat::MIME_TYPE);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue