Skip to content

Conversation

@eric-wang-1990
Copy link
Contributor

Summary

This PR adds detailed activity tracing for the Databricks connection phase to improve observability and debugging. The logging follows the pattern used by commercial ODBC drivers like Simba.

Key improvements:

  • Logs driver information (name, version, assembly) at connection start
  • Logs all connection properties with exact ADBC parameter names (e.g., adbc.databricks.xxx, adbc.spark.xxx)
  • Sanitizes sensitive values (passwords, tokens, secrets) to show as ***
  • Logs OpenSession request details (protocol version, namespace, configuration)
  • Logs OpenSession response with protocol capabilities and final feature flags
  • Separates protocol-dependent features from user settings
  • Logs feature downgrades when protocol doesn't support requested features
  • Logs namespace handling and fallback logic

Changes

  • Modified DatabricksConnection.cs:
    • Added OpenAsync() override to log driver info and connection properties within activity context
    • Added LogConnectionProperties() method to iterate and log all properties with sanitization
    • Enhanced CreateSessionRequest() to log request details
    • Enhanced HandleOpenSessionResponse() to log protocol negotiation and feature flags

Example Log Output

Connection properties are now logged in the activity trace with exact names:

"TagObjects": {
  "adbc.spark.type": "http",
  "adbc.spark.host": "...",
  "adbc.databricks.enable_multiple_catalog_support": "true",
  "adbc.spark.access_token": "***",
  ...
}

How is this tested?

  • Built successfully with dotnet build
  • Tested with actual Databricks connection on Windows
  • Verified log output contains driver info, connection properties, and protocol details
  • Verified sensitive values are properly sanitized

🤖 Generated with Claude Code

This commit adds detailed activity tracing for the Databricks connection phase
to improve observability and debugging.

Changes:
- Added driver information logging (name, version, assembly) at connection start
- Added connection properties logging with exact ADBC parameter names
- Implemented property sanitization for sensitive values (passwords, tokens, secrets)
- Added OpenSession request logging (protocol version, namespace, configuration)
- Added OpenSession response logging with protocol capabilities and feature flags
- Added separate logging for protocol-dependent features vs user settings
- Added feature downgrade logging when protocol doesn't support requested features
- Added namespace handling and fallback logging

The logging follows the pattern used by commercial ODBC drivers like Simba,
providing comprehensive visibility into the connection establishment process.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
eric-wang-1990 and others added 3 commits October 15, 2025 06:18
- Remove connection.client_protocol_version (duplicate of connection.client_protocol)
- Remove connection.server_protocol_version_value (duplicate of connection.server_protocol_version)
- Remove total_properties from connection.properties.end event

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
The previous implementation created nested OpenAsync activities which caused
HandleOpenSessionResponse logging to be lost. Now all connection logging
(driver info, properties, request, response, protocol capabilities, and
feature flags) will appear in a single OpenAsync activity.

Changes:
- Removed duplicate OpenAsync override that created nested activity
- Moved driver info and property logging to CreateSessionRequest
- All logging now uses the base class's traced OpenAsync activity

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Events added late in the activity lifecycle may not be captured by the
activity listener. Changed protocol capabilities and feature flags from
AddEvent to SetTag so they appear reliably in the log output.

Changes:
- Protocol capabilities now logged as tags (connection.protocol.*)
- Feature flags now logged as tags (connection.feature.*)
- Feature downgrades now logged as tags when they occur

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

protected override async Task HandleOpenSessionResponse(TOpenSessionResp? session, Activity? activity = default)
{
activity?.AddEvent("connection.open_session_response.received");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that since this HandleOpenSessionresponse is called from after this OpenSession

session = await Client.OpenSession(request, cancellationToken);
, and operation to the activity after that call will somehow not be serialized to the log. Do you have any idea why? @birschick-bq

@CurtHagenlocher CurtHagenlocher changed the title Add comprehensive connection logging to Databricks ADBC driver feat(csharp/src/Drivers/Databricks): Add comprehensive connection logging to Databricks ADBC driver Oct 15, 2025
Copy link
Contributor

@CurtHagenlocher CurtHagenlocher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall these changes look fine to me, but I haven't really developed an internalized sense for System.Diagnostics.Activity so I'm hoping that @birschick-bq can provide feedback too.

eric-wang-1990 and others added 3 commits October 19, 2025 05:48
…y.Current

Changed CreateSessionRequest to wrap its logic in this.TraceActivity(activity => {...})
instead of relying on Activity.Current. This creates a proper child Activity span
for the session creation operation and improves tracing isolation.

All Activity.Current references have been replaced with the explicit activity parameter.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@eric-wang-1990
Copy link
Contributor Author

@CurtHagenlocher Are you able to merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants