Commit b99a179
feat(csharp): add statement-level trace parent support (#3896)
## Summary
Enable setting trace parent at the statement level for connection
pooling scenarios like Power BI, where multiple queries reuse the same
connection but need different trace IDs for distributed tracing.
## Changes
- **TracingStatement**: Add `_statementTraceParent` field and
`SetTraceParent()` method
- **TracingStatement**: `TraceParent` property now returns statement
override or falls back to connection's trace parent
- **HiveServer2Statement**: Add `SetOption` case for
`AdbcOptions.Telemetry.TraceParent`
- Add comprehensive test coverage for statement-level trace parent
functionality
## Motivation
This brings C# implementation to parity with Go drivers which already
support statement-level trace parent via `SetOption`.
### Power BI Use Case
Power BI uses connection pooling where multiple queries reuse the same
connection. Each Power BI query has its own trace ID for distributed
tracing correlation. Without statement-level trace parent support, all
queries from a pooled connection would share the same trace context,
making it impossible to correlate individual query traces.
With this change, Power BI can:
```csharp
var connection = pool.GetConnection();
// Query 1 with Trace ID A
var stmt1 = connection.CreateStatement();
stmt1.SetOption("adbc.telemetry.trace_parent", powerBiQueryTraceIdA);
stmt1.ExecuteQuery();
// Query 2 with Trace ID B (same connection!)
var stmt2 = connection.CreateStatement();
stmt2.SetOption("adbc.telemetry.trace_parent", powerBiQueryTraceIdB);
stmt2.ExecuteQuery();
```
## Test Plan
Added `CanSetTraceParentOnStatement` test that verifies:
1. Statement inherits connection's trace parent by default
2. Statement can override with its own trace parent via `SetOption`
3. Activities created by the statement use the statement's trace parent
4. Setting trace parent to null falls back to connection's trace parent
All existing tests pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent dfa8a56 commit b99a179
File tree
3 files changed
+88
-1
lines changed- csharp
- src
- Apache.Arrow.Adbc/Tracing
- Drivers/Apache/Hive2
- test/Apache.Arrow.Adbc.Tests/Tracing
3 files changed
+88
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
322 | 325 | | |
323 | 326 | | |
324 | 327 | | |
| |||
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
258 | 309 | | |
259 | 310 | | |
260 | 311 | | |
| |||
451 | 502 | | |
452 | 503 | | |
453 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
454 | 532 | | |
455 | 533 | | |
456 | 534 | | |
| |||
0 commit comments