-
Notifications
You must be signed in to change notification settings - Fork 173
feat(csharp): add statement-level trace parent support #3896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(csharp): add statement-level trace parent support #3896
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>
CurtHagenlocher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
birschick-bq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
) <!-- 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)
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