Skip to content
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

#5962 Change to early return of OS instead of throwing #5963

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ private static IServiceCollection AddResourceMonitoringInternal(
this IServiceCollection services,
Copy link
Contributor

@evgenyfedorov2 evgenyfedorov2 Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method can now be fully covered by unit tests, please remove the comment and ExcludeFromCodeCoverage attribute

Action<IResourceMonitorBuilder> configure)
{
var builder = new ResourceMonitorBuilder(services);

_ = services.AddMetrics();

var builder = new ResourceMonitorBuilder(services);
#if NETFRAMEWORK
_ = builder.AddWindowsProvider();
#else
bool isSupportedOs = OperatingSystem.IsWindows() || OperatingSystem.IsLinux();
if (!isSupportedOs)
{
return services;
}

if (OperatingSystem.IsWindows())
{
_ = builder.AddWindowsProvider();
Expand All @@ -78,10 +82,6 @@ private static IServiceCollection AddResourceMonitoringInternal(
{
_ = builder.AddLinuxProvider();
}
else
{
throw new PlatformNotSupportedException();
}
#endif

configure.Invoke(builder);
Expand Down
Loading