Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ changes go in their respective binding's NEXT_CHANGELOG.

- Feature flags are fetched after kernel authentication and before session
creation; sessions read process-cache values instead of retaining snapshots.
- Kernel telemetry enablement now follows the connector-service Kernel feature
flag when the client leaves it unspecified; explicit client enable/disable
settings take precedence.
- **Breaking (Rust API):** `TelemetryConfig::enabled` changes type from `bool`
to `Option<bool>`, where `None` defers to the workspace feature flag. Direct
Rust consumers that read or assign this public field must migrate (e.g. use
the new `with_enabled`/`set_enabled` helpers or wrap values in `Some(..)`).
- Added a backward-compatible C telemetry-config v2 setter whose nullable
config and `has_enabled` field preserve unspecified client enablement.

### Updated

Expand Down
2 changes: 1 addition & 1 deletion docs/designs/kernel-telemetry-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ should follow ADBC unless product owners choose a kernel-specific endpoint:
- Endpoint format currently used by ADBC:
`/api/2.0/connector-service/feature-flags/ADBC/{driver_version}`.
- Existing server-side flag:
`databricks.partnerplatform.clientConfigsFeatureFlags.enableTelemetryForAdbc`.
`databricks.partnerplatform.clientConfigsFeatureFlags.enableTelemetryForKernel`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — The design doc previously named ADBC's enableTelemetryForAdbc as the "Existing server-side flag" and advised following ADBC's flag "unless product owners choose a kernel-specific endpoint" / "only after the backend/dashboard owner confirms the split." This PR both renames the doc entry to enableTelemetryForKernel and hardcodes that name in src/session.rs:81, while still labeling it "Existing server-side flag". If connector-service does not yet serve enableTelemetryForKernel, the label is inaccurate and feature-flag enablement will silently never fire (fail-safe: get_bool returns None → telemetry stays disabled by default, so no correctness break). Worth confirming the backend actually exposes this kernel-specific flag, and noting in the PR that the split was owner-approved, since the doc itself gates that rename on confirmation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛔ NEEDS HUMAN DECISION — the bots can't resolve this thread; a maintainer's input is required.

The comment's core ask — confirm connector-service actually serves enableTelemetryForKernel and that the ADBC→kernel flag split was owner-approved — is an out-of-band product/backend fact I cannot verify from the repo, and the doc itself gates the rename on that confirmation. There is no correctness break (reviewer notes the fail-safe: get_bool→None→telemetry stays disabled by default), so no defensive code change is warranted, and a speculative doc-label edit could contradict the real product decision in either direction. A human must confirm with the backend/dashboard owner whether the kernel-specific flag exists and the split is approved, then either keep the "Existing server-side flag" label (and note owner approval in the PR) or revert the rename in both the doc and src/session.rs:81.

Comment thread
jay-xiao446 marked this conversation as resolved.
Resolved

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — This line now labels ...clientConfigsFeatureFlags.enableTelemetryForKernel as the "Existing server-side flag," and src/session.rs keys enablement off that exact name. Two things are left inconsistent:

  1. The guidance paragraph a few lines below is unchanged and still says to "introduce a kernel-specific flag only after the backend/dashboard owner confirms the split." The doc now simultaneously declares a kernel-specific flag as existing and warns not to introduce one without backend confirmation — please reconcile, and confirm the flag actually exists server-side.
  2. The endpoint line directly above still reads /feature-flags/ADBC/{driver_version}, while the real resolver builds the path from the per-driver-family segment (GOLANG/NODEJS/ODBC/PYTHON, see ClientType::as_endpoint_segment) — there is no ADBC/KERNEL client type. So the flag must be served under those driver families, not an ADBC/kernel namespace.

Functionally this is fail-open (an absent flag resolves to None → disabled), so there's no correctness risk — but if the backend hasn't published enableTelemetryForKernel under the relevant client types yet, feature-flag-driven enablement is a silent no-op until it does. Worth a confirmation + a doc touch-up.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied the fix locally but the push failed (likely another commit landed on this branch since I started). This bundle covered 1 thread(s); all reverted. Re-trigger by replying to this thread.

[push retry after rebase failed]
: 
remote: - A pull request for this branch has been added to a merge queue. Branches that        
remote:   are queued for merging cannot be updated. To modify this branch, dequeue the        
remote:   associated pull request.        
To https://github.com/databricks/databricks-sql-kernel.git
 ! [remote rejected] jay/telemetry-feature-flag -> jay/telemetry-feature-flag (protected branch hook declined)
error: failed to push some refs to 'https://github.com/databricks/databricks-sql-kernel.git'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the attempt — but the push was rejected by the merge queue, so no change actually landed. The current head still shows all three pieces I flagged: the endpoint line reads /feature-flags/ADBC/{driver_version}, line 342 labels enableTelemetryForKernel as the "Existing server-side flag," and the guidance just below still says to "introduce a kernel-specific flag only after the backend/dashboard owner confirms the split." Since nothing was applied, this still needs a human to reconcile the doc and confirm the flag is actually published under the real per-driver-family segments. Leaving this open for triage.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied the fix locally but the push failed (likely another commit landed on this branch since I started). This bundle covered 1 thread(s); all reverted. Re-trigger by replying to this thread.

[push retry after rebase failed]
: 
remote: - A pull request for this branch has been added to a merge queue. Branches that        
remote:   are queued for merging cannot be updated. To modify this branch, dequeue the        
remote:   associated pull request.        
To https://github.com/databricks/databricks-sql-kernel.git
 ! [remote rejected] jay/telemetry-feature-flag -> jay/telemetry-feature-flag (protected branch hook declined)
error: failed to push some refs to 'https://github.com/databricks/databricks-sql-kernel.git'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No code change landed — the engineer-bot's push was rejected by the merge queue both times, so the current head is unchanged. The snippet at lines 339–346 still shows all three items: the endpoint line reads /feature-flags/ADBC/{driver_version}, line 342 labels enableTelemetryForKernel as the "Existing server-side flag," and the guidance just below still says to introduce a kernel-specific flag only after backend confirmation. Nothing here is technical evidence that the finding was wrong, so this needs a human to reconcile the doc and confirm the flag is actually published under the real per-driver-family segments. Leaving it open for triage.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The thread is resolved with a docs-only edit reconciling all three inconsistencies the reviewer flagged, verified directly against src/feature_flags/mod.rs and src/session.rs.

Pushed fef6013.


If the kernel needs separate rollout from ADBC, introduce a kernel-specific flag
only after the backend/dashboard owner confirms the split. Do not fall back to
Expand Down
19 changes: 19 additions & 0 deletions include/databricks_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,25 @@ KernelStatusCode kernel_session_config_set_telemetry_config(KernelSessionConfig*
uint64_t retry_delay_ms,
uint64_t close_flush_timeout_ms);

/* Optional telemetry configuration for hosts that must distinguish an omitted
* enablement setting from an explicit false. Passing `telemetry_config == NULL`
* leaves the kernel telemetry configuration unchanged. Otherwise the tuning
* fields are applied and `has_enabled` controls whether `enabled` overrides the
* workspace feature flag. The original positional setter above remains ABI
* compatible and is equivalent to this function with `has_enabled = true`. */
typedef struct KernelTelemetryConfig {
bool has_enabled;
bool enabled;
size_t batch_size;
uint64_t flush_interval_ms;
uint32_t max_retries;
uint64_t retry_delay_ms;
uint64_t close_flush_timeout_ms;
} KernelTelemetryConfig;

KernelStatusCode kernel_session_config_set_telemetry_config_v2(
KernelSessionConfig* config, const KernelTelemetryConfig* telemetry_config);

/* Configure telemetry circuit-breaker behavior. `threshold` and `timeout_ms`
* must be > 0 when circuit breaking is enabled. If this setter is not called,
* the kernel keeps its default circuit-breaker policy. */
Expand Down
3 changes: 3 additions & 0 deletions napi/NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ layout, or npm publishing. Pure-kernel changes go in the root

### Changed

- An omitted `telemetryEnabled` now allows workspace feature-flag enablement;
an explicit `true` or `false` still takes precedence.

### Updated

### Fixed
Expand Down
50 changes: 42 additions & 8 deletions napi/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,13 @@ pub struct ConnectionOptions {
/// Overall retry budget in whole seconds. Maps onto
/// [`HttpConfig::overall_timeout`].
pub retry_overall_timeout_secs: Option<u32>,
/// Enable kernel telemetry export. Omitted / `false` keeps telemetry
/// disabled. When enabled, the kernel records operation telemetry below the
/// binding layer and exports through the Databricks SQL driver telemetry
/// endpoint.
/// Enable kernel telemetry export. Tri-state: an explicit `true` or `false`
/// takes precedence; when omitted, export defers to the
/// `enableTelemetryForKernel` workspace feature flag, falling back to
/// disabled when the flag is absent. Only an explicit `false` guarantees
/// telemetry stays disabled. When enabled, the kernel records operation
/// telemetry below the binding layer and exports through the Databricks SQL
/// driver telemetry endpoint.
pub telemetry_enabled: Option<bool>,
/// Number of telemetry events buffered before a flush. Omitted ⇒ kernel
/// default. Must be greater than zero when supplied.
Expand Down Expand Up @@ -655,8 +658,10 @@ fn build_http_config(options: &mut ConnectionOptions) -> HttpConfig {
///
/// Returns `None` when the caller did not mention telemetry at all, preserving
/// the kernel default. A caller may set telemetry knobs while leaving
/// `telemetry_enabled` false; the config is still passed through, but telemetry
/// remains disabled until explicitly enabled.
/// `telemetry_enabled` unset; the config is still passed through, and whether
/// export actually runs is then decided by the tri-state precedence
/// (explicit setting → `enableTelemetryForKernel` workspace feature flag →
/// disabled). Only an explicit `false` guarantees telemetry stays disabled.
fn build_telemetry_config(options: &ConnectionOptions) -> napi::Result<Option<TelemetryConfig>> {
let mentioned = options.telemetry_enabled.is_some()
|| options.telemetry_batch_size.is_some()
Expand Down Expand Up @@ -704,7 +709,9 @@ fn build_telemetry_config(options: &ConnectionOptions) -> napi::Result<Option<Te
}

let mut telemetry = TelemetryConfig::default();
telemetry.enabled = options.telemetry_enabled.unwrap_or(false);
if let Some(enabled) = options.telemetry_enabled {
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved
Comment thread
oss-reviewer-bot[bot] marked this conversation as resolved.
Resolved
telemetry.set_enabled(enabled);
}
if let Some(v) = options.telemetry_batch_size {
telemetry.batch_size = v as usize;
}
Expand Down Expand Up @@ -1594,7 +1601,7 @@ mod tests {
.expect("valid telemetry config")
.expect("telemetry mentioned");

assert!(telemetry.enabled);
assert_eq!(telemetry.enabled, Some(true));
assert_eq!(telemetry.batch_size, 25);
assert_eq!(
telemetry.flush_interval,
Expand All @@ -1619,6 +1626,33 @@ mod tests {
assert!(build_telemetry_config(&base()).unwrap().is_none());
}

#[test]
fn telemetry_enabled_omitted_leaves_feature_flag_in_control() {
// Omitting `telemetryEnabled` while touching another telemetry knob must
// leave `enabled` as `None`, so the workspace feature flag still
// decides. An explicit value, by contrast, pins `enabled`.
let mut omitted = base();
omitted.telemetry_batch_size = Some(25);
let telemetry = build_telemetry_config(&omitted)
.expect("valid telemetry config")
.expect("telemetry mentioned");
assert_eq!(telemetry.enabled, None);

let mut explicit_true = base();
explicit_true.telemetry_enabled = Some(true);
let telemetry = build_telemetry_config(&explicit_true)
.expect("valid telemetry config")
.expect("telemetry mentioned");
assert_eq!(telemetry.enabled, Some(true));

let mut explicit_false = base();
explicit_false.telemetry_enabled = Some(false);
let telemetry = build_telemetry_config(&explicit_false)
.expect("valid telemetry config")
.expect("telemetry mentioned");
assert_eq!(telemetry.enabled, Some(false));
}

#[test]
fn telemetry_options_reject_zero_required_fields() {
let mut o = base();
Expand Down
93 changes: 93 additions & 0 deletions pyo3/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyo3/NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ changes go in the root `NEXT_CHANGELOG.md`.

### Changed

- An omitted `telemetry_enabled` now allows workspace feature-flag enablement;
an explicit `True` or `False` still takes precedence.

### Updated

### Fixed
Expand Down
16 changes: 9 additions & 7 deletions pyo3/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub(crate) struct SessionInner {

#[derive(Default)]
struct TelemetryKwargs {
enabled: bool,
enabled: Option<bool>,
batch_size: Option<usize>,
flush_interval_ms: Option<u64>,
max_retries: Option<u32>,
Expand All @@ -67,7 +67,7 @@ struct TelemetryKwargs {

impl TelemetryKwargs {
fn is_mentioned(&self) -> bool {
self.enabled
self.enabled.is_some()
|| self.batch_size.is_some()
|| self.flush_interval_ms.is_some()
|| self.max_retries.is_some()
Expand Down Expand Up @@ -113,7 +113,9 @@ fn build_telemetry_config(
}

let mut telemetry = databricks_sql_kernel::TelemetryConfig::default();
telemetry.enabled = options.enabled;
if let Some(enabled) = options.enabled {
telemetry.set_enabled(enabled);
}
if let Some(v) = options.batch_size {
telemetry.batch_size = v;
}
Expand Down Expand Up @@ -383,7 +385,7 @@ impl Session {
process_name=None,
complex_types_as_json=false,
intervals_as_string=false,
telemetry_enabled=false,
telemetry_enabled=None,
telemetry_batch_size=None,
telemetry_flush_interval_ms=None,
telemetry_max_retries=None,
Expand Down Expand Up @@ -449,7 +451,7 @@ impl Session {
process_name: Option<String>,
complex_types_as_json: bool,
intervals_as_string: bool,
telemetry_enabled: bool,
telemetry_enabled: Option<bool>,
telemetry_batch_size: Option<usize>,
telemetry_flush_interval_ms: Option<u64>,
telemetry_max_retries: Option<u32>,
Expand Down Expand Up @@ -747,7 +749,7 @@ mod send_sync_tests {
#[test]
fn telemetry_kwargs_map_to_kernel_config() {
let telemetry = build_telemetry_config(TelemetryKwargs {
enabled: true,
enabled: Some(true),
batch_size: Some(25),
flush_interval_ms: Some(1_000),
max_retries: Some(2),
Expand All @@ -759,7 +761,7 @@ mod send_sync_tests {
})
.expect("valid telemetry config");

assert!(telemetry.enabled);
assert_eq!(telemetry.enabled, Some(true));
assert_eq!(telemetry.batch_size, 25);
assert_eq!(
telemetry.flush_interval,
Expand Down
Loading
Loading