beam-telemetry / telemetry_metrics_prometheus_core

Core Prometheus Telemetry.Metrics Reporter package for telemetry_metrics_prometheus
Apache License 2.0
35 stars 30 forks source link

Memory leak #52

Open yzh44yzh opened 1 year ago

yzh44yzh commented 1 year ago

Hi. We are using your library in our project, and consider it helpful. Thank you.

However, we found a memory leak. If nobody ever asks for metrics through API, ETS dist table is never clean up.

We've got 1Gb of data and 3M of records in dist table before noticing it.

yzh44yzh commented 1 year ago

https://github.com/beam-telemetry/telemetry_metrics_prometheus_core/blob/main/lib/core/aggregator.ex#L17 this is where data are removed from table. If nobody calls Aggregator.aggregate/3, data are never removed.

akoutmos commented 1 year ago

There are a couple of ways to solve this problem. Some of those have been discussed here: https://github.com/beam-telemetry/telemetry_metrics_prometheus_core/issues/41.

In short, you will probably need to set up a GenServer cron job that regularly aggregates the ETS data.

yzh44yzh commented 1 year ago

Ok, thank you. As for me, I've replaced this lib with prometheus_ex.