Commit 49c1f1c
feat(profiling): Integrate OtlpProfileUploader with explicit reference counting
Integrate OtlpProfileUploader into ProfilingAgent to enable parallel JFR and
OTLP profile uploads when configured. Implements explicit reference counting
pattern for RecordingData to safely support multiple concurrent handlers.
Key changes:
1. ProfilingAgent integration:
- Add OtlpProfileUploader alongside ProfileUploader
- Extract handler methods (handleRecordingData, handleRecordingDataWithDump)
- Use method references instead of capturing lambdas for better performance
- Call retain() once for each handler (dumper, OTLP, JFR)
- Update shutdown hooks to properly cleanup OTLP uploader
2. Explicit reference counting in RecordingData:
- Change initial refcount from 1 to 0 for clarity
- Each handler must call retain() before processing
- Each handler calls release() when done
- doRelease() called only when refcount reaches 0
- Updated javadocs to reflect explicit counting pattern
3. Comprehensive test coverage:
- RecordingDataRefCountingTest validates all handler combinations
- Tests single, dual, and triple handler scenarios
- Verifies thread-safety with concurrent handlers
- Tests error conditions (premature release, retain after release)
- Confirms idempotent release behavior
Benefits:
- Symmetric treatment of all handlers (no special first handler)
- Clear, explicit reference counting (easier to understand and verify)
- No resource leaks or premature cleanup
- Efficient method references (no lambda capture overhead)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 1d3aee9 commit 49c1f1c
File tree
3 files changed
+307
-18
lines changed- dd-java-agent/agent-profiling
- profiling-controller/src/test/java/com/datadog/profiling/controller
- src/main/java/com/datadog/profiling/agent
- internal-api/src/main/java/datadog/trace/api/profiling
3 files changed
+307
-18
lines changedLines changed: 222 additions & 0 deletions
| 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 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
Lines changed: 75 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
48 | 51 | | |
49 | 52 | | |
50 | 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 | + | |
51 | 101 | | |
52 | 102 | | |
53 | 103 | | |
| |||
133 | 183 | | |
134 | 184 | | |
135 | 185 | | |
136 | | - | |
| 186 | + | |
137 | 187 | | |
138 | 188 | | |
139 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
140 | 194 | | |
141 | 195 | | |
142 | 196 | | |
| |||
150 | 204 | | |
151 | 205 | | |
152 | 206 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 207 | + | |
| 208 | + | |
158 | 209 | | |
159 | 210 | | |
160 | 211 | | |
| |||
169 | 220 | | |
170 | 221 | | |
171 | 222 | | |
172 | | - | |
| 223 | + | |
173 | 224 | | |
174 | 225 | | |
175 | 226 | | |
| |||
188 | 239 | | |
189 | 240 | | |
190 | 241 | | |
191 | | - | |
| 242 | + | |
192 | 243 | | |
193 | 244 | | |
194 | 245 | | |
195 | | - | |
| 246 | + | |
196 | 247 | | |
197 | 248 | | |
198 | 249 | | |
199 | 250 | | |
200 | 251 | | |
201 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
202 | 256 | | |
203 | 257 | | |
204 | 258 | | |
| |||
207 | 261 | | |
208 | 262 | | |
209 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
210 | 268 | | |
211 | 269 | | |
212 | 270 | | |
213 | 271 | | |
214 | 272 | | |
215 | 273 | | |
216 | 274 | | |
| 275 | + | |
217 | 276 | | |
218 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
219 | 281 | | |
220 | 282 | | |
221 | 283 | | |
| 284 | + | |
222 | 285 | | |
223 | 286 | | |
224 | 287 | | |
225 | 288 | | |
226 | | - | |
| 289 | + | |
227 | 290 | | |
228 | 291 | | |
229 | 292 | | |
0 commit comments