feat(csharp): add statement-level trace parent support#3896
Merged
CurtHagenlocher merged 1 commit intoapache:mainfrom Jan 16, 2026
Merged
Conversation
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 This brings C# implementation to parity with Go drivers which already support statement-level trace parent via SetOption. Fixes support for Power BI scenarios where each query needs its own trace context while using connection pooling. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Contributor
birschick-bq
left a comment
There was a problem hiding this comment.
I'm think we want to update the trace parent all objects that use the Trace instance. I don't think we want a separate value for the statement.
| public abstract class TracingStatement : AdbcStatement, ITracingStatement | ||
| { | ||
| private readonly ActivityTrace _trace; | ||
| private string? _statementTraceParent; |
Contributor
There was a problem hiding this comment.
I'm not convinced we need a separate trace parent for statements.
Because the statement will use the connection to make calls, if the trace parent is not passed to the connection, the connection tracing won't include the trace parent value.
Contributor
Author
There was a problem hiding this comment.
This is just for enable databricks to override the traceparent that passed from PBI for statement level.
I am fine with reverting this and use some other generic approach to support, let me know what you think
This was referenced Jan 19, 2026
Merged
birschick-bq
added a commit
to adbc-drivers/hiveserver2
that referenced
this pull request
Jan 21, 2026
) <!-- Copyright (c) 2025 ADBC Drivers Contributors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> ## What's Changed - ports `Statement.SetOption` for `TraceParent` change from [arrow-adbc](apache/arrow-adbc#3896)
jhrotko
pushed a commit
to jhrotko/arrow-adbc
that referenced
this pull request
Feb 2, 2026
## 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
_statementTraceParentfield andSetTraceParent()methodTraceParentproperty now returns statement override or falls back to connection's trace parentSetOptioncase forAdbcOptions.Telemetry.TraceParentMotivation
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:
Test Plan
Added
CanSetTraceParentOnStatementtest that verifies:SetOptionAll existing tests pass.
🤖 Generated with Claude Code