dotnet / extensions

This repository contains a suite of libraries that provide facilities commonly needed when creating production-ready applications.
MIT License
2.68k stars 758 forks source link

Retire IResourceMonitor set of API in favor of observable instruments #5414

Open evgenyfedorov2 opened 2 months ago

evgenyfedorov2 commented 2 months ago

Currently, ResourceMonitoring can be consumed in two ways:

Both ways provide the same resource monitoring data, so essentially we have duplicated functionality. We can simplify it all by deprecating the IResourceMonitor API and recommend the observable instruments as the only way forward. Namely, we can deprecate following classes (or structs): src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/SystemResources.cs src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Snapshot.cs src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceUtilization.cs src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ISnapshotProvider.cs src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/IResourceMonitorBuilder.cs src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/IResourceMonitor.cs

Pros:

Cons:

evgenyfedorov2 commented 2 months ago

@RussKie @joperezr @geeknoid @andrey-noskov - please take a look when you have time

geeknoid commented 2 months ago

Regarding your "con", given that we wouldn't be deleting the API and just marking it obsolete, then nobody would be 'blocked', right?

andrey-noskov commented 2 months ago

yes, please! this probably should include ResourceMonitorService, CircularBuffer, Calculator and many other internal utilities that power our IResourceMonitor implementation.

evgenyfedorov2 commented 2 months ago

Regarding your "con", given that we wouldn't be deleting the API and just marking it obsolete, then nobody would be 'blocked', right?

Yes.

Another question - I assume we will be able to delete any Obsolete API when .NET 8 support ends, e.g. in 2026?

geeknoid commented 2 months ago

@joperezr Are obsoleted APIs ever removed from the code base?

joperezr commented 2 months ago

Yes, they can be. Typically that is done in the subsequent LTS version after being marked as obsoleted (in an LTS version too). This policy is documented here: https://learn.microsoft.com/en-us/dotnet/core/compatibility/api-removal

RussKie commented 2 months ago

@evgenyfedorov2: sounds good to me. We can mark these API (and anything else related) as obsolete in the .NET 9 release (i.e., the dev branch). We'll also need to create migration guides.

There isn't much time before we switch to .NET 9, so we should do this before then.