[2/7] Telemetry Infrastructure: CircuitBreaker and FeatureFlagCache#325
Open
samikshya-db wants to merge 10 commits intomainfrom
Open
[2/7] Telemetry Infrastructure: CircuitBreaker and FeatureFlagCache#325samikshya-db wants to merge 10 commits intomainfrom
samikshya-db wants to merge 10 commits intomainfrom
Conversation
This was referenced Jan 28, 2026
This is part 2 of 7 in the telemetry implementation stack. Components: - CircuitBreaker: Per-host endpoint protection with state management - FeatureFlagCache: Per-host feature flag caching with reference counting - CircuitBreakerRegistry: Manages circuit breakers per host Circuit Breaker: - States: CLOSED (normal), OPEN (failing), HALF_OPEN (testing recovery) - Default: 5 failures trigger OPEN, 60s timeout, 2 successes to CLOSE - Per-host isolation prevents cascade failures - All state transitions logged at debug level Feature Flag Cache: - Per-host caching with 15-minute TTL - Reference counting for connection lifecycle management - Automatic cache expiration and refetch - Context removed when refCount reaches zero Testing: - 32 comprehensive unit tests for CircuitBreaker - 29 comprehensive unit tests for FeatureFlagCache - 100% function coverage, >80% line/branch coverage - CircuitBreakerStub for testing other components Dependencies: - Builds on [1/7] Types and Exception Classifier
Implements getAuthHeaders() method for authenticated REST API requests: - Added getAuthHeaders() to IClientContext interface - Implemented in DBSQLClient using authProvider.authenticate() - Updated FeatureFlagCache to fetch from connector-service API with auth - Added driver version support for version-specific feature flags - Replaced placeholder implementation with actual REST API calls Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Change feature flag endpoint to use NODEJS client type - Fix telemetry endpoints to /telemetry-ext and /telemetry-unauth - Update payload to match proto with system_configuration - Add shared buildUrl utility for protocol handling
- Change payload structure to match JDBC: uploadTime, items, protoLogs - protoLogs contains JSON-stringified TelemetryFrontendLog objects - Remove workspace_id (JDBC doesn't populate it) - Remove debug logs added during testing
- Fix import order in FeatureFlagCache - Replace require() with import for driverVersion - Fix variable shadowing - Disable prefer-default-export for urlUtils
06b1f7a to
1cdb716
Compare
Fix TypeScript compilation error by implementing getAuthHeaders method required by IClientContext interface.
7ec20b2 to
689e561
Compare
Added osArch, runtimeVendor, localeName, charSetEncoding, and processName fields to DriverConfiguration to match JDBC implementation.
jadewang-db
reviewed
Feb 3, 2026
| @@ -0,0 +1,235 @@ | |||
| /** | |||
There was a problem hiding this comment.
try use some existing library for circuitbreaker
| const authHeaders = authenticatedExport ? await this.context.getAuthHeaders() : {}; | ||
|
|
||
| // Make HTTP POST request with authentication | ||
| const response: Response = await this.fetchFn(endpoint, { |
| this.emit(TelemetryEventType.CLOUDFETCH_CHUNK, event); | ||
| } catch (error: any) { | ||
| // Swallow all exceptions - log at debug level only | ||
| logger.log(LogLevel.debug, `Error emitting cloudfetch chunk: ${error.message}`); |
There was a problem hiding this comment.
should we make this log error or debug
sreekanth-db
reviewed
Feb 3, 2026
| interface DatabricksTelemetryPayload { | ||
| uploadTime: number; | ||
| items: string[]; // Always empty - required field | ||
| protoLogs: string[]; // JSON-stringified TelemetryFrontendLog objects |
Contributor
There was a problem hiding this comment.
TelemetryFrontendLog - do you mean DatabricksTelemetryLog ?
sreekanth-db
reviewed
Feb 3, 2026
| private getDriverVersion(): string { | ||
| try { | ||
| // In production, this would read from package.json | ||
| return '1.0.0'; |
Contributor
There was a problem hiding this comment.
is this logic updated in the next PRs ?
sreekanth-db
reviewed
Feb 3, 2026
| logger.log(LogLevel.debug, `Flushing ${metricsToExport.length} telemetry metrics`); | ||
|
|
||
| // Export metrics (exporter.export never throws) | ||
| this.exporter.export(metricsToExport); |
Contributor
There was a problem hiding this comment.
should we reset the flush timer here by calling startFlushTimer ?
Example scenario:
Flush timer duration: 30 sec
- flush timer starts at 0
- lets say pendingMetrics reaches its limit at 25th sec - export the data to backend
- timer reaches its limit at 30th sec - again tries to export the data within 5 seconds (we might hit rate limits on telemetry with large loads)
sreekanth-db
reviewed
Feb 3, 2026
Contributor
sreekanth-db
left a comment
There was a problem hiding this comment.
Added few comments, please take a look
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of 7-part Telemetry Implementation Stack
This layer adds infrastructure components for resilience and feature flag management.
Summary
Implements CircuitBreaker for per-host endpoint protection and FeatureFlagCache for efficient feature flag management with reference counting.
Components
CircuitBreaker (
lib/telemetry/CircuitBreaker.ts)State machine for endpoint protection:
Configuration:
CircuitBreakerRegistry
Manages circuit breakers per host for isolation:
FeatureFlagCache (
lib/telemetry/FeatureFlagCache.ts)Per-host feature flag caching with lifecycle management:
Testing
Next Steps
This PR is followed by:
Dependencies
Depends on: [1/7] Telemetry Foundation (#324)