Add Sentry (#19)
* add sentry * add sentry * better log web3proxy * Add managing and worker on sentry * better log web3proxy
This commit is contained in:
@@ -8,11 +8,8 @@ using Managing.Core.Middleawares;
|
||||
using Managing.Infrastructure.Databases.InfluxDb.Models;
|
||||
using Managing.Infrastructure.Databases.MongoDb.Configurations;
|
||||
using Managing.Infrastructure.Evm.Models.Privy;
|
||||
using Microsoft.Extensions.ServiceDiscovery;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using NSwag;
|
||||
using NSwag.Generation.Processors.Security;
|
||||
@@ -26,10 +23,36 @@ using OpenApiSecurityScheme = NSwag.OpenApiSecurityScheme;
|
||||
// Builder
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Configuration.SetBasePath(AppContext.BaseDirectory);
|
||||
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json");
|
||||
|
||||
var mongoConnectionString = builder.Configuration.GetSection(Constants.Databases.MongoDb)["ConnectionString"];
|
||||
var influxUrl = builder.Configuration.GetSection(Constants.Databases.InfluxDb)["Url"];
|
||||
var web3ProxyUrl = builder.Configuration.GetSection("Web3Proxy")["BaseUrl"];
|
||||
|
||||
// Initialize Sentry
|
||||
SentrySdk.Init(options =>
|
||||
{
|
||||
// A Sentry Data Source Name (DSN) is required.
|
||||
options.Dsn = builder.Configuration["Sentry:Dsn"];
|
||||
|
||||
// When debug is enabled, the Sentry client will emit detailed debugging information to the console.
|
||||
options.Debug = false;
|
||||
|
||||
// Adds request URL and headers, IP and name for users, etc.
|
||||
options.SendDefaultPii = true;
|
||||
|
||||
// This option is recommended. It enables Sentry's "Release Health" feature.
|
||||
options.AutoSessionTracking = true;
|
||||
|
||||
// Enabling this option is recommended for client applications only. It ensures all threads use the same global scope.
|
||||
options.IsGlobalModeEnabled = false;
|
||||
|
||||
// Example sample rate for your transactions: captures 10% of transactions
|
||||
options.TracesSampleRate = 0.1;
|
||||
});
|
||||
|
||||
// Add service discovery for Aspire
|
||||
builder.Services.AddServiceDiscovery();
|
||||
|
||||
@@ -41,9 +64,6 @@ builder.Services.AddHealthChecks()
|
||||
.AddUrlGroup(new Uri($"{web3ProxyUrl}/health"), name: "web3proxy", tags: ["api"]);
|
||||
|
||||
builder.WebHost.UseUrls("http://localhost:5001");
|
||||
builder.Configuration.SetBasePath(AppContext.BaseDirectory);
|
||||
builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json");
|
||||
|
||||
builder.Host.UseSerilog((hostBuilder, loggerConfiguration) =>
|
||||
{
|
||||
@@ -161,7 +181,11 @@ app.UseSwaggerUI(c =>
|
||||
|
||||
app.UseCors("CorsPolicy");
|
||||
|
||||
app.UseMiddleware(typeof(GlobalErrorHandlingMiddleware));
|
||||
// Add Sentry diagnostics middleware (now using shared version from Core)
|
||||
app.UseSentryDiagnostics();
|
||||
|
||||
// Using shared GlobalErrorHandlingMiddleware from Core project
|
||||
app.UseMiddleware<GlobalErrorHandlingMiddleware>();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
@@ -173,12 +197,12 @@ app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
endpoints.MapHub<PositionHub>("/positionhub");
|
||||
|
||||
endpoints.MapHealthChecks("/health", new HealthCheckOptions
|
||||
|
||||
endpoints.MapHealthChecks("/health", new HealthCheckOptions
|
||||
{
|
||||
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
|
||||
});
|
||||
|
||||
|
||||
endpoints.MapHealthChecks("/alive", new HealthCheckOptions
|
||||
{
|
||||
Predicate = r => r.Tags.Contains("live"),
|
||||
|
||||
Reference in New Issue
Block a user