Xabaril / AspNetCore.Diagnostics.HealthChecks

Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Apache License 2.0
4.08k stars 795 forks source link

.NET 6.0 Support / EF 5.0.1 fix #845

Closed cculver closed 2 years ago

cculver commented 3 years ago

It would be helpful to release a prerelease version of this library so we can start working with it on .NET 6.0. Currently, when trying to run from .NET 6, we run into a major problem with the UI in that upon initializing entities for Entity Framework Core 5.0.1, the application crashes. I'm asking to either upgrade everything to .NET 6 or to at least upgrade EF to 5.0.5 to fix that bug.

Please see https://github.com/dotnet/runtime/issues/49683 for the 5.0.1 problem / 5.0.5 fix under .NET 6.0.

unaizorrilla commented 3 years ago

Hi @cculver

I try to fix this on the 5.X ASAP and the preview for .NET 6 next week

cculver commented 3 years ago

Thanks!

jasontaylordev commented 2 years ago

I'd love to see this too. I want to demonstrate AspNetCore.Diagnostics.HealthChecks working with .NET 6 at a workshop next week. Happy to run with a preview version.

cculver commented 2 years ago

Would a PR help here?

liuhll commented 2 years ago

I am also looking forward to being able to use this package on the .net6.0 platform,In my open source microservice project silky, I also use this package as a service health check tool,

unaizorrilla commented 2 years ago

I'm working hard on this on net6-0 branch after my daily work, so sorry but the time is limited, I try to release a preview at the end of the week, but my promise is only about working hard!

Also @carlosrecuero is helping me on this!

projectje commented 2 years ago

I just wanted to doublecheck that probably then also falls under this:

System.TypeLoadException: Method 'GetServiceProviderHashCode' in type 'ExtensionInfo' from assembly 'Microsoft.EntityFrameworkCore.InMemory, Version=5.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
   at Microsoft.EntityFrameworkCore.InMemory.Infrastructure.Internal.InMemoryOptionsExtension.get_Info()
   at Microsoft.EntityFrameworkCore.DbContextOptions.GetHashCode()
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd[TArg](TKey key, Func`3 valueFactory, TArg factoryArgument)
   at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.GetOrAdd(IDbContextOptions options, Boolean providerRequired)
   at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
   at HealthChecks.UI.Core.Data.HealthChecksDb..ctor(DbContextOptions`1 options)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at HealthChecks.UI.Core.HostedService.UIInitializationHostedService.InitializeDatabase(IServiceProvider sp)
   at HealthChecks.UI.Core.HostedService.UIInitializationHostedService.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
carlosrecuero commented 2 years ago

Hi @projectje, thank you for your comment. Could you please provide me further information about how to reproduce this error?

projectje commented 2 years ago

@carlosrecuero Hi, when i comment out services.AddHealthChecksUI( ...... ).AddInMemoryStorage() it seems to run through.

When I only remove .AddInMemoryStorage() i get the following so .AddInMemoryStorage() leads to the 'GetServiceProviderHashCode' exception above.

Which is probably the same as all of these : https://github.com/search?q=GetServiceProviderHashCode&type=issues and is this breaking change: https://github.com/dotnet/efcore/issues/26022 https://github.com/dotnet/efcore/issues/26022#issuecomment-920204319

System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: HealthChecks.UI.Core.Notifications.IHealthCheckFailureNotifier Lifetime: Scoped ImplementationType: HealthChecks.UI.Core.Notifications.WebHookFailureNotifier': Unable to resolve service for type 'HealthChecks.UI.Core.Data.HealthChecksDb' while attempting to activate 'HealthChecks.UI.Core.Notifications.WebHookFailureNotifier'.) (Error while validating the service descriptor 'ServiceType: HealthChecks.UI.Core.HostedService.IHealthCheckReportCollector Lifetime: Scoped ImplementationType: HealthChecks.UI.Core.HostedService.HealthCheckReportCollector': Unable to resolve service for type 'HealthChecks.UI.Core.Data.HealthChecksDb' while attempting to activate 'HealthChecks.UI.Core.HostedService.HealthCheckReportCollector'.) ---> System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: HealthChecks.UI.Core.Notifications.IHealthCheckFailureNotifier Lifetime: Scoped ImplementationType: HealthChecks.UI.Core.Notifications.WebHookFailureNotifier': Unable to resolve service for type 'HealthChecks.UI.Core.Data.HealthChecksDb' while attempting to activate 'HealthChecks.UI.Core.Notifications.WebHookFailureNotifier'. ---> System.InvalidOperationException: Unable to resolve service for type 'HealthChecks.UI.Core.Data.HealthChecksDb' while attempting to activate 'HealthChecks.UI.Core.Notifications.WebHookFailureNotifier'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(ServiceDescriptor serviceDescriptor, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor) --- End of inner exception stack trace --- at Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(ServiceDescriptor descriptor) at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection1 serviceDescriptors, ServiceProviderOptions options) --- End of inner exception stack trace --- at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection1 serviceDescriptors, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder) at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter1.CreateServiceProvider(Object containerBuilder) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build().`

alirezanet commented 2 years ago

Any update on this ? .NET 6.0 is officially out.

carlosrecuero commented 2 years ago

Hi, thank you for your interest. There is already a preview version for net6.0.

alirezanet commented 2 years ago

Hi, thank you for your interest. There is already a preview version for net6.0.

Thanks, but i can't find any preview version for the first three packages.

      <PackageVersion Include="AspNetCore.HealthChecks.UI" Version="5.0.1"/>
      <PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1"/>
      <PackageVersion Include="AspNetCore.HealthChecks.UI.MySql.Storage" Version="5.0.1"/>

      <PackageVersion Include="AspNetCore.HealthChecks.MongoDb" Version="6.0.1-rc1.1"/>
      <PackageVersion Include="AspNetCore.HealthChecks.Redis" Version="6.0.1-rc1.1"/>
      <PackageVersion Include="AspNetCore.HealthChecks.MySql" Version="6.0.1-rc1.1"/>
      <PackageVersion Include="AspNetCore.HealthChecks.Network" Version="6.0.1-rc1.1"/>
      <PackageVersion Include="AspNetCore.HealthChecks.System" Version="6.0.1-rc1.1"/>
      <PackageVersion Include="AspNetCore.HealthChecks.Uris" Version="6.0.1" />

I think using the version 5 packages causing this error at runtime:

Unhandled exception. System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.MutablePropertyExtensions.SetValueComparer(Microsoft.EntityFrameworkCore.Metadata.IMutableProperty, Microsoft.EntityFramewo
rkCore.ChangeTracking.ValueComparer)'.
   at HealthChecks.UI.Core.Data.Configuration.HealthCheckExecutionEntryMap.Configure(EntityTypeBuilder`1 builder)
ok10d commented 2 years ago

Could't find a preview version of below for net 6.0.

<PackageReference Include="AspNetCore.HealthChecks.UI" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="5.0.1" />

Causes below on initialization:

[INF] [HealthChecks.UI.Core.HostedService.UIInitializationHostedService] Initializing UI Database
Unhandled exception. System.TypeInitializationException: The type initializer for 'Microsoft.EntityFrameworkCore.Query.QueryableMethods' threw an exception.
unaizorrilla commented 2 years ago

Nope, the UI is not deployed yet on 6.0 We are working on it!

unaizorrilla commented 2 years ago

Hi!

-rc2 version for .NET 6 already on NuGet, we hope to release final version ASAP!

mathiasbl commented 2 years ago

Can we get an rc version for AspNetCore.HealthChecks.AzureKeyVault and AspNetCore.HealthChecks.AzureStorage?

carlosrecuero commented 2 years ago

Yes, we are working on them. Quite likely, they will be ready at the end of the week.

JuergenGutsch commented 2 years ago

The preview version 6.0.1-rc2.4 is working with ASP.NET Core 6.0

skoruba commented 2 years ago

Hi, when do you plan to release stable version 6? Thanks!

JuergenGutsch commented 2 years ago

Yea, that would be great. The rc2.4 works quite well. This could be published as the final version from my point of view.

carlosrecuero commented 2 years ago

We are finishing it and will be ready in the following days.

El mar., 28 dic. 2021 20:24, Juergen Gutsch @.***> escribió:

Yea, that would be great. The rc2.4 works quite well. This could be published as the final version from my point of view.

— Reply to this email directly, view it on GitHub https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/845#issuecomment-1002249835, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALZUJ4X5PEU2A3BZBQ4N5LUTIFITANCNFSM5GJIDS6Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.*** com>

skoruba commented 2 years ago

I can see that almost all packages are released, which is great 😊 Can you please release also UI packages?

Thanks

carlosrecuero commented 2 years ago

Hi @skoruba, UI packages have been release now

saddamhossain commented 1 year ago

The UI is not working with .NET 7.0. I am using the following packages:

`

`

This is the error I encountered:

error

sungam3r commented 1 year ago

Try latest v7-preview packages, they support net7.