[PECOBLR-1381][PECOBLR-1382] Implement telemetry Phase 6-7: Collection, Aggregation & Driver Integration#320
Open
samikshya-db wants to merge 5 commits intostack/PECOBLR-1143-telemetry-phase4-5from
Conversation
…gation This commit implements Phase 6 (metric collection and aggregation) for the telemetry system. Phase 6: Metric Collection & Aggregation - Implement error classification (errors.go) - isTerminalError() for identifying non-retryable errors - classifyError() for categorizing errors for telemetry - HTTP error handling utilities - Implement telemetry interceptor (interceptor.go) - beforeExecute() / afterExecute() hooks for statement execution - Context-based metric tracking with metricContext - Latency measurement and tag collection - Connection event recording - Error swallowing with panic recovery - Implement metrics aggregator (aggregator.go) - Statement-level metric aggregation - Batch size and flush interval logic - Background flush goroutine with ticker - Thread-safe metric recording with mutex protection - Immediate flush for connection and terminal errors - Aggregated counts (chunks, bytes, polls) - Update telemetryClient (client.go) - Wire up aggregator with exporter - Automatic aggregator start in constructor - Graceful shutdown with 5s timeout - getInterceptor() for per-connection interceptors Architecture: - Each connection gets its own interceptor instance - All interceptors share the same aggregator (per host) - Aggregator batches metrics and flushes periodically - Exporter sends batched metrics to Databricks - Circuit breaker protects against endpoint failures Testing: - All 70+ existing tests continue to pass - Compilation verified, no breaking changes Note: Phase 7 (driver integration) will be completed separately to allow careful review and testing of hooks in connection.go and statement.go. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
This commit implements Phase 7 (driver integration) for the telemetry system, completing the full telemetry pipeline from driver operations to export. Phase 7: Driver Integration - Add telemetry configuration to UserConfig - EnableTelemetry: User opt-in flag (respects server feature flags) - ForceEnableTelemetry: Force enable flag (bypasses server checks) - DSN parameter parsing in ParseDSN() - DeepCopy support for telemetry fields - Add telemetry support to connection - Add telemetry field to conn struct (*telemetry.Interceptor) - Initialize telemetry in connector.Connect() - Release telemetry resources in conn.Close() - Graceful shutdown with pending metric flush - Export telemetry types for driver use - Export Interceptor type (was interceptor) - Export GetInterceptor() method (was getInterceptor) - Export Close() method (was close) - Create driver integration helper (driver_integration.go) - InitializeForConnection(): One-stop initialization - ReleaseForConnection(): Resource cleanup - Encapsulates feature flag checks and client management - Reference counting for per-host resources Integration Flow: 1. User sets enableTelemetry=true or forceEnableTelemetry=true in DSN 2. connector.Connect() calls telemetry.InitializeForConnection() 3. Telemetry checks feature flags and returns Interceptor if enabled 4. Connection uses Interceptor for metric collection (Phase 8) 5. conn.Close() releases telemetry resources Architecture: - Per-connection: Interceptor instance - Per-host (shared): telemetryClient, aggregator, exporter - Global (singleton): clientManager, featureFlagCache, circuitBreakerManager Opt-In Priority (5 levels): 1. forceEnableTelemetry=true - Always enabled (testing/internal) 2. enableTelemetry=false - Always disabled (explicit opt-out) 3. enableTelemetry=true + server flag - User opt-in with server control 4. Server flag only - Default Databricks-controlled behavior 5. Default - Disabled (fail-safe) Testing: - All 70+ telemetry tests passing - No breaking changes to existing driver tests - Compilation verified across all packages - Graceful handling when telemetry disabled Note: Statement hooks (beforeExecute/afterExecute) will be added in follow-up for actual metric collection during query execution. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
d3070b1 to
7771cfd
Compare
This was referenced Jan 30, 2026
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 stacked PR builds on #319 and implements Phases 6-7 of the telemetry system, completing the full pipeline.
Stack: Part 2 of 2
Phase 6: Metric Collection & Aggregation ✅
New Files
errors.go(108 lines)isTerminalError()- Non-retryable error detectionclassifyError()- Error categorizationinterceptor.go(146 lines)BeforeExecute()/AfterExecute()hooksaggregator.go(242 lines)client.go(updated)Phase 7: Driver Integration ✅
Configuration Support
internal/config/config.go(+18 lines)EnableTelemetryfieldForceEnableTelemetryfieldDeepCopy()supportConnection Integration
connection.go,connector.go(+20 lines)connstructConnect()Close()Helper Module
driver_integration.go(59 lines)InitializeForConnection()- SetupReleaseForConnection()- CleanupIntegration Flow
Changes
Total: +1,073 insertions, -48 deletions (13 files)
Phase 6:
telemetry/errors.go(108 lines) - NEWtelemetry/interceptor.go(146 lines) - NEWtelemetry/aggregator.go(242 lines) - NEWtelemetry/client.go(+27/-9) - MODIFIEDPhase 7:
telemetry/driver_integration.go(59 lines) - NEWinternal/config/config.go(+18) - MODIFIEDconnection.go(+10) - MODIFIEDconnector.go(+10) - MODIFIEDtelemetry/DESIGN.md- MODIFIEDTesting
All tests passing ✅
Usage Example
Related Issues
Checklist