fix(sentry): use config pipeline for DSN, add MaxRequestBodySize and ProfilesSampleRate

- Heimdall.Web/Program.cs: use Sentry:Dsn from IConfiguration as primary
  source with legacy SENTRY_DSN env var as fallback (no hardcoded DSN)
- Heimdall.Agent/Program.cs: same pattern applied
- Both: add MaxRequestBodySize=Small and ProfilesSampleRate=0.05
  (previously missing); lower TracesSampleRate to 0.05
- appsettings.json: add Sentry:Dsn entry for discoverability

Resolves codify signal: hardcoded-sdk-credentials (C1)
This commit is contained in:
Arnaud Dartois committed 2026-07-28 10:14:34 +00:00
1 parent e8bede3d79
commit edc739dffe
4 files changed
+31 -11

No files matched your search

+10 -4
View File
@@ -209,16 +209,22 @@ public partial class Program {
internal static void ConfigureServices(WebApplicationBuilder builder)
{
// ── Sentry (GlitchTip) — DSN from env var only ───────────────────
var sentryDsn = Environment.GetEnvironmentVariable("SENTRY_DSN");
if (sentryDsn is not null)
// ── Sentry (GlitchTip) — DSN from config pipeline with legacy env var fallback ──
// Primary: Sentry:Dsn from appsettings.json or env var Sentry__Dsn
// Fallback: legacy SENTRY_DSN env var (Docker backward compat)
// Neither set → DSN is null → Sentry SDK no-ops gracefully
var sentryDsn = builder.Configuration["Sentry:Dsn"]
?? Environment.GetEnvironmentVariable("SENTRY_DSN");
if (!string.IsNullOrEmpty(sentryDsn))
{
builder.WebHost.UseSentry(options =>
{
options.Dsn = sentryDsn;
options.MinimumBreadcrumbLevel = LogLevel.Debug;
options.MinimumEventLevel = LogLevel.Error;
options.TracesSampleRate = 0.1;
options.TracesSampleRate = 0.05;
options.MaxRequestBodySize = Sentry.Extensibility.RequestSize.Small;
options.ProfilesSampleRate = 0.05;
});
}