-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The health checks resource utilization library assumes IResourceMonitor
is registered.
#4560
Comments
This would create a coupling between the implementation of the health check and the implementation of the IResourceMonitoring API, which I think is incorrect. |
The coupling is already there, I'm forced to add a NuGet package reference to something I know nothing about, nor do I know what needs to be implemented to satisfy this error—that's going to be a bad end user experience. If you want more developers adopting this package, you'll want to make this optional, to where the consumer wouldn't be required to do anything extra to consume your library (the happy path). |
Agree with @IEvangelist. What would you expect the user to do in this situation @geeknoid? Are we missing another abstraction or default implementation? |
The issue is that you have two abstractions and associated implementations: IFoo and Foo as an implementation If I add <IFoo, Foo> to DI should I also force <IFooProvider, FooProvider> into DI? This breaks the abstraction in IMO since it's implicitly assuming that because the user chose to implement IFoo with Foo, that also means they implicitly chose to implement IFooProvider with FooProvider. What if they instead want MyCustomFooProvider instead? This is pretty pervasive in how we put together the R9 libs at this point. The customer generally needs to attach explicitly the providers and the available implementations. |
I'm saying you provide a |
I had to find this thread and add Otherwise adding |
Description
The
Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization
assumes that theIResourceMonitor
service has been registered, it's my belief that if this package relies on the resource monitoring services:extensions/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj
Line 20 in 6fda2c8
It should be responsible for ensuring that the
IResourceMonitor
is added to theIServiceCollection
.Reproduction Steps
Create a simple console app:
Update the Program.cs with the following:
This results in the following:
Expected behavior
I'd expect this to run without exception, as calling
AddResourceUtilizationHealthCheck
would add the required services.Actual behavior
A runtime exception is thrown.
Regression?
No response
Known Workarounds
Manually call
AddResourceMonitoring
.Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: