feat: log tailnet tunnels to the connection log (#27423)

Co-authored-by: Chris DiGiamo <cd@anthropic.com>
Co-authored-by: Chris DiGiamo <cdigiamo@anthropic.com>
This commit is contained in:
Jon Ayers
2026-07-28 15:30:12 -05:00
committed by GitHub
co-authored by Chris DiGiamo Chris DiGiamo
parent 8cc7f2bb0e
commit 1a6a8be96c
21 changed files with 381 additions and 30 deletions
+14
View File
@@ -466,6 +466,20 @@ func (p *DBTokenProvider) connLogInitRequest(w http.ResponseWriter, r *http.Requ
connType = database.ConnectionTypeWorkspaceApp
}
// An empty slug_or_port is reserved for tunnel sessions (see
// coderd/workspaceagents.go logTunnelConnection); writing one
// here would collide with them in the audit session dedupe
// index. Request.Check rejects empty slugs, so this is
// unreachable today.
if slugOrPort == "" {
p.Logger.Critical(ctx, "workspace app audit session has empty slug_or_port, skipping connection log",
slog.F("workspace_id", aReq.dbReq.Workspace.ID),
slog.F("agent_id", aReq.dbReq.Agent.ID),
slog.F("app_id", aReq.dbReq.App.ID),
)
return
}
// If we end up logging, ensure relevant fields are set.
logger := p.Logger.With(
slog.F("workspace_id", aReq.dbReq.Workspace.ID),