Skip to content

feat(appkit): correlate Lakebase queries with request traces - #737

Draft
stepashka wants to merge 1 commit into
databricks:mainfrom
stepashka:feat/xta-21643-lakebase-trace-context
Draft

stepashka wants to merge 1 commit into
databricks:mainfrom
stepashka:feat/xta-21643-lakebase-trace-context

Conversation

@stepashka

Copy link
Copy Markdown

Summary

  • Generate a withLakebaseTraceContext helper for direct Lakebase SQL in AppKit scaffolds. It reads the active OpenTelemetry span at query execution, adds a W3C traceparent comment and sanitized service label, and preserves query parameters and sampling flags. Queries without a valid active span remain unchanged.
  • Use the helper in the sample Lakebase routes and document app span export and captured plan correlation. The helper covers these direct string queries; raw pools, checked-out clients, ORMs, and the optional agent tool are outside this change.
  • Sync the scaffold manifest and lockfiles. Correct existing Knip exclusions for the published CLI file and dependencies used by repository tools so the required commit and CI check passes.

Validation

  • Node 22.23.4 and pnpm 11.0.8: pnpm build, pnpm docs:build, pnpm check:fix, pnpm -r typecheck, pnpm test (333 files and 6,174 tests passed; one skipped), pnpm check, pnpm docs:check, pnpm knip, license and template dependency checks, generated types and manifest sync, and public registry lockfile checks.
  • Rendered scaffolds with Lakebase enabled and disabled. The enabled scaffold passed 13 tests with both pnpm and npm and built successfully. Both package manager template install/build/startup smoke checks passed.
  • Ran two concurrent HTTP requests through the generated helper and a real Lakebase PostgreSQL branch. Both parameterized queries returned their values, and each SQL comment matched its exported request span. The service label was sanitized.
  • The playground integration suite passed 29 tests with installed system Chrome. The standard local run could not launch because this machine lacks Playwright's pinned Chromium binary; CI installs that binary.

Remaining verification

I could not read system.lakebase.plan_history from the available test workspace because the principal lacks USE SCHEMA on system.lakebase. The live test above verifies SQL execution and span/comment identity, but a captured plan row remains unverified. This PR is a draft for that reason.

The downstream app-templates repository is populated by AppKit's release sync; I validated its rendered Lakebase variant locally and am leaving that update to the existing sync process.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant