Repository navigation
feat(telemetry): wire connection telemetry - #267
Conversation
There was a problem hiding this comment.
Verdict: 2 Low
Looks good — clean connection-telemetry wiring with proper fail-open semantics (export failures swallowed, close() succeeds regardless) and solid test coverage across disabled/enabled/custom-config/failure cases. Two low-severity notes: build_connection_params emits several hardcoded/reconstructed values that can misreport the real session config, and in_flight JoinHandles are only reaped at close (a latent unbounded-growth for future high-volume telemetry paths, not triggered by connection events in this PR). Nit: in non-test builds test_or_noop_exporter always returns None, so TelemetryConfig { enabled: true } is currently an intentional no-op — this is clearly staged per the module doc, just worth keeping visible until the production exporter lands.
Scope: reviewed as a stacked increment (f214647..head); the parent's changes are reviewed on the parent PR.
| os_version: override_config.os_version.or(defaults.os_version), | ||
| os_arch: override_config.os_arch.or(defaults.os_arch), | ||
| driver_name: override_config.driver_name.or(defaults.driver_name), | ||
| client_app_name: override_config.client_app_name.or(defaults.client_app_name), |
There was a problem hiding this comment.
🔵 Low — build_connection_params reports several connection facts as hardcoded constants rather than reading them from the actual session config:
http_pathis reconstructed as/sql/1.0/warehouses/{warehouse_id}instead of using the path the connection was actually configured with.modeis alwaysSea.auto_commitis alwaysSome(true), even though a caller can open a session and disable autocommit (set_autocommit), andenable_arrow/enable_direct_resultsare unconditionallytrue.
This is telemetry-only metadata (no functional impact), but it means the emitted DriverConnectionParameters can misreport the session's real configuration, which undercuts the value of the telemetry. Consider threading the real values through, or dropping fields you can't yet source accurately rather than emitting a fixed guess.
| self.in_flight | ||
| .lock() | ||
| .expect("poisoned telemetry in-flight queue") | ||
| .push(handle); |
There was a problem hiding this comment.
🔵 Low — Completed export JoinHandles pushed into in_flight are only ever reaped by flush_bounded (i.e. at session close). For a long-lived session that spawns many batches, the in_flight vector accumulates already-finished handles for the entire session lifetime, growing without bound. Connection telemetry alone won't trigger this (only 2 events/session vs. batch_size 200, so no batch spawn fires here), but once statement/result-stream telemetry lands on this path it will. Consider retaining only unfinished handles (e.g. retain(|h| !h.is_finished())) when enqueuing, so completed tasks are dropped incrementally.
- build Phase 2 connection telemetry on top of the split Phase 1
telemetry modules
- expand TelemetryConfig with connection telemetry knobs
- expose top-level SessionBuilder/SessionConfig driver system
configuration for binding-provided driver identity
- add TelemetryRuntime, no-op/real connection telemetry, and minimal
in-memory export queue
- emit CREATE_SESSION and DELETE_SESSION telemetry through
Session::open/close
- add tests for disabled telemetry, close flush, fail-open exporter
errors, and driver system configuration defaults
```mermaid
flowchart LR
TelemetryConfig[SessionConfig.telemetry] --> Open[Session::open]
DriverSystem[SessionConfig.driver_system_configuration] --> Open
Open --> Runtime[runtime.rs\nTelemetryRuntime]
Runtime --> NoOp[runtime.rs\nNoOpConnectionTelemetry]
Runtime --> Real[runtime.rs\nRealConnectionTelemetry]
Real --> Context[runtime.rs\nTelemetrySessionContext]
DriverSystem --> Context
Real --> Client[client.rs\nTelemetryClient]
Client --> Queue[In-memory pending queue]
Client --> Exporter[exporter.rs\nTelemetryExporter]
Exporter --> Request[models.rs\nTelemetryRequest protoLogs]
Runtime --> Models[models.rs\nOssSqlDriverTelemetryLog]
```
```mermaid
sequenceDiagram
participant User
participant Session
participant Transport
participant Runtime as TelemetryRuntime
participant Client as TelemetryClient
participant Exporter as TelemetryExporter
User->>Session: open(config)
Session->>Transport: create_session(...)
Transport-->>Session: session_id
Session->>Runtime: emit CREATE_SESSION
Runtime->>Client: enqueue event
Session-->>User: Session
User->>Session: close()
Session->>Transport: delete_session(session_id)
Transport-->>Session: ok/error
Session->>Runtime: emit DELETE_SESSION
Runtime->>Client: bounded flush
Client->>Exporter: export TelemetryRequest
Exporter-->>Client: ok/error swallowed
Session-->>User: delete_session result
```
- cargo +stable fmt --all --check
- git diff --check
- cargo test telemetry --lib --locked
- cargo test --locked
- cargo clippy --lib --locked -- -D warnings
- cargo clippy --all-targets --locked -- -D warnings
---------
Signed-off-by: Jay Xiao <jay.xiao@databricks.com>
Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Co-authored-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Signed-off-by: Jay Xiao <jay.xiao@databricks.com>
824ce3c to
8f7e2f1
Compare
There was a problem hiding this comment.
Verdict: 1 Medium · 1 Low
Solid, well-tested plumbing for connection telemetry — fail-open behavior is verified and event ordering is covered. Two non-blocking concerns: sanitize_error maps SQLSTATE into the stack_trace field (semantic mismatch, drops real diagnostic context) and build_connection_params hardcodes mode/auto_commit/enable_arrow rather than reflecting actual config. Note also (by design for this phase) that test_or_noop_exporter returns None in non-test builds, so enabled: true emits nothing in production until the production exporter lands in a later phase — expected given the stacked-PR scope.
| } | ||
| } | ||
|
|
||
| fn auth_flow(auth: &AuthConfig) -> Option<DriverAuthFlow> { |
There was a problem hiding this comment.
🟡 Medium — sanitize_error stuffs the 5-character SQLSTATE into the stack_trace field:
fn sanitize_error(error: &KernelError) -> DriverErrorInfo {
DriverErrorInfo {
error_name: Some(error.code.slug().to_string()),
stack_trace: error.sql_state.clone(),
}
}This is a semantic mismatch — telemetry consumers reading stack_trace will get a value like 42P01, not a trace. KernelError already carries a field intended for exactly this: diagnostic_info (documented as "Multi-line text with stack frames or operator context"). Consider mapping stack_trace from diagnostic_info (or leaving it None) and surfacing SQLSTATE elsewhere, so the field's meaning matches the ADBC/JDBC envelope other drivers emit. As written the actual failure context (error.message, diagnostic_info) is dropped entirely and the one field that is populated is misleading.
| auth: &AuthConfig, | ||
| ) -> DriverConnectionParameters { | ||
| DriverConnectionParameters { | ||
| http_path: Some(format!("/sql/1.0/warehouses/{}", connection.warehouse_id)), |
There was a problem hiding this comment.
🔵 Low — build_connection_params hardcodes several connection attributes that are actually configurable: mode: DriverMode::Sea, auto_commit: Some(true), enable_arrow: Some(true), enable_direct_results: Some(true). SessionConfig exposes a transport: Option<TransportMode> and autocommit can be toggled via set_autocommit, so this telemetry will misreport those parameters when the caller diverges from the defaults (e.g. Thrift transport or autocommit off). Since these are captured once at session-open time this may be acceptable for now, but the hardcoded mode/auto_commit will silently drift from reality. Worth a comment noting these are placeholders, or wiring them from the real config.
🥞 Stacked PR
Use this link to review incremental changes.
Summary
Separates Phase 2 from the Phase 1 foundation in the telemetry stack.
This PR wires connection-level telemetry on top of the Phase 1 model/test-support contract:
TelemetryRuntimeand connection telemetry context/client wiringDriverSystemConfigurationwith kernel defaultsStack
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" branch kernel-telemetry-phase-2 checkout kernel-telemetry-phase-2 commit id: "phase 2: connection telemetry"Connection Flow
sequenceDiagram participant User participant Session participant Transport participant Runtime as TelemetryRuntime participant Client as TelemetryClient participant Exporter as TelemetryExporter User->>Session: open(config) Session->>Transport: create_session(...) Transport-->>Session: session_id Session->>Runtime: emit CREATE_SESSION Runtime->>Client: enqueue event Session-->>User: Session User->>Session: close() Session->>Transport: delete_session(session_id) Session->>Runtime: emit DELETE_SESSION Runtime->>Client: bounded flush Client->>Exporter: export TelemetryRequest Exporter-->>Client: ok/error swallowedValidation
Previously run on this stack:
cargo test telemetry --lib --lockedcargo test c_abi::session --lib --lockedgit diff --check