-
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
Register internal ResourceMonitor with ResourceUtilizationHealthCheck #5413
Register internal ResourceMonitor with ResourceUtilizationHealthCheck #5413
Conversation
How can we help customers to detect and avoid this? |
We will update our documentation at https://learn.microsoft.com/en-us/dotnet/core/diagnostics/diagnostic-health-checks
The library will silently use the built-in
Update the docs as mentioned above. Add a note about the order of registration. |
Please link the pull-request updating the docs here as well. |
|
see also dotnet/docs#42853 |
Fixes #4560
What is changing
ResourceUtilizationHealthCheck
depends onIResourceMonitor
and requires an implementation of it to be registered first, which is also mentioned in #4560. Typically, users would achieve this by calling theAddResourceMonitoring()
method which registers the internal ResourceMonitorService for this purpose:After this change, users don't have to call
AddResourceMonitoring()
and can just callAddResourceUtilizationHealthCheck()
immediately:Impact
If you use
AddResourceMonitoring()
method call, you may omit it.If you use a custom implementation of
IResourceMonitor
and register it using theAddSingleton<IResourceMonitor, TImplementation>()
method, then no action is required.If you use a custom implementation of
IResourceMonitor
and register it using theTryAddSingleton<IResourceMonitor, TImplementation>()
method which is placed beforeAddResourceUtilizationHealthCheck()
, then no action is required. For example, assuming the custom implementationTImplementation
class name isMyResourceMonitorService
, the following scenarios will continue to work as is:✅ works:
✅ works:
✅ works:
If you use
TryAddSingleton<IResourceMonitor, TImplementation>()
which is placed after theAddResourceUtilizationHealthCheck()
method call, then the following will not work, because the internal ResourceMonitorService will be registered and used instead of theMyResourceMonitorService
:❌ does not work:
To fix that, please use either
AddSingleton<IResourceMonitor, TImplementation>()
extension methods, or place the registration before theAddResourceUtilizationHealthCheck()
method call:✅ works:
Microsoft Reviewers: Open in CodeFlow