mirror of
https://github.com/morbalint/kemkas.git
synced 2026-07-18 03:13:46 +00:00
add open telemetry and refactor setup
This commit is contained in:
+10
-19
@@ -11,6 +11,9 @@ using Kemkas.Web.Services.Identity;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using OpenTelemetry.Metrics;
|
||||
using OpenTelemetry.Resources;
|
||||
using OpenTelemetry.Trace;
|
||||
using IPNetwork = Microsoft.AspNetCore.HttpOverrides.IPNetwork;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -34,25 +37,7 @@ builder.Services.AddSingleton<IEmailSender, MailgunEmailSender>();
|
||||
builder.Services.AddDefaultIdentity<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||
|
||||
builder.Services.AddAuthentication()
|
||||
.AddGoogle(options =>
|
||||
{
|
||||
var section = builder.Configuration.GetSection("Authentication:Google");
|
||||
options.ClientId = section["ClientId"];
|
||||
options.ClientSecret = section["ClientSecret"];
|
||||
})
|
||||
.AddFacebook(options =>
|
||||
{
|
||||
var section = builder.Configuration.GetSection("Authentication:Facebook");
|
||||
options.ClientId = section["ClientId"];
|
||||
options.ClientSecret = section["ClientSecret"];
|
||||
})
|
||||
.AddDiscord(options =>
|
||||
{
|
||||
var section = builder.Configuration.GetSection("Authentication:Discord");
|
||||
options.ClientId = section["ClientId"];
|
||||
options.ClientSecret = section["ClientSecret"];
|
||||
});
|
||||
builder.AddAuth();
|
||||
|
||||
builder.Services.AddControllersWithViews().AddJsonOptions(options =>
|
||||
{
|
||||
@@ -62,6 +47,10 @@ builder.Services.AddControllersWithViews().AddJsonOptions(options =>
|
||||
});
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
builder.AddOpenTelemetry();
|
||||
|
||||
builder.Services.AddHealthChecks();
|
||||
|
||||
builder.Services.AddCharacterServices();
|
||||
|
||||
var app = builder.Build();
|
||||
@@ -93,6 +82,8 @@ else
|
||||
app.UseHsts(); // TODO: check if this should be handled by proxy
|
||||
}
|
||||
|
||||
app.UseHealthChecks("/health");
|
||||
|
||||
await using (var scope = app.Services.CreateAsyncScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
|
||||
Reference in New Issue
Block a user