prometheus_client_php
prometheus_client_php copied to clipboard
Type issue on bucket values
Hey,
I think there is an issue, if you try this :
$registry = new \Prometheus\CollectorRegistry(new Prometheus\Storage\Redis());
$histogram = $registry->getOrRegisterHistogram('test', 'some_histogram', 'it observes', [], [0, 1, 2, 3, 4, 5]);
$histogram->observe(5);
$renderer = new \Prometheus\RenderTextFormat();
$result = $renderer->render($registry->getMetricFamilySamples());
echo $result;
You get PHP Fatal error: Uncaught TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, int given
Here src/Prometheus/RenderTextFormat.php(59)
Because bucket values are "labelized" and labels values are "sanitized".
I found a workaround :
$histogram = $registry->getOrRegisterHistogram('test', 'some_histogram', 'it observes', [], ['0', '1', '2', '3', '4', '5']);
But I think it is not the way it should work, am I right ?