@@ -662,6 +662,7 @@ export function buildKernelTelemetryOptions(
662662 | 'telemetryCircuitBreakerThreshold'
663663 | 'telemetryCircuitBreakerTimeout'
664664 > ,
665+ options : Pick < ConnectionOptions , 'telemetryEnabled' > = { } ,
665666) {
666667 const telemetry : KernelTelemetryOptions = {
667668 driverName : DRIVER_NAME ,
@@ -676,16 +677,13 @@ export function buildKernelTelemetryOptions(
676677 localeName : getLocaleName ( ) ,
677678 charSetEncoding : 'UTF-8' ,
678679 processName : getProcessName ( ) ,
679- // The JS/Thrift telemetry path always runs with a per-host circuit breaker
680- // (`CircuitBreakerRegistry` creates one unconditionally). Enable the kernel's
681- // breaker too so the `telemetryCircuitBreakerThreshold` / `...TimeoutMs` knobs
682- // forwarded below actually take effect — the napi `.d.ts` documents those two
683- // as applying only when the breaker is enabled, so if the kernel defaults it
684- // off they would silently do nothing.
685- telemetryCircuitBreakerEnabled : true ,
686- telemetryEnabled : ( config . telemetryEnabled ?? true ) && ! isTelemetryDisabledByEnv ( ) ,
687680 } ;
688681
682+ const envDisabled = isTelemetryDisabledByEnv ( ) ;
683+ if ( options . telemetryEnabled !== undefined || envDisabled ) {
684+ telemetry . telemetryEnabled = ( options . telemetryEnabled ?? true ) && ! envDisabled ;
685+ }
686+
689687 // `batchSize`, `flushIntervalMs`, and `closeFlushTimeoutMs` share the same napi
690688 // contract constraint as the breaker fields below (`Must be greater than zero when
691689 // supplied`), so a caller-supplied `0`/negative would forward verbatim and surface
@@ -711,11 +709,10 @@ export function buildKernelTelemetryOptions(
711709 if ( Number . isFinite ( config . telemetryCloseTimeoutMs ) && config . telemetryCloseTimeoutMs ! > 0 ) {
712710 telemetry . telemetryCloseFlushTimeoutMs = config . telemetryCloseTimeoutMs ;
713711 }
714- // The breaker is forced on above, and the napi contract requires threshold/timeout
715- // to be strictly positive when it is enabled. A caller-supplied `0` (or negative)
716- // would otherwise be forwarded verbatim and surface as a hard kernel `openSession`
717- // rejection, so treat any non-positive value as a misconfiguration and fall back to
718- // the kernel defaults (5 / 60000) instead.
712+ // The napi contract requires threshold/timeout to be strictly positive when
713+ // supplied. A caller-supplied `0` (or negative) would otherwise be forwarded
714+ // verbatim and surface as a hard kernel `openSession` rejection, so treat any
715+ // non-positive value as a misconfiguration and delegate to the kernel default.
719716 if ( Number . isFinite ( config . telemetryCircuitBreakerThreshold ) && config . telemetryCircuitBreakerThreshold ! > 0 ) {
720717 telemetry . telemetryCircuitBreakerThreshold = config . telemetryCircuitBreakerThreshold ;
721718 }
0 commit comments