Commit 6dd935f
[PECOBLR-1383] Add statement execution hooks for telemetry collection (#321)
## Summary
This **stacked PR** builds on #320 and adds statement execution hooks to
complete end-to-end telemetry collection.
**Stack:** Part 3 of 3
- Base: #319 (PECOBLR-1143 - Phases 4-5)
- Previous: #320 (PECOBLR-1381-1382 - Phases 6-7)
- This PR: PECOBLR-1383 (Statement execution hooks)
---
## Changes
### Exported Methods for Driver Integration
**`telemetry/interceptor.go`**
- ✅ Exported `BeforeExecute()` - starts metric tracking for a statement
- ✅ Exported `AfterExecute()` - records metric with timing and error
info
- ✅ Exported `AddTag()` - adds tags to current metric context
- ✅ Exported `CompleteStatement()` - marks statement complete and
flushes
### Statement Execution Hooks
**`connection.go`**
- ✅ Added hooks to `QueryContext()`:
- Calls `BeforeExecute()` with statement ID from operation handle GUID
- Uses defer to call `AfterExecute()` and `CompleteStatement()`
- ✅ Added hooks to `ExecContext()`:
- Calls `BeforeExecute()` with statement ID
- Proper error handling (includes stagingErr)
- Uses defer to call `AfterExecute()` and `CompleteStatement()`
### Documentation
**`telemetry/DESIGN.md`**
- ✅ Updated Phase 6 to mark as completed
- ✅ Added statement execution hooks to Phase 7 checklist
---
## Integration Flow
```
Connection.QueryContext()
↓
BeforeExecute(statementID) → creates metricContext with startTime
↓
[Statement Execution]
↓
AfterExecute(err) → records metric with latency and error
↓
CompleteStatement(statementID, failed) → flushes aggregated metrics
```
---
## Testing
**All tests passing** ✅
- ✅ 99 telemetry tests (2.018s)
- ✅ All driver tests (58.576s)
- ✅ No breaking changes
- ✅ Telemetry properly disabled when not configured
---
## End-to-End Telemetry
With this PR, the telemetry system is **fully functional end-to-end**:
1. ✅ **Collection** - Metrics collected from QueryContext/ExecContext
2. ✅ **Aggregation** - Statement-level aggregation with batching
3. ✅ **Circuit Breaker** - Protection against failing endpoints
4. ✅ **Export** - HTTP POST with retry and exponential backoff
5. ✅ **Feature Flags** - Server-side control with 5-level priority
6. ✅ **Resource Management** - Per-host clients with reference counting
---
## Related Issues
- Builds on: #320 (PECOBLR-1381-1382)
- Implements: PECOBLR-1383 (Statement execution hooks) ✅
---
## Checklist
- [x] Export interceptor methods for driver use
- [x] Add hooks to QueryContext
- [x] Add hooks to ExecContext
- [x] Update DESIGN.md checklist
- [x] All tests passing
- [x] No breaking changes
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent f850b47 commit 6dd935f
File tree
5 files changed
+111
-75
lines changed- telemetry
5 files changed
+111
-75
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
130 | 153 | | |
131 | 154 | | |
132 | 155 | | |
| |||
137 | 160 | | |
138 | 161 | | |
139 | 162 | | |
| 163 | + | |
140 | 164 | | |
141 | 165 | | |
142 | 166 | | |
| |||
168 | 192 | | |
169 | 193 | | |
170 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
171 | 198 | | |
172 | 199 | | |
173 | 200 | | |
174 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
175 | 214 | | |
176 | 215 | | |
177 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2116 | 2116 | | |
2117 | 2117 | | |
2118 | 2118 | | |
2119 | | - | |
2120 | | - | |
2121 | | - | |
2122 | | - | |
2123 | | - | |
2124 | | - | |
2125 | | - | |
2126 | | - | |
2127 | | - | |
2128 | | - | |
2129 | | - | |
2130 | | - | |
2131 | | - | |
2132 | | - | |
2133 | | - | |
2134 | | - | |
2135 | | - | |
2136 | | - | |
2137 | | - | |
2138 | | - | |
2139 | | - | |
2140 | | - | |
2141 | | - | |
2142 | | - | |
2143 | | - | |
2144 | | - | |
2145 | | - | |
2146 | | - | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
2147 | 2147 | | |
2148 | 2148 | | |
2149 | 2149 | | |
| |||
2167 | 2167 | | |
2168 | 2168 | | |
2169 | 2169 | | |
2170 | | - | |
2171 | | - | |
2172 | | - | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
2173 | 2176 | | |
2174 | 2177 | | |
2175 | 2178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | 31 | | |
34 | 32 | | |
35 | 33 | | |
| |||
63 | 61 | | |
64 | 62 | | |
65 | 63 | | |
66 | | - | |
67 | | - | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
| |||
136 | 132 | | |
137 | 133 | | |
138 | 134 | | |
139 | | - | |
140 | | - | |
141 | 135 | | |
142 | 136 | | |
143 | 137 | | |
| |||
248 | 242 | | |
249 | 243 | | |
250 | 244 | | |
251 | | - | |
252 | | - | |
253 | 245 | | |
254 | 246 | | |
255 | 247 | | |
256 | 248 | | |
257 | | - | |
258 | 249 | | |
259 | 250 | | |
260 | 251 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | | - | |
49 | | - | |
| 47 | + | |
50 | 48 | | |
51 | 49 | | |
52 | 50 | | |
| |||
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
92 | | - | |
93 | | - | |
| 90 | + | |
94 | 91 | | |
95 | 92 | | |
96 | 93 | | |
97 | 94 | | |
98 | 95 | | |
99 | | - | |
100 | 96 | | |
101 | 97 | | |
102 | 98 | | |
| |||
112 | 108 | | |
113 | 109 | | |
114 | 110 | | |
115 | | - | |
116 | | - | |
| 111 | + | |
117 | 112 | | |
118 | 113 | | |
119 | 114 | | |
120 | 115 | | |
121 | 116 | | |
122 | 117 | | |
123 | | - | |
124 | | - | |
| 118 | + | |
125 | 119 | | |
126 | 120 | | |
127 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | 18 | | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
27 | 25 | | |
28 | 26 | | |
29 | | - | |
30 | 27 | | |
31 | 28 | | |
32 | 29 | | |
| |||
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | | - | |
42 | | - | |
43 | 38 | | |
44 | 39 | | |
45 | 40 | | |
46 | 41 | | |
47 | 42 | | |
48 | | - | |
49 | | - | |
50 | 43 | | |
51 | 44 | | |
52 | 45 | | |
53 | 46 | | |
54 | 47 | | |
55 | 48 | | |
56 | 49 | | |
57 | | - | |
| 50 | + | |
58 | 51 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 52 | + | |
| 53 | + | |
62 | 54 | | |
63 | 55 | | |
64 | 56 | | |
65 | 57 | | |
66 | 58 | | |
| 59 | + | |
67 | 60 | | |
68 | 61 | | |
69 | 62 | | |
| |||
72 | 65 | | |
73 | 66 | | |
74 | 67 | | |
75 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
76 | 87 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 88 | + | |
| 89 | + | |
80 | 90 | | |
81 | 91 | | |
82 | 92 | | |
| |||
96 | 106 | | |
97 | 107 | | |
98 | 108 | | |
| 109 | + | |
99 | 110 | | |
100 | 111 | | |
101 | 112 | | |
| |||
109 | 120 | | |
110 | 121 | | |
111 | 122 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
116 | 126 | | |
117 | 127 | | |
118 | 128 | | |
| |||
146 | 156 | | |
147 | 157 | | |
148 | 158 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
153 | 162 | | |
154 | 163 | | |
155 | 164 | | |
| |||
0 commit comments