Skip to content

The only tool you need to know what is happening and how to fix it.

feat: logs retention based on size - great for self hosting done for #277

narrow-adventured87390c87882
diff --git a/CLAUDE.md b/CLAUDE.md
index d4246e39..694d219d 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -268,6 +268,8 @@ OUTBOX_POLL_SECONDS=15 # notification outbox drain interval; mini
# Retention (see "Data Retention" section below)
SQLITE_RETENTION_DAYS=30 # 0 to disable; only applies in SQLite mode
+DUCKDB_RETENTION_DAYS=30 # telemetry TTL on the DuckDB backend; when set it wins over SQLITE_RETENTION_DAYS there, when unset SQLITE_RETENTION_DAYS applies as fallback; 0 to disable
+LOG_RECORDS_MAX_ROWS= # optional cap on log_records rows; unset/0 = disabled. NOT a hard limit: a cleanup worker trims to the newest N rows once per minute, so ingest above N rows/minute overshoots the cap between runs. Only applies in SQLite mode (SQLite or DuckDB telemetry)
SESSION_RECORDING_RETENTION_DAYS=30 # 0 to disable; only applies when STORAGE_TYPE=local
PROFILE_ARCHIVE_RAW=false # native pprof ingest only: write the original pprof bytes to object storage as a lossless archive
PROFILE_RETENTION_DAYS=30 # 0 to disable; on-disk archive TTL, only with PROFILE_ARCHIVE_RAW + STORAGE_TYPE=local
@@ -901,6 +903,7 @@ The three profiling tables share a 30-day TTL keyed on each table's time column
| Variable | Default | Notes |
|----------|---------|-------|
| `SQLITE_RETENTION_DAYS` | `30` | TTL in days. Set to `0` to disable the worker entirely. Has no effect outside SQLite mode. |
+| `DUCKDB_RETENTION_DAYS` | `30` | Same worker on the DuckDB telemetry backend. When set it takes precedence there; when unset the worker falls back to `SQLITE_RETENTION_DAYS` (selection in `retention.telemetryRetentionConfig`). |
Tables it prunes (and the column used):
@@ -916,6 +919,8 @@ Tables it prunes (and the column used):
`archived_exceptions` (per-hash flags) and `slow_endpoints` (per-endpoint config) are intentionally skipped — they are not time-series data. `profiling_stacks` *is* pruned (unlike those two) because it holds no user intent — it is a regenerable dedup table whose `last_seen` tracks the most recent referencing sample, so deleting expired stacks is safe.
+**2b. Log row cap — `retention.Start` worker** (`backend/app/retention/log_cap.go`). SQLite mode only (SQLite or DuckDB telemetry), off by default. When `LOG_RECORDS_MAX_ROWS` is set to a positive N, a worker runs once at startup and then every minute and deletes `log_records` rows strictly older than the Nth-newest row's `timestamp` (single portable DELETE with an `ORDER BY timestamp DESC LIMIT 1 OFFSET N-1` subquery; NULL boundary = no-op under the cap, boundary ties are kept). **The cap is best-effort, not a hard limit**: nothing throttles ingest, so between passes the table can exceed N, and sustained ingest above N rows/minute keeps it above the cap permanently — document it to users as a cleanup task with a 1-minute window, sized with headroom for peak log volume. Bounds log disk usage independently of `SQLITE_RETENTION_DAYS`; disk reclamation still happens via the hourly retention pass / DuckDB WAL checkpointing.
+
**3. On-disk session recordings — `retention.Start` worker** (`backend/app/retention/recordings.go`). Session recordings written to local disk (`STORAGE_TYPE=local`) accumulate under `<STORAGE_PATH>/recordings/`. A second worker walks that directory once at startup and then every hour and removes files whose `mtime` is older than the TTL, then prunes any directories left empty. The worker is a no-op when `STORAGE_TYPE=s3`.
| Variable | Default | Notes |
diff --git a/backend/app/config/config.go b/backend/app/config/config.go
index 15cb5054..b8b2d2f2 100644
--- a/backend/app/config/config.go
+++ b/backend/app/config/config.go
@@ -37,6 +37,8 @@ type Cfg struct {
S3Endpoint string
SQLiteRetentionDays string
+ DuckDBRetentionDays string
+ LogRecordsMaxRows string
SessionRecordingRetentionDays string
SessionRecordingUploadWorkers string
SessionRecordingUploadQueueSize string
@@ -153,6 +155,8 @@ func LoadFromEnv() *Cfg {
S3Endpoint: os.Getenv("S3_ENDPOINT"),
SQLiteRetentionDays: os.Getenv("SQLITE_RETENTION_DAYS"),
+ DuckDBRetentionDays: os.Getenv("DUCKDB_RETENTION_DAYS"),
+ LogRecordsMaxRows: os.Getenv("LOG_RECORDS_MAX_ROWS"),
SessionRecordingRetentionDays: os.Getenv("SESSION_RECORDING_RETENTION_DAYS"),
SessionRecordingUploadWorkers: os.Getenv("SESSION_RECORDING_UPLOAD_WORKERS"),
SessionRecordingUploadQueueSize: os.Getenv("SESSION_RECORDING_UPLOAD_QUEUE_SIZE"),
diff --git a/backend/app/retention/log_cap.go b/backend/app/retention/log_cap.go
new file mode 100644
index 00000000..c251c1a1
--- /dev/null
+++ b/backend/app/retention/log_cap.go
@@ -0,0 +1,54 @@
+package retention
+
+import (
+ "context"
+ "fmt"
+ "time"
+
+ "github.com/tracewayapp/traceway/backend/app/config"
+ "github.com/tracewayapp/traceway/backend/app/db"
+ traceway "go.tracewayapp.com"
+)
+
+const logCapTickInterval = time.Minute
+
+func startLogRecordsCap(ctx context.Context, maxRows int) {
+ if !db.IsSQLite() || maxRows <= 0 {
+ return
+ }
+
+ config.Logf("Starting log_records row cap worker (max rows: %d, interval: %s)", maxRows, logCapTickInterval)
+
+ go func() {
+ defer traceway.Recover()
+
+ runLogRecordsCap(ctx, maxRows)
+
+ ticker := time.NewTicker(logCapTickInterval)
+ defer ticker.Stop()
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-ticker.C:
+ runLogRecordsCap(ctx, maxRows)
+ }
+ }
+ }()
+}
+
+func runLogRecordsCap(ctx context.Context, maxRows int) {
+ if db.TelemetryDB == nil || ctx.Err() != nil {
+ return
+ }
+
+ // Deletes everything strictly older than the Nth-newest row; a no-op (NULL
+ // boundary) while the table holds maxRows rows or fewer.
+ query := fmt.Sprintf(
+ "DELETE FROM log_records WHERE timestamp < (SELECT timestamp FROM log_records ORDER BY timestamp DESC LIMIT 1 OFFSET %d)",
+ maxRows-1,
+ )
+ if _, err := db.TelemetryDB.ExecContext(ctx, query); err != nil {
+ traceway.CaptureException(fmt.Errorf("retention: log_records row cap delete failed: %w", err))
+ }
+}
diff --git a/backend/app/retention/log_cap_duckdb_test.go b/backend/app/retention/log_cap_duckdb_test.go
new file mode 100644
index 00000000..12139e1b
--- /dev/null
+++ b/backend/app/retention/log_cap_duckdb_test.go
@@ -0,0 +1,56 @@
+//go:build telemetry_duckdb
+
+package retention
+
+import (
+ "context"
+ "database/sql"
+ "testing"
+
+ "github.com/duckdb/duckdb-go/v2"
+ "github.com/tracewayapp/lit/v2"
+ "github.com/tracewayapp/traceway/backend/app/db"
+)
+
+func TestRunLogRecordsCap_DuckDBDeletesOldestBeyondCap(t *testing.T) {
+ connector, err := duckdb.NewConnector("", nil)
+ if err != nil {
+ t.Fatalf("open in-memory duckdb: %v", err)
+ }
+ telDB := sql.OpenDB(connector)
+
+ if _, err := telDB.Exec("CREATE TABLE log_records (id VARCHAR NOT NULL, timestamp TIMESTAMP NOT NULL)"); err != nil {
+ t.Fatalf("ddl: %v", err)
+ }
+ if _, err := telDB.Exec("INSERT INTO log_records SELECT 'r' || i, TIMESTAMP '2026-01-01' + to_seconds(i) FROM range(15) t(i)"); err != nil {
+ t.Fatalf("insert: %v", err)
+ }
+
+ prevTelDB, prevDriver := db.TelemetryDB, db.Driver
+ db.TelemetryDB = telDB
+ db.Driver = lit.SQLite
+ t.Cleanup(func() {
+ telDB.Close()
+ db.TelemetryDB = prevTelDB
+ db.Driver = prevDriver
+ })
+
+ runLogRecordsCap(context.Background(), 10)
+
+ var n int
+ if err := telDB.QueryRow("SELECT count(*) FROM log_records").Scan(&n); err != nil {
+ t.Fatalf("count: %v", err)
+ }
+ if n != 10 {
+ t.Errorf("got %d rows after cap, want 10", n)
+ }
+
+ // Rows i=5..14 are the 10 newest; nothing older than i=5 may survive.
+ var older int
+ if err := telDB.QueryRow("SELECT count(*) FROM log_records WHERE timestamp < TIMESTAMP '2026-01-01' + to_seconds(5)").Scan(&older); err != nil {
+ t.Fatalf("count older: %v", err)
+ }
+ if older != 0 {
+ t.Errorf("expected 0 rows older than the cap boundary, got %d", older)
+ }
+}
diff --git a/backend/app/retention/log_cap_test.go b/backend/app/retention/log_cap_test.go
new file mode 100644
index 00000000..33fa3caa
--- /dev/null
+++ b/backend/app/retention/log_cap_test.go
@@ -0,0 +1,76 @@
+//go:build !telemetry_ch
+
+package retention
+
+import (
+ "context"
+ "testing"
+ "time"
+
+ "github.com/tracewayapp/traceway/backend/app/db"
+)
+
+func TestRunLogRecordsCap_DeletesOldestBeyondCap(t *testing.T) {
+ setupRetentionTestDB(t)
+
+ now := time.Now().UTC().Truncate(time.Second)
+ for i := range 15 {
+ insertWithTime(t, db.TelemetryDB, "log_records", "timestamp", now.Add(time.Duration(-i)*time.Second))
+ }
+
+ runLogRecordsCap(context.Background(), 10)
+
+ assertCount(t, db.TelemetryDB, "log_records", 10)
+
+ // The 10 newest rows (offsets 0..-9s) survive; the boundary is -9s.
+ boundary := now.Add(-9 * time.Second).Format(time.RFC3339Nano)
+ var older int
+ if err := db.TelemetryDB.QueryRow("SELECT count(*) FROM log_records WHERE timestamp < ?", boundary).Scan(&older); err != nil {
+ t.Fatalf("count older: %v", err)
+ }
+ if older != 0 {
+ t.Errorf("expected 0 rows older than the cap boundary, got %d", older)
+ }
+}
+
+func TestRunLogRecordsCap_UnderCapIsNoOp(t *testing.T) {
+ setupRetentionTestDB(t)
+
+ now := time.Now().UTC().Truncate(time.Second)
+ for i := range 5 {
+ insertWithTime(t, db.TelemetryDB, "log_records", "timestamp", now.Add(time.Duration(-i)*time.Second))
+ }
+
+ runLogRecordsCap(context.Background(), 10)
+
+ assertCount(t, db.TelemetryDB, "log_records", 5)
+}
+
+func TestRunLogRecordsCap_ExactlyAtCapIsNoOp(t *testing.T) {
+ setupRetentionTestDB(t)
+
+ now := time.Now().UTC().Truncate(time.Second)
+ for i := range 10 {
+ insertWithTime(t, db.TelemetryDB, "log_records", "timestamp", now.Add(time.Duration(-i)*time.Second))
+ }
+
+ runLogRecordsCap(context.Background(), 10)
+
+ assertCount(t, db.TelemetryDB, "log_records", 10)
+}
+
+func TestRunLogRecordsCap_AlreadyCancelledContextIsNoOp(t *testing.T) {
+ setupRetentionTestDB(t)
+
+ now := time.Now().UTC().Truncate(time.Second)
+ for i := range 15 {
+ insertWithTime(t, db.TelemetryDB, "log_records", "timestamp", now.Add(time.Duration(-i)*time.Second))
+ }
+
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+
+ runLogRecordsCap(ctx, 10)
+
+ assertCount(t, db.TelemetryDB, "log_records", 15)
+}
diff --git a/backend/app/retention/retention.go b/backend/app/retention/retention.go
index 17377e00..0df631d8 100644
--- a/backend/app/retention/retention.go
+++ b/backend/app/retention/retention.go
@@ -7,6 +7,7 @@ import (
"time"
"github.com/tracewayapp/traceway/backend/app/config"
+ "github.com/tracewayapp/traceway/backend/app/db"
)
const (
@@ -17,7 +18,9 @@ const (
func Start(ctx context.Context) {
cfg := config.Config
- startSQLiteRetention(ctx, parseRetentionDays(cfg.SQLiteRetentionDays))
+ telemetryDays, telemetrySource := telemetryRetentionConfig(db.IsDuckDBTelemetry(), cfg.SQLiteRetentionDays, cfg.DuckDBRetentionDays)
+ startSQLiteRetention(ctx, telemetryDays, telemetrySource)
+ startLogRecordsCap(ctx, parseMaxRows(cfg.LogRecordsMaxRows))
startRecordingDiskCleanup(ctx, parseRetentionDays(cfg.SessionRecordingRetentionDays))
startProfileArchiveDiskCleanup(ctx, parseRetentionDays(cfg.ProfileRetentionDays))
startOAuthSessionsPrune(ctx)
@@ -36,3 +39,27 @@ func parseRetentionDays(value string) int {
}
return days
}
+
+// telemetryRetentionConfig picks the TTL for the embedded telemetry store. On
+// the DuckDB backend DUCKDB_RETENTION_DAYS wins when set, falling back to
+// SQLITE_RETENTION_DAYS so deployments that configured the old variable keep
+// their window. Both default to 30 days when unset or invalid.
+func telemetryRetentionConfig(isDuckDB bool, sqliteDays, duckdbDays string) (int, string) {
+ if isDuckDB && strings.TrimSpace(duckdbDays) != "" {
+ return parseRetentionDays(duckdbDays), "DUCKDB_RETENTION_DAYS"
+ }
+ return parseRetentionDays(sqliteDays), "SQLITE_RETENTION_DAYS"
+}
+
+// parseMaxRows returns 0 (disabled) for empty, invalid, or non-positive values.
+func parseMaxRows(value string) int {
+ trimmed := strings.TrimSpace(value)
+ if trimmed == "" {
+ return 0
+ }
+ rows, err := strconv.Atoi(trimmed)
+ if err != nil || rows < 0 {
+ return 0
+ }
+ return rows
+}
diff --git a/backend/app/retention/retention_test.go b/backend/app/retention/retention_test.go
new file mode 100644
index 00000000..7b20226d
--- /dev/null
+++ b/backend/app/retention/retention_test.go
@@ -0,0 +1,32 @@
+package retention
+
+import "testing"
+
+func TestTelemetryRetentionConfig(t *testing.T) {
+ cases := []struct {
+ name string
+ isDuckDB bool
+ sqliteDays string
+ duckdbDays string
+ wantDays int
+ wantSource string
+ }{
+ {"sqlite default", false, "", "", 30, "SQLITE_RETENTION_DAYS"},
+ {"sqlite explicit", false, "7", "", 7, "SQLITE_RETENTION_DAYS"},
+ {"sqlite ignores duckdb var", false, "7", "90", 7, "SQLITE_RETENTION_DAYS"},
+ {"duckdb default", true, "", "", 30, "SQLITE_RETENTION_DAYS"},
+ {"duckdb explicit", true, "", "90", 90, "DUCKDB_RETENTION_DAYS"},
+ {"duckdb wins over sqlite var", true, "7", "90", 90, "DUCKDB_RETENTION_DAYS"},
+ {"duckdb falls back to sqlite var", true, "7", "", 7, "SQLITE_RETENTION_DAYS"},
+ {"duckdb disabled", true, "7", "0", 0, "DUCKDB_RETENTION_DAYS"},
+ {"duckdb invalid uses default", true, "", "abc", 30, "DUCKDB_RETENTION_DAYS"},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ days, source := telemetryRetentionConfig(tc.isDuckDB, tc.sqliteDays, tc.duckdbDays)
+ if days != tc.wantDays || source != tc.wantSource {
+ t.Errorf("got (%d, %s), want (%d, %s)", days, source, tc.wantDays, tc.wantSource)
+ }
+ })
+ }
+}
diff --git a/backend/app/retention/sqlite.go b/backend/app/retention/sqlite.go
index 627b3ddf..efabd7a4 100644
--- a/backend/app/retention/sqlite.go
+++ b/backend/app/retention/sqlite.go
@@ -30,16 +30,16 @@ var telemetryRetentionTargets = []struct {
{"profiling_stacks", "last_seen"},
}
-func startSQLiteRetention(ctx context.Context, days int) {
+func startSQLiteRetention(ctx context.Context, days int, source string) {
if !db.IsSQLite() {
return
}
if days == 0 {
- config.Logln("SQLite retention disabled (SQLITE_RETENTION_DAYS=0)")
+ config.Logf("Telemetry retention disabled (%s=0)", source)
return
}
- config.Logf("Starting SQLite retention worker (TTL: %d days, interval: %s)", days, tickInterval)
+ config.Logf("Starting telemetry retention worker (TTL: %d days, interval: %s, via %s)", days, tickInterval, source)
go func() {
defer traceway.Recover()
diff --git a/docs/pages/learn/hardware-requirements.mdx b/docs/pages/learn/hardware-requirements.mdx
index b5a5617a..f4efe628 100644
--- a/docs/pages/learn/hardware-requirements.mdx
+++ b/docs/pages/learn/hardware-requirements.mdx
@@ -74,7 +74,7 @@ Two things differ from the SQLite sizing story:
Under sustained ingest, `DUCKDB_CHECKPOINT_THRESHOLD` (default 16MB) can be raised to reduce WAL checkpoint stalls at the cost of a larger WAL and longer restart replay.
-Disk behaves like the SQLite story above (same retention worker, same `/data` volume), but columnar compression makes the telemetry file several times smaller for the same rows.
+Disk behaves like the SQLite story above (same retention worker, configured with `DUCKDB_RETENTION_DAYS`, same `/data` volume), but columnar compression makes the telemetry file several times smaller for the same rows.
## ClickHouse + PostgreSQL mode
diff --git a/docs/pages/learn/logs.mdx b/docs/pages/learn/logs.mdx
index 752216e8..e0eddf12 100644
--- a/docs/pages/learn/logs.mdx
+++ b/docs/pages/learn/logs.mdx
@@ -117,7 +117,7 @@ No extra configuration is required — the standard OTel context propagation car
## Retention
-Logs are stored in ClickHouse with daily partitioning and a 90-day TTL on the timestamp date. Older logs are removed automatically without operator intervention. Self-hosted deployments on SQLite or DuckDB prune logs after 30 days by default, configurable with `SQLITE_RETENTION_DAYS`.
+Logs are stored in ClickHouse with daily partitioning and a 90-day TTL on the timestamp date. Older logs are removed automatically without operator intervention. Self-hosted deployments on SQLite or DuckDB prune logs after 30 days by default, configurable with `SQLITE_RETENTION_DAYS` (on DuckDB, `DUCKDB_RETENTION_DAYS`). They can additionally cap the log table with `LOG_RECORDS_MAX_ROWS`. The cap is a cleanup task, not a hard limit: every minute the oldest logs are deleted until only the newest N rows remain. A burst that ingests more than N rows within one minute can still push the table past the cap until the next run, so size the cap with headroom for your peak log volume.
## Sending Logs
diff --git a/docs/pages/server/duckdb.mdx b/docs/pages/server/duckdb.mdx
index dbde2b7a..ef91432a 100644
--- a/docs/pages/server/duckdb.mdx
+++ b/docs/pages/server/duckdb.mdx
@@ -45,12 +45,13 @@ Identical to the SQLite image: blobs (source maps, session recordings, AI traces
## Configuration
-All [SQLite deployment variables](/server/sqlite#configuration) apply unchanged (`JWT_SECRET`, `APP_BASE_URL`, `SQLITE_PATH`, `STORAGE_*`, `S3_*`, `PORTS`, `SQLITE_RETENTION_DAYS`, `SESSION_RECORDING_RETENTION_DAYS`). The retention worker prunes the DuckDB telemetry tables on the same `SQLITE_RETENTION_DAYS` schedule and issues a `CHECKPOINT` afterwards so deleted rows are actually reclaimed from disk.
+All [SQLite deployment variables](/server/sqlite#configuration) apply unchanged (`JWT_SECRET`, `APP_BASE_URL`, `SQLITE_PATH`, `STORAGE_*`, `S3_*`, `PORTS`, `LOG_RECORDS_MAX_ROWS`, `SESSION_RECORDING_RETENTION_DAYS`). The retention worker prunes the DuckDB telemetry tables hourly and issues a `CHECKPOINT` afterwards so deleted rows are actually reclaimed from disk. It keeps 30 days by default, configurable with `DUCKDB_RETENTION_DAYS` (when that is unset, a configured `SQLITE_RETENTION_DAYS` still applies as a fallback).
-On top of those, the DuckDB engine has three knobs:
+On top of those, the DuckDB build has these knobs:
| Variable | Default | Description |
|----------|---------|-------------|
+| `DUCKDB_RETENTION_DAYS` | `30` | Days to keep telemetry rows in the DuckDB store. Not a hard cutoff: a cleanup task runs once an hour and deletes rows older than the window, so expired rows can linger until the next run. Set to `0` to disable pruning. Falls back to `SQLITE_RETENTION_DAYS` when unset. |
| `DUCKDB_MEMORY_LIMIT` | *(unset, DuckDB auto-tunes to ~80% of host RAM)* | Memory budget for the telemetry engine, e.g. `2GB`. Set it explicitly in any memory-capped container, to roughly half the container's RAM. |
| `DUCKDB_THREADS` | *(unset, DuckDB uses all cores)* | Caps the engine's thread count, e.g. `4`. Useful on shared hosts. |
| `DUCKDB_CHECKPOINT_THRESHOLD` | *(unset, DuckDB default 16MB)* | WAL size that triggers a checkpoint, e.g. `256MB`. Raise it under sustained ingest to reduce checkpoint stalls; the cost is a larger WAL on disk and a longer replay after a restart. |
diff --git a/docs/pages/server/local-setup.mdx b/docs/pages/server/local-setup.mdx
index 59b6b36b..8ee288c3 100644
--- a/docs/pages/server/local-setup.mdx
+++ b/docs/pages/server/local-setup.mdx
@@ -81,6 +81,8 @@ POSTGRES_SSLMODE=disable
| `OAUTH_SESSION_SECRET` | Optional. Cookie signing secret for the OAuth round-trip. Falls back to `JWT_SECRET` when unset. |
| `SESSION_RECORDING_RETENTION_DAYS` | Optional. Days to keep session recording files on disk under `STORAGE_PATH/recordings/`. Defaults to `30`. Worker runs hourly and on startup. `0` disables; no effect when `STORAGE_TYPE=s3`. |
| `SQLITE_RETENTION_DAYS` | Optional. Days to keep SQLite telemetry rows. Defaults to `30`. `0` disables. Only applies when running with `DB_TYPE=sqlite`. |
+| `DUCKDB_RETENTION_DAYS` | Optional. Days to keep telemetry rows on the DuckDB backend (`-tags telemetry_duckdb` build). Defaults to `30`, falling back to `SQLITE_RETENTION_DAYS` when unset. `0` disables. Pruning runs hourly, so expired rows can linger between runs. |
+| `LOG_RECORDS_MAX_ROWS` | Optional. Caps the log table via a cleanup task that runs every minute and keeps only the newest N rows. Not a hard limit: ingesting more than N rows within a minute exceeds the cap until the next run. Unset or `0` disables. Only applies when running with `DB_TYPE=sqlite` (SQLite or DuckDB telemetry). |
For local OAuth testing, register the provider's callback URL as `http://localhost:5173/api/auth/callback/github` (or `.../google`).
diff --git a/docs/pages/server/sqlite.mdx b/docs/pages/server/sqlite.mdx
index 34d8b457..c3fc4ab9 100644
--- a/docs/pages/server/sqlite.mdx
+++ b/docs/pages/server/sqlite.mdx
@@ -73,6 +73,7 @@ If `STORAGE_TYPE` is unset (or set to `local`), blobs are written to `/data/stor
| `PORTS` | `80,8082` | Comma-separated list of HTTP ports the server should listen on |
| `GIN_MODE` | `release` | Gin runtime mode |
| `SQLITE_RETENTION_DAYS` | `30` | Days to keep telemetry rows (endpoints, exceptions, spans, metrics, logs, sessions, recordings, fired notifications, notification history). A background worker prunes older rows once at startup and then every hour. Set to `0` to disable. |
+| `LOG_RECORDS_MAX_ROWS` | *(unset)* | Optional cap on the number of log rows, independent of `SQLITE_RETENTION_DAYS`. This is not a hard limit: a cleanup task runs every minute and deletes the oldest logs until only the newest N rows remain. Between runs the table can grow past N, and if you ingest more than N rows in a single minute the table (and disk usage) will exceed the cap until the next cleanup. Size it with headroom for your peak ingest rate. Unset or `0` disables the cap. |
| `SESSION_RECORDING_RETENTION_DAYS` | `30` | Days to keep session recording files on disk under `STORAGE_PATH/recordings/`. Files older than the TTL are deleted hourly and on startup; empty subdirectories are removed. No effect when `STORAGE_TYPE=s3`. Set to `0` to disable. |
## SSO (optional)