Uh oh!
There was an error while loading. Please reload this page.
feat(kernel): surface kernel logs through Python logging on use_kernel - #824
Conversation
When the kernel backend loads, auto-initialize the kernel's
tracing -> Python logging bridge so `use_kernel=True` users see kernel
logs with no extra setup. Kernel logs land under the
`databricks.sql.kernel` logger (a child of the connector's
`databricks.sql.*` namespace), so an existing
`logging.getLogger("databricks.sql").setLevel(...)` cascades to them.
- `_errors.py` calls `databricks_sql_kernel.init_logging()` once at
extension load (it's the canonical kernel-import site). The call is
`getattr`-guarded so an older kernel wheel without the function still
works — just without kernel logs.
- e2e tests assert kernel records reach the `databricks.sql.kernel`
logger (and the pyo3 boundary under `databricks.sql.kernel.pyo3`) and
that the level set on the logger is respected. Creds-gated per the
existing kernel e2e convention.
Requires the companion kernel/pyo3 change
(databricks-sql-kernel#120) that exposes `init_logging()`.
Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>gopalldb
commented
Jun 4, 2026
🟠 P1 (Important — should fix before merge)
🟡 P2 (Minor)
|
Review feedback from PR #824 (gopalldb): - P1: guard the init_logging() call against throwing, not just a missing function. A panic across the PyO3 boundary surfaces as pyo3_runtime.PanicException (a BaseException, not Exception), so a bare call could escape module import and fail every use_kernel=True connection over a non-essential logging feature. Wrap in try/except BaseException, log a debug breadcrumb, continue. This also neutralizes the idempotency concern regardless of the Rust impl. - P2: soften the level-control test docstring to make clear it asserts the effective customer-visible outcome (sub-threshold records don't surface), not source-side suppression — caplog filters after the FFI. - P2: downgrade the databricks.sql.kernel.pyo3 assertion to a soft warning so a benign kernel change to the boundary breadcrumb target doesn't break the connector e2e suite. The core databricks.sql.kernel contract is still hard-asserted. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
vikrantpuppala
commented
Jun 4, 2026
Thanks @gopalldb — these are great catches. Dispositions below; pushed in ca9234b. P1#1 — bare |
Uh oh!
There was an error while loading. Please reload this page.
…g bridge The kernel tracing -> Python logging bridge (init_logging / pyo3-log, routing under databricks.sql.kernel) landed in kernel #120 — AFTER the previously-pinned 101aa46 (#118). The kernel-e2e built a wheel without the bridge, so test_kernel_logs_reach_python_logging failed with 'no records delivered' (assert []). Bump to f4ee6fe (current kernel main: includes #118, #120, #123, #125). Verified live against a wheel built from f4ee6fe: the bridge delivers records to the databricks.sql.kernel logger, and both test_kernel_logs_reach_python_logging and test_kernel_log_level_is_respected pass. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com> # Conflicts: # KERNEL_REV
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
On the
use_kernel=Truepath, the Rust kernel's logs now surface through Python's stdlibloggingautomatically — no extra setup. Kernel logs land under thedatabricks.sql.kernellogger, a child of the connector'sdatabricks.sql.*namespace, so a customer's existing logging config just works:Before this, kernel-backed sessions emitted nothing into Python logging — the kernel produced
tracingevents but nothing on the Python path consumed them.Changes
backend/kernel/_errors.pycallsdatabricks_sql_kernel.init_logging()once when the kernel extension loads (the canonical kernel-import site). The call isgetattr-guarded, so an older kernel wheel without the function still works — just without kernel logs.tests/e2e/test_kernel_backend.pyadds two creds-gated e2e tests (matching the existing kernel e2e convention):test_kernel_logs_reach_python_logging— a query at DEBUG produces records ondatabricks.sql.kernel, and the pyo3 boundary surfaces underdatabricks.sql.kernel.pyo3.test_kernel_log_level_is_respected— at WARNING, the chatty DEBUG kernel records are filtered out (proving level control, not unconditional forwarding).Cross-layer visibility
With this, a single query shows the full vertical in one stream:
Dependency
Requires the companion kernel/pyo3 change that exposes
init_logging(): databricks/databricks-sql-kernel#120. Until a kernel wheel containing that function is installed, this is a no-op (thegetattrguard), so it's safe to merge independently.Testing
Both e2e tests pass against a live warehouse with a locally-built kernel wheel (
maturin develop).🤖 Generated with Claude Code