Deadlock on gcCollector#371
Conversation
Signed-off-by: Krukov Dima <glebov.ru@gmail.com>
Signed-off-by: Krukov Dima <glebov.ru@gmail.com>
Signed-off-by: Krukov Dima <glebov.ru@gmail.com>
Signed-off-by: Krukov Dima <glebov.ru@gmail.com>
brian-brazil
left a comment
There was a problem hiding this comment.
Thanks for looking into this.
Switching to gc.stats sounds good to me, we'll only lose 3.3 support.
|
I still think we'd be better off using gc.stats. |
|
@brian-brazil Agree with you. I will prepare PR asap |
Signed-off-by: Krukov Dima <glebov.ru@gmail.com>
|
@brian-brazil I remade PR to using |
Signed-off-by: dmitry.kryukov <dmitry.kryukov@exness.com>
prometheus_client/gc_collector.py
Outdated
| collected = Histogram( | ||
| def collect(self): | ||
| collected = GaugeMetricFamily( | ||
| 'python_gc_collected_objects', |
There was a problem hiding this comment.
Aren't these all counters?
object_collected and objects_uncollectable would also be more usual.
There was a problem hiding this comment.
Please explain to me:
''object_collected'' Are you taking about variables names or about metrics names?
Is your question about choosing the type of metrics?
There was a problem hiding this comment.
The metric names.
Also, the types don't seem right.
There was a problem hiding this comment.
I renamed the metrics names and redid it with counter type
Signed-off-by: dmitry.kryukov <dmitry.kryukov@exness.com>
| 'python_gc_collected_objects', | ||
| def collect(self): | ||
| collected = CounterMetricFamily( | ||
| 'python_gc_objects_collected', |
There was a problem hiding this comment.
Counters should end in _total
There was a problem hiding this comment.
CounterMetricFamily will add it autocratically. You can see it in tests https://github.com/prometheus/client_python/pull/371/files#diff-b8616fecc6de945cdf630d3ad09aebb8R26
There was a problem hiding this comment.
Ah yes, I'd forgotten I'd already added that.
Hello!
Regading #363
We have the same problem with asyncio using (aiohttp, single process, single thread)
As we cannot predict when
gc.collect()will be executed (withgc.enable), it is not possible to use something that has locks inside thegc.collectcallbacks. So, YES, we neet to reconsidered how the GC collector works.One way it is remove GC Collector 😎 .
Another way in this PR - Collect metrics in simle structures witout locks and represent it in 'collect' method.
Therd way is to use
gc.stats(since python 3.4) with Gauge (GaugeMetricFamily) metrics atcollect.Or as @megabotan said, just remove lock in
getmethof ofMutexValue