PromPHP / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
415 stars 91 forks source link

\Prometheus\CollectorRegistry::getMetricFamilySamples uses a large amount of memory #141

Open skyellin opened 8 months ago

skyellin commented 8 months ago

\Prometheus\CollectorRegistry::getMetricFamilySamples, and the functions it uses, needs to store the entire output in memory. This can grow quite large for applications with a lot of metrics and high cardinality. It seems that it would be possible to avoid keeping all the output in memory, by having \Prometheus\CollectorRegistry::getMetricFamilySamples (and its dependecies) return a generator rather than an array.