Commit 73f2a36
[PECOBLR-1143] Implement telemetry Phase 4-5: Export infrastructure and opt-in configuration (#319)
## Summary
This PR implements Phases 4-5 of the telemetry system for the Databricks
SQL Go driver.
**Stack:** Part 1 of 2
- This PR: PECOBLR-1143 (Phases 4-5)
- Next: PECOBLR-1381-1382 (Phases 6-7)
---
## Phase 4: Export Infrastructure ✅
**New file: `exporter.go` (192 lines)**
- ✅ `telemetryExporter` with circuit breaker integration
- ✅ HTTP POST to `/api/2.0/telemetry-ext` endpoint
- ✅ Exponential backoff retry (100ms base, 3 retries max)
- ✅ Tag filtering via `shouldExportToDatabricks()`
- ✅ JSON serialization (`telemetryPayload`, `exportedMetric`)
- ✅ Comprehensive error swallowing
- ✅ Support for HTTP and HTTPS URLs
**New file: `exporter_test.go` (448 lines)**
- ✅ 17 comprehensive tests with mock HTTP server
- ✅ Success scenarios, retry logic, circuit breaker
- ✅ Tag filtering, error swallowing, exponential backoff
- ✅ Context cancellation, 4xx/5xx handling
---
## Phase 5: Opt-In Configuration Integration ✅
**Updated: `config.go` (+48 lines)**
- ✅ `isTelemetryEnabled()` with 5-level priority logic
- ✅ Integration with `featureFlagCache`
- ✅ Error handling with safe fallbacks
**Updated: `config_test.go` (+230 lines)**
- ✅ 8 tests for all 5 priority levels
- ✅ Server error scenarios, unreachable hosts
**Priority Logic:**
1. `forceEnableTelemetry=true` → always enabled
2. `enableTelemetry=false` → always disabled
3. `enableTelemetry=true` + server feature flag check
4. Server-side feature flag only (default)
5. Default disabled (fail-safe)
---
## Changes
**Total:** +976 insertions, -57 deletions
---
## Testing
**All 70+ tests passing** ✅ (2.017s)
- Circuit Breaker: 15 tests ✓
- Config & Opt-In: 19 tests ✓
- Exporter: 17 tests ✓
- Feature Flags: 12 tests ✓
- Manager: 9 tests ✓
- Tags: 7 tests ✓
---
## Related Issues
- Implements: PECOBLR-1143 (Phases 4-5)
- Enables: PECOBLR-1381 (Phase 6)
- Enables: PECOBLR-1382 (Phase 7)
---
## Checklist
- [x] Implements Phase 4 export infrastructure
- [x] Implements Phase 5 opt-in configuration
- [x] Comprehensive unit tests
- [x] All tests passing
- [x] DESIGN.md checklist updated
- [x] No breaking changes
---------
Signed-off-by: samikshya-chand_data <samikshya.chand@databricks.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent abbe173 commit 73f2a36
File tree
11 files changed
+1764
-195
lines changed- internal/config
- telemetry
11 files changed
+1764
-195
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| 341 | + | |
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
0 commit comments