Add comprehensive telemetry system for Node.js SQL driver#323
Closed
samikshya-db wants to merge 2 commits intomainfrom
Closed
Add comprehensive telemetry system for Node.js SQL driver#323samikshya-db wants to merge 2 commits intomainfrom
samikshya-db wants to merge 2 commits intomainfrom
Conversation
Implements a complete telemetry system following the JDBC driver pattern: Core Components: - TelemetryEventEmitter: Event-based telemetry emission using Node.js EventEmitter - MetricsAggregator: Per-statement aggregation with batch processing and periodic flushing - DatabricksTelemetryExporter: HTTP export to Databricks telemetry endpoints with retry logic - FeatureFlagCache: Per-host feature flag caching with reference counting - CircuitBreaker: Per-host endpoint protection with OPEN/HALF_OPEN/CLOSED states - ExceptionClassifier: Terminal vs retryable exception classification - TelemetryClient/Provider: Per-host HTTP client management with reference counting Integration: - Integrated into DBSQLClient with per-connection lifecycle management - Event emissions at key driver operations: connection.open, statement.start/complete, cloudfetch.chunk, error - Feature flag driven with runtime override support via ConnectionOptions - All telemetry errors swallowed and logged at debug level only - Zero impact on driver operations when telemetry fails or is disabled Testing: - 226 comprehensive unit and integration tests - 97.76% line coverage, 90.59% branch coverage, 100% function coverage - Tests verify exception swallowing, debug-only logging, reference counting, circuit breaker behavior Configuration: - telemetryEnabled: boolean (default: false, feature flag driven) - telemetryBatchSize: number (default: 100) - telemetryFlushIntervalMs: number (default: 5000) - telemetryRetryMaxAttempts: number (default: 3) See docs/TELEMETRY.md for complete documentation.
- Fix no-plusplus errors: replace ++ and -- with += 1 and -= 1 - Fix global-require errors: move require() calls to imports - Fix no-unused-vars errors: remove or mark unused variables - Fix no-await-in-loop: add eslint-disable for intentional retry logic - Fix no-lonely-if: refactor nested if statements - Fix default-case: add default case to switch statements - Fix no-promise-executor-return: wrap setTimeout in arrow function All linting errors resolved. Only 14 warnings remain for unnamed test functions.
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.
Summary
This PR implements a complete telemetry system for the Node.js SQL driver, following the JDBC driver pattern.
Core Components
Event-Based Architecture
Resource Management
Error Handling
Integration
connection.open- On successful connectionstatement.start- On statement executionstatement.complete- On statement finishcloudfetch.chunk- On chunk downloaderror- On exceptions with terminal classificationTesting
Tests verify:
Configuration
Documentation
See
docs/TELEMETRY.mdfor complete documentation including:Files Changed
lib/telemetry/*.ts(9 files)lib/DBSQLClient.ts,lib/DBSQLOperation.ts,lib/DBSQLSession.ts,lib/result/CloudFetchResultHandler.tstests/unit/telemetry/*.ts(8 files)tests/e2e/telemetry/*.ts(1 file)tests/unit/.stubs/*.ts(2 files)docs/TELEMETRY.md,spec/telemetry-*.mdTest Plan
All tests passing with excellent coverage.