Commit 6fb037c
[PECOBLR-1381][PECOBLR-1382] Implement telemetry Phase 6-7: Collection, Aggregation & Driver Integration (#320)
## 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
- Base: #319 (PECOBLR-1143 - Phases 4-5)
- This PR: PECOBLR-1381 + PECOBLR-1382 (Phases 6-7)
---
## Phase 6: Metric Collection & Aggregation ✅
### New Files
**`errors.go` (108 lines)**
- ✅ `isTerminalError()` - Non-retryable error detection
- ✅ `classifyError()` - Error categorization
- ✅ HTTP error handling utilities
**`interceptor.go` (146 lines)**
- ✅ `BeforeExecute()` / `AfterExecute()` hooks
- ✅ Context-based metric tracking
- ✅ Latency measurement
- ✅ Tag collection
- ✅ Error swallowing
**`aggregator.go` (242 lines)**
- ✅ Statement-level aggregation
- ✅ Batch processing (size: 100)
- ✅ Background flush (interval: 5s)
- ✅ Thread-safe operations
- ✅ Immediate flush for terminal errors
**`client.go` (updated)**
- ✅ Full pipeline integration
- ✅ Graceful shutdown
---
## Phase 7: Driver Integration ✅
### Configuration Support
**`internal/config/config.go` (+18 lines)**
- ✅ `EnableTelemetry` field
- ✅ `ForceEnableTelemetry` field
- ✅ DSN parameter parsing
- ✅ `DeepCopy()` support
### Connection Integration
**`connection.go`, `connector.go` (+20 lines)**
- ✅ Telemetry field in `conn` struct
- ✅ Initialization in `Connect()`
- ✅ Cleanup in `Close()`
### Helper Module
**`driver_integration.go` (59 lines)**
- ✅ `InitializeForConnection()` - Setup
- ✅ `ReleaseForConnection()` - Cleanup
- ✅ Feature flag checking
- ✅ Resource management
---
## Integration Flow
```
DSN: "host:port/path?enableTelemetry=true"
↓
connector.Connect()
↓
telemetry.InitializeForConnection()
├─→ Feature flag check (5-level priority)
├─→ Get/Create telemetryClient (per host)
└─→ Create Interceptor (per connection)
↓
conn.telemetry = Interceptor
↓
conn.Close()
├─→ Flush pending metrics
└─→ Release resources
```
---
## Changes
**Total:** +1,073 insertions, -48 deletions (13 files)
### Phase 6:
- `telemetry/errors.go` (108 lines) - NEW
- `telemetry/interceptor.go` (146 lines) - NEW
- `telemetry/aggregator.go` (242 lines) - NEW
- `telemetry/client.go` (+27/-9) - MODIFIED
### Phase 7:
- `telemetry/driver_integration.go` (59 lines) - NEW
- `internal/config/config.go` (+18) - MODIFIED
- `connection.go` (+10) - MODIFIED
- `connector.go` (+10) - MODIFIED
- `telemetry/DESIGN.md` - MODIFIED
---
## Testing
**All tests passing** ✅
- ✅ 70+ telemetry tests (2.018s)
- ✅ No breaking changes
- ✅ Compilation verified
- ✅ Thread-safety verified
---
## Usage Example
```go
// Enable telemetry via DSN
dsn := "host:443/sql/1.0?enableTelemetry=true"
db, _ := sql.Open("databricks", dsn)
// Or force enable
dsn := "host:443/sql/1.0?forceEnableTelemetry=true"
```
---
## Related Issues
- Builds on: #319 (PECOBLR-1143)
- Implements: PECOBLR-1381 (Phase 6) ✅
- Implements: PECOBLR-1382 (Phase 7) ✅
---
## Checklist
- [x] Phase 6: Collection & aggregation
- [x] Phase 7: Driver integration
- [x] Configuration support
- [x] Resource management
- [x] All tests passing
- [x] No breaking changes
- [x] DESIGN.md updated
---------
Signed-off-by: samikshya-chand_data <samikshya.chand@databricks.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 0b7d209 commit 6fb037c
File tree
10 files changed
+765
-78
lines changed- internal/config
- telemetry
10 files changed
+765
-78
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
| |||
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| 151 | + | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
| |||
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
285 | 298 | | |
286 | 299 | | |
287 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1440 | 1440 | | |
1441 | 1441 | | |
1442 | 1442 | | |
1443 | | - | |
1444 | | - | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | | - | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
1449 | 1446 | | |
1450 | 1447 | | |
1451 | 1448 | | |
| |||
1474 | 1471 | | |
1475 | 1472 | | |
1476 | 1473 | | |
1477 | | - | |
1478 | | - | |
1479 | | - | |
| 1474 | + | |
| 1475 | + | |
1480 | 1476 | | |
1481 | 1477 | | |
1482 | 1478 | | |
| |||
1495 | 1491 | | |
1496 | 1492 | | |
1497 | 1493 | | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
| 1494 | + | |
1506 | 1495 | | |
1507 | 1496 | | |
1508 | 1497 | | |
| |||
2108 | 2097 | | |
2109 | 2098 | | |
2110 | 2099 | | |
2111 | | - | |
2112 | | - | |
2113 | | - | |
2114 | | - | |
2115 | | - | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
2116 | 2104 | | |
2117 | 2105 | | |
2118 | 2106 | | |
2119 | 2107 | | |
2120 | 2108 | | |
2121 | | - | |
2122 | 2109 | | |
2123 | 2110 | | |
2124 | 2111 | | |
| |||
2158 | 2145 | | |
2159 | 2146 | | |
2160 | 2147 | | |
2161 | | - | |
2162 | | - | |
2163 | | - | |
2164 | | - | |
2165 | | - | |
2166 | | - | |
2167 | | - | |
2168 | | - | |
2169 | | - | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
2173 | | - | |
2174 | | - | |
2175 | | - | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
2179 | | - | |
2180 | | - | |
2181 | | - | |
2182 | | - | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
2183 | 2173 | | |
2184 | 2174 | | |
2185 | 2175 | | |
| |||
0 commit comments