feat: add API Sentry tracing

This commit is contained in:
Alexandre Brandizzi 2026-09-03 13:59:13 -03:00
parent 69ba573315
commit 8e4a5ed4d8
3 changed files with 13 additions and 1 deletions

View file

@ -16,6 +16,11 @@
# uses the AWS SDK default credential chain (env AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY,
# the shared profile/SSO, or the EC2/ECS instance role). Prefer an instance role in prod.
# --- Sentry error and transaction monitoring ---
# Leave the DSN blank to keep telemetry inactive. Set the environment per deployment.
SENTRY_DSN=
SENTRY_ENVIRONMENT=development
# --- SQL Server connection string (Api.SeaHavenIndustries + SeaHavenIndustries) ---
ConnectionStrings__DefaultConnection=Server=<host>;Initial Catalog=<db>;User Id=<user>;Password=<password>;MultipleActiveResultSets=true
@ -44,4 +49,3 @@ Sync__Enabled=true
# --- Legacy endpoint deprecation headers ---
LegacyEndpoints__DeprecationEnabled=false
LegacyEndpoints__SunsetDate=2026-12-31

View file

@ -15,6 +15,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="SendGrid" Version="9.29.3" />
<PackageReference Include="Sentry.AspNetCore" Version="6.10.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="PasswordGenerator" Version="2.1.0" />
</ItemGroup>

View file

@ -16,6 +16,13 @@ using SeaHaven.Services.Implementation;
using SeaHaven.Services.Interfaces;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseSentry(options =>
{
options.TracesSampleRate = 1.0;
options.SendDefaultPii = false;
});
ConfigurationManager configuration = builder.Configuration;
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")));