djluck / prometheus-net.DotNetRuntime

Exposes .NET core runtime metrics (GC, JIT, lock contention, thread pool) using the prometheus-net package
MIT License
357 stars 85 forks source link

There seems to be no way to disable collector recycling #72

Closed sandersaares closed 1 year ago

sandersaares commented 2 years ago

Recycling collectors can apparently crash .NET 6.0 runtime:

I would therefore like to disable recycling. If I understand it right, the recycling is no longer necessary with .NET 6.0 anyway, right? (Based on comments in https://github.com/dotnet/runtime/issues/43985)

However, it seems that there is no option for this! RecycleCollectorsEvery() does not accept a null/zero parameter. I request that this option be added and/or recycling be disabled from 6.0 onwards if it is no longer relevant.

djluck commented 2 years ago

Interesting, thanks for the research @sandersaares. If this is the case then yeah, let's go with disabling recycling for .NET 6.0 (from memory this would leave it only enabled for .NET 5.0). I can submit an MR later this week or so.

djluck commented 1 year ago

Hey @sandersaares, I just double checked and by default recycling isn't enabled for any runtime (although you can choose to enable it via RecycleCollectorsEvery).

sandersaares commented 1 year ago

It seems to default to 24 hours here for net50: https://github.com/djluck/prometheus-net.DotNetRuntime/blob/aa9fb94ac63643aeef2ac1a11d6a57f8378d9aac/src/prometheus-net.DotNetRuntime/DotNetRuntimeStatsCollector.cs#L205

Am I misreading the code somehow? Seems to match what I observe happening.

djluck commented 1 year ago

Apologies, I missed that (it's been a while since I've looked at this code!). I've just published v4.3.0 which targets .net60 and as a result, should see collector recycling only enabled by default for .net50.

sandersaares commented 1 year ago

Thanks! I confirm this seems to fix it.