-
Notifications
You must be signed in to change notification settings - Fork 804
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
HealthCheck UI - Configurable Storage Providers (InMemory, SqlServer, Postgres, Sqlite) #455
Comments
How do you think we should implement this feature?. Do you think we should add migrations for different providers (SqlServer, Postgres, Sqlite) inside the HealthChecks.UI assembly and expose methods such as: services
.AddHealthChecksUI()
// This could use a default in memory storage services
.AddHealthChecksUI()
.AddUISqlServerStorage(connectionString) services
.AddHealthChecksUI()
.AddUIPostgresStorage(connectionString) of just make our DbContext public and let the user create their own migrations for whatever provider? services.AddDbContext<UIDbContext>(setup => {
setup.UseSqlServer(connectionString, opt => opt.MigrationsAssembly("AssemblyName");
}); |
@CarlosLanderas I would say the first approach, better intention, easier to mock and extendable. |
@CarlosLanderas how can I help you with such a feature? |
This style looks best. I personally like the extension method style on the IMHO, I think you will want a combination of both. e.g. add the storage dependency, then add that dependency to the HealthCheck.UI dependency. |
IMHO, the main difference between boths approaches is: With the first one, we would be the ones creating the migrations inside the UI assembly and wiring everything internally (MigrationsAssembly, Database migrate execution, etc) and the user would be limited to the available provider migrations. The second options requires more work for the user, but everything can be customized outside the UI (With the risk of doing it wrong as well). If we stick with the second option and allow the user to create the Migrations and configure the Context provider and options we would still need to trigger the initial seed that feeds the storage with the configured Healthcheck and webhook endpoints in the UI internals. |
What's the status of this change? |
Waiting for feedback and opinions |
I like the first option. The fluent style keeps your package simple. If you implement the standard data providers everyone will be happy i think. The second option would make your package more complex to configure and it would not be so straightforward as it is right now. |
I also prefer the first option. Don't get me wrong, but getting migrations right is hard enough as it is...I don't want to have to think about other people's migrations as well (if that's possible). |
Same. I prefer the first option to only allow the minimum options required, black box mode. The only thing is the name of the extension method, I would prefer something like this to make it clear about the intended function: services
.AddHealthChecksUI(setup =>
{
setup.AddSqlServerStorage(connectionString);
}); |
First option. |
First option - keeping things "black box" is extremely important. |
Yes, of course this is another valid options. Thanks for the propoisal. |
@CarlosLanderas are you accepting PRs only for bugfixes or improvements as well? Do you have a guideline over how to perform PRs? |
Work has started. We have added a HealthChecksUIBuilder se we can properly chain all the dependencies. You can follow work in this branch: https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/tree/storage-providers |
@CarlosLanderas looking at the commits so far it seems that it's still very much dependant on Entity Framework Core, is there any plan on abstracting this away so other database providers that don't have an EF provider can be implemented? |
@kevbite to be honest I don't think so (at least at the moment) as several parts in the UI use EF Core. (collector, middleware, seeding, etc). What DB provider are you thinking about? |
@CarlosLanderas I was thinking about building support for MongoDB, I know few products out there that only have MongoDB as backing store. |
Well, you can maybe propose different kind of storage models and create an abstraction layer inside the library so that whatever Database you choose, it should implement the required methods. I believe that EF Core will be suitable for most scenarii but you can also offer a way to let developer create their own extension method which will return the right storage layer (class) for their use case. As an example, see: services
.AddHealthChecksUI(setup =>
{
// Provided by a HealthChecks UI package
// Will use an EF Core implementation (or whatever)
setup.AddSqlServerStorage(connectionString);
// Provided by anyone
// Will use the according implementation to store data in a mongodb instance
setup.AddMongoDbStorage(connectionString);
}); |
Getting |
@cesarbmx, this has been solved. Could you try again? |
@CarlosLanderas - All working. |
@cesarbmx great! Thank you for your feedback! Check the updated docs to know to to disable migrations, limit history entries in the frontend, use collector interceptors and other goodies that have been added :) |
@CarlosLanderas any support for MySql planned? |
@udlose, yes, at soon at is supported in 3.0. They support 2.2 right now if I am not wrong |
Can you please clarify what you are referring to? I am currently using MySql 5.7.12 in my .NET Core 3.1.3 application. I don't understand who the it and they you are referring to |
@udlose , let me check it, and if possible I submit the provider tomorrow ;) |
@udlose, migrations can not be created, they need to upgrade the provider as you can read in the link below. I forgot I faced this problem when tried to create the provider the first time:
PublicKeyToken=c5687fc88969c44d' does not have an implementation. |
@udlose in the issue, the suggest using https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql As entity framework team is no longer maintaining the MySql provider. Pomelo is a fully featured provider. I am gonna give it a try |
@udlose, here is the published MySql storage provider package: https://www.nuget.org/packages/AspNetCore.HealthChecks.UI.MySql.Storage |
@CarlosLanderas Thank you so much! I greatly appreciate your promptness :) I'm not using EntityFramework, I assume that was an implementation/support blocker on your side? I will pull the package and give it a try later this week or next (have another pressing item I need to complete first). What all do I need to do on my side to get the provider and database setup? We are running MySql in AWS. TIA |
@udlose, it automatically runs migrations against the connection string database creating all the requires tables. |
|
@CarlosLanderas Is there any way to run the migrations manually? Or better yet, generate them as you normaly do in EF? Applying migrations on startup seems a bit dangerous if you are using more than one instance... |
For Postgres DB, is it possible to configure any other schema then public? |
@CarlosLanderas can you please respond to my comment from April 20th? |
Same question as @protradeshare-admin, how do we change the schema for the storage options (other than dbo for SQL Server so)? |
Same question as @protradeshare-admin and @Odonno, I have more then one context and I intend to use the same database to store the health checks data, how can I change the schema for the storage? Because I already have a table named __EFMigrationsHistory in the public schema. |
What would you like to be added:
Health Check UI Storage Providers (SqlServer, Postgres, Sqlite)
We need to start working in configurable Health Checks Database providers.
Why is this needed:
Right now, we only support SQLite and this is very limiting. For example Azure App Service running under linux is not compatible
We are going to allow the user configuring it's own storage provider using Entity Framework Core.
The idea is making the UI DbContext public, configuring the default storage as "In Memory", (if we have no compatibility issues) and allow the user to override this default provider when ConfigureDbContext is configured by the user
The text was updated successfully, but these errors were encountered: