Repository navigation
feat(telemetry): add phase 1 telemetry foundation - #266
Conversation
Signed-off-by: Jay Xiao <jay.xiao@databricks.com>
Signed-off-by: Jay Xiao <jay.xiao@databricks.com>
9002140 to
824ce3c
Compare
There was a problem hiding this comment.
Verdict: 1 Medium · 3 Low
Solid, well-tested telemetry foundation with clean fail-open wiring and good serialization-shape coverage. One medium concern: sanitize_error sources DriverErrorInfo.stack_trace from the 5-char sql_state, which mislabels the field and drops the actual error detail on the paths that hit it (see F1). A few low-severity notes on the always-disabled-in-production gate, unbounded in_flight handle growth, and a runtime_version that can never populate. Nits: several DriverConnectionParameters values (mode/enable_arrow/enable_direct_results/auto_commit) are hardcoded rather than derived from actual session config — fine for the foundation phase but worth revisiting as those knobs become real.
| fn sanitize_error(error: &KernelError) -> DriverErrorInfo { | ||
| DriverErrorInfo { | ||
| error_name: Some(error.code.slug().to_string()), | ||
| stack_trace: error.sql_state.clone(), |
There was a problem hiding this comment.
🟡 Medium — sanitize_error populates DriverErrorInfo.stack_trace from error.sql_state. That is a semantic mismatch: sql_state is a 5-character SQLSTATE code (e.g. 42601), not a stack trace. Two consequences:
- For the common error paths that flow through this code (a failed
delete_session, i.e. transport/network/HTTP errors),sql_stateis almost alwaysNone, sostack_tracewill be empty and the error telemetry carries onlyerror_name(the code slug) — no descriptive detail at all. - When
sql_stateis present, it is mislabeled as a stack trace, which will confuse anyone reading the telemetry against the documented envelope shape.
The Error type carries richer, more relevant fields for diagnostics — message, diagnostic_info, error_code — that would be more appropriate here (subject to whatever redaction policy applies). At minimum, sourcing stack_trace from sql_state looks like a copy/paste of the wrong field.
| session_id: Some(self.session.session_id.clone()), | ||
| system_configuration: Some(self.session.system_configuration.clone()), | ||
| driver_connection_params: Some(self.session.connection_params.clone()), | ||
| auth_type: Some(self.session.auth_type.clone()), |
There was a problem hiding this comment.
🔵 Low — In non-test builds test_or_noop_exporter always returns None, so from_config returns TelemetryRuntime::disabled() even when the caller set TelemetryConfig { enabled: true, .. }. This is expected for the phase-1 foundation (no production exporter is wired yet), but a user who opts in via the public SessionBuilder::telemetry(..) + enabled: true gets a completely silent no-op with no log line indicating telemetry was dropped. Consider a one-time tracing::debug!/warn! when enabled is true but no exporter is available, so the silent-disable is diagnosable once real exporters land.
| pub(super) fn enqueue(&self, log: TelemetryFrontendLog) { | ||
| let batch = { | ||
| let mut pending = self.pending.lock().expect("poisoned telemetry queue"); | ||
| pending.push(log); |
There was a problem hiding this comment.
🔵 Low — enqueue pushes every spawned batch-export JoinHandle into in_flight, but handles are only removed in drain_in_flight(), which runs solely from flush_bounded() (session close). For a long-lived session that flushes many batches before close, the in_flight vector grows monotonically with completed-but-not-joined handles and is never pruned until close. For phase-1 connection telemetry (one create + one delete per session) this is negligible, but the client is generic and later phases enqueue per-statement events. Consider retaining only unfinished handles (e.g. drop finished ones opportunistically on enqueue) to bound memory over a session's lifetime.
| let defaults = DriverSystemConfiguration { | ||
| driver_version: Some(env!("CARGO_PKG_VERSION").to_string()), | ||
| runtime_name: Some("rust".to_string()), | ||
| runtime_version: option_env!("RUSTC_VERSION").map(str::to_string), |
There was a problem hiding this comment.
🔵 Low — runtime_version is read from option_env!("RUSTC_VERSION"), but nothing in the repo sets that environment variable at build time (no build.rs emits it; rustc_version appears only as a transitive lock entry). option_env! is evaluated at compile time, so this field will always be None and runtime_version will never be emitted. Either wire up a build.rs that exports RUSTC_VERSION (via the rustc_version crate already in the lock graph) or drop the field until it can be populated, to avoid a field that silently never appears.
|
/trigger all |
824ce3c to
f214647
Compare
There was a problem hiding this comment.
Verdict: 1 Low
Solid foundational PR — verified against the reference C# driver's proto schema/models: wrapper field casing (uploadTime/protoLogs camelCase, workspace_id/frontend_log_event_id snake_case), enum SCREAMING_SNAKE_CASE values, and the full field set all match. One low note: the inner sql_driver_log int64 fields serialize as JSON numbers whereas the reference's proto3-JSON path emits them as strings — likely benign since proto parsers accept both, but worth a conscious decision given the PR's parity goal.
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub error_info: Option<DriverErrorInfo>, | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub operation_latency_ms: Option<i64>, |
There was a problem hiding this comment.
🔵 Low — The inner OssSqlDriverTelemetryLog and its nested messages are serialized here with plain serde_json, which emits 64-bit integers (operation_latency_ms, *_latency_millis, chunk_id, retry_count, http_connection_pool_size, socket_timeout, etc.) as JSON numbers. The reference C# driver serializes this same message through the protobuf JsonFormatter (ProtoJsonConverter.cs), and the proto3 JSON mapping encodes int64/uint64/fixed64 fields as JSON strings (e.g. "operation_latency_ms": "25", not 25). So the on-wire shape of sql_driver_log diverges from the reference for every 64-bit field.
This is likely benign in practice — the proto3 JSON spec requires parsers to accept both a number and a decimal string for int64, so a compliant backend parser should ingest the numeric form. But since this PR's stated goal is to mirror "the SQL driver telemetry envelope used by the ADBC and JDBC drivers," it's worth a deliberate decision + a note (and ideally a test asserting the chosen int64 representation), rather than an incidental difference. Note this only affects fields inside sql_driver_log; the wrapper workspace_id/timestamp_millis are number-typed in the reference too (System.Text.Json), so those already match.
|
/merge |
🥞 Stacked PR
Use this link to review incremental changes.
Summary
This PR is Phase 1 of the telemetry stack. It contains only the foundational telemetry model contract and local test-support exports.
Phase 1:
Phase 2 connection telemetry has been split into the next stack PR.
Flow
flowchart LR model[Telemetry Models] request[TelemetryRequest] exporter[TelemetryExporter trait] capture[Capturing Test Exporter] tests[Serialization + capture tests] model --> request request --> exporter exporter --> capture capture --> testsStack
gitGraph commit id: "main" branch kernel-telemetry-phase-1 checkout kernel-telemetry-phase-1 commit id: "phase 1: model contract" commit id: "phase 1: local exports"Validation
Previously run on this stack:
cargo test telemetry --lib --lockedgit diff --check