Commit 87ecea4
authored
[SVLS-7168] Create inferred Span and Span links for GCP PubSub (#6415)
* feat: add producer-side batch message handling with span linking
- Collect span links from messages 2-N (first becomes parent)
- Extract parent context from first message trace context
- Create pubsub.request span with span links metadata
- Inject batch metadata into all messages (_dd.pubsub_request.*, _dd.batch.*)
- Add 128-bit trace ID support (_dd.p.tid)
- Add operation tag for batched vs single requests
* feat: add ack context map and producer improvements for batching
- Add ack context map to preserve trace context across batched acknowledges
- Update producer to use batchSpan._startTime for accurate publish time
- Add explicit parent span support in client plugin
- Wrap Message.ack() to store context before batched gRPC acknowledge
- Update Subscription.emit to properly handle storage context
- Sync auto-load improvements from Branch 1
* fix: resolve linting errors in google-cloud-pubsub.js
* fix: remove trailing whitespace in client.js
* fix comments
* feat: add span linking from delivery span to pubsub.request
- Add _reconstructPubSubContext to extract pubsub.request span ID from headers
- Add span link to original trace context if different from pubsub.request
- Supports same-trace parenting for better trace continuity
* feat: check for pubsub.delivery span in AsyncLocalStorage before extracting from headers
- HTTP plugin now checks if a delivery span is active in storage
- If found, uses delivery span as parent for http.request
- Ensures proper span hierarchy for push subscriptions
* feat: add span linking and batch metadata to pull-based consumer
- Extract pubsub.request span ID from message attributes
- Add span link correlation tags
- Calculate delivery duration from publish start time
- Add batch size and index tags for batched messages
* feat: add comprehensive span linking for consumer and push subscriptions
- Add _reconstructPubSubRequestContext in consumer for proper span reparenting
- Reparent first message in batch to pubsub.request span
- Add comprehensive batch metadata and correlation tags
- Improve resource naming and service separation
- Add delivery duration calculation
- Update push subscription logging to warn level with better messages
- Add missing headers warning for troubleshooting
* Remove comments
* run npm lint
* fix test
* fix test
* fix test
* fix index.js test
* fix index.js test
* fix context error
* fix lint
* fix lint
* fix lint
* fix index.js test
* fix plugin
* add ctx
* test the index
* update consumer subscription bindstart
* update addhook subscription
* add debug logs
* Fix consumer span context loss with WeakMap and add comprehensive debug logging
* Fix double finish
* Fix consumer span type: explicitly set _type='worker' after startSpan
* Fix: use span.setTag('span.type', 'worker') instead of span._type
* Debug: Add type in startSpan options and via setTag, improve logging
* Fix: Use runStores for _dispense and publish for remove with improved logging
* add debug logs
* Fix: Guarantee test harness loads instrumentation before requiring @google-cloud/pubsub
* update subscription
* update subscription
* test fix for index.spec.js timeout
* fix test logic
* fix linter
* fix linter
* remove comments
* feat: add producer-side batch message handling with span linking
- Collect span links from messages 2-N (first becomes parent)
- Extract parent context from first message trace context
- Create pubsub.request span with span links metadata
- Inject batch metadata into all messages (_dd.pubsub_request.*, _dd.batch.*)
- Add 128-bit trace ID support (_dd.p.tid)
- Add operation tag for batched vs single requests
* feat: add ack context map and producer improvements for batching
- Add ack context map to preserve trace context across batched acknowledges
- Update producer to use batchSpan._startTime for accurate publish time
- Add explicit parent span support in client plugin
- Wrap Message.ack() to store context before batched gRPC acknowledge
- Update Subscription.emit to properly handle storage context
- Sync auto-load improvements from Branch 1
* fix: resolve linting errors in google-cloud-pubsub.js
* fix: remove trailing whitespace in client.js
* fix comments
* update from review
* addional cleanup
* [SVLS-7168] Create tests for GCP PubSub Push Subscriptions Plugin (#6414)
* feat: add producer-side batch message handling with span linking
- Collect span links from messages 2-N (first becomes parent)
- Extract parent context from first message trace context
- Create pubsub.request span with span links metadata
- Inject batch metadata into all messages (_dd.pubsub_request.*, _dd.batch.*)
- Add 128-bit trace ID support (_dd.p.tid)
- Add operation tag for batched vs single requests
* feat: add span linking from delivery span to pubsub.request
- Add _reconstructPubSubContext to extract pubsub.request span ID from headers
- Add span link to original trace context if different from pubsub.request
- Supports same-trace parenting for better trace continuity
* feat: check for pubsub.delivery span in AsyncLocalStorage before extracting from headers
- HTTP plugin now checks if a delivery span is active in storage
- If found, uses delivery span as parent for http.request
- Ensures proper span hierarchy for push subscriptions
* feat: add span linking and batch metadata to pull-based consumer
- Extract pubsub.request span ID from message attributes
- Add span link correlation tags
- Calculate delivery duration from publish start time
- Add batch size and index tags for batched messages
* remove comments
* new test file
* Fix push subscription test module resolution for CI
* Implement full HTTP+Pub/Sub integration tests
* run linter
* test other frameworks
* Fix push subscription tests1 parent 75dd311 commit 87ecea4
7 files changed
Lines changed: 716 additions & 116 deletions
File tree
- packages
- datadog-instrumentations/src
- datadog-plugin-google-cloud-pubsub
- src
- test
- dd-trace/src/plugins/util
Lines changed: 65 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
| |||
88 | 106 | | |
89 | 107 | | |
90 | 108 | | |
91 | | - | |
92 | | - | |
93 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
94 | 112 | | |
95 | 113 | | |
96 | 114 | | |
97 | 115 | | |
98 | 116 | | |
99 | 117 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 118 | + | |
103 | 119 | | |
104 | 120 | | |
105 | 121 | | |
| |||
214 | 230 | | |
215 | 231 | | |
216 | 232 | | |
217 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
218 | 246 | | |
219 | 247 | | |
220 | 248 | | |
| |||
227 | 255 | | |
228 | 256 | | |
229 | 257 | | |
230 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
231 | 263 | | |
232 | 264 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
238 | 269 | | |
239 | 270 | | |
240 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
241 | 275 | | |
242 | 276 | | |
243 | 277 | | |
244 | 278 | | |
245 | | - | |
246 | | - | |
247 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
248 | 288 | | |
249 | 289 | | |
250 | 290 | | |
| |||
275 | 315 | | |
276 | 316 | | |
277 | 317 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
284 | 326 | | |
285 | | - | |
286 | 327 | | |
287 | 328 | | |
288 | 329 | | |
289 | | - | |
290 | | - | |
| 330 | + | |
291 | 331 | | |
292 | 332 | | |
293 | 333 | | |
| |||
Lines changed: 142 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 | | |
8 | 10 | | |
9 | 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 | + | |
10 | 37 | | |
11 | 38 | | |
12 | 39 | | |
13 | | - | |
14 | | - | |
| 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 | + | |
15 | 110 | | |
16 | 111 | | |
17 | 112 | | |
18 | | - | |
| 113 | + | |
19 | 114 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
27 | 118 | | |
28 | 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 | + | |
29 | 158 | | |
30 | 159 | | |
31 | 160 | | |
| |||
38 | 167 | | |
39 | 168 | | |
40 | 169 | | |
41 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
42 | 173 | | |
43 | 174 | | |
44 | 175 | | |
45 | 176 | | |
46 | 177 | | |
47 | 178 | | |
48 | | - | |
49 | 179 | | |
50 | 180 | | |
51 | 181 | | |
| |||
0 commit comments