Commit 70cefbf4 authored by Dominik Hebeler's avatar Dominik Hebeler

changed exporter to a histogram

parent 56353b27
......@@ -44,6 +44,11 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $exception)
{
if ($request->is('*/meta/meta.ger3*')) {
$registry = \Prometheus\CollectorRegistry::getDefault();
$histogram = $registry->getOrRegisterHistogram('metager', 'result_histogram', 'counts total number of returned results', [], [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]);
$histogram->observe(0);
}
return parent::render($request, $exception);
}
......
......@@ -123,8 +123,31 @@ class MetaGerSearch extends Controller
}
$registry = \Prometheus\CollectorRegistry::getDefault();
$gauge = $registry->getOrRegisterGauge('metager', 'result_gauge', 'counts total number of returned results');
$gauge->set(sizeof($metager->getResults()));
$histogram = $registry->getOrRegisterHistogram('metager', 'result_histogram', 'counts total number of returned results', [], [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]);
$resultCount = sizeof($metager->getResults());
$observeValue = 0;
if($resultCount > 0 && $resultCount <= 10){
$observeValue = 10;
}else if($resultCount <= 20){
$observeValue = 20;
}else if($resultCount <= 30){
$observeValue = 30;
}else if($resultCount <= 40){
$observeValue = 40;
}else if($resultCount <= 50){
$observeValue = 50;
}else if($resultCount <= 60){
$observeValue = 60;
}else if($resultCount <= 70){
$observeValue = 70;
}else if($resultCount <= 80){
$observeValue = 80;
}else if($resultCount <= 90){
$observeValue = 90;
}else if($resultCount > 90){
$observeValue = 100;
}
$histogram->observe($observeValue);
return $resultpage;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment