-
Notifications
You must be signed in to change notification settings - Fork 165
feat(csharp/src/Drivers/Databricks): Add comprehensive connection logging to Databricks ADBC driver #3577
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
base: main
Are you sure you want to change the base?
feat(csharp/src/Drivers/Databricks): Add comprehensive connection logging to Databricks ADBC driver #3577
Changes from 4 commits
112e1d6
2ab73c8
21fb9f3
8cd79e5
8234f76
8df8b03
2987ce7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |||
| using Apache.Arrow.Adbc.Drivers.Apache.Spark; | ||||
| using Apache.Arrow.Adbc.Drivers.Databricks.Auth; | ||||
| using Apache.Arrow.Adbc.Drivers.Databricks.Reader; | ||||
| using Apache.Arrow.Adbc.Tracing; | ||||
| using Apache.Arrow.Ipc; | ||||
| using Apache.Hive.Service.Rpc.Thrift; | ||||
| using Thrift.Protocol; | ||||
|
|
@@ -100,6 +101,32 @@ public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : ba | |||
| ValidateProperties(); | ||||
| } | ||||
|
|
||||
| private void LogConnectionProperties(Activity? activity) | ||||
| { | ||||
| if (activity == null) return; | ||||
|
|
||||
| activity.AddEvent("connection.properties.start"); | ||||
|
|
||||
| foreach (var kvp in Properties) | ||||
| { | ||||
| string key = kvp.Key; | ||||
| string value = kvp.Value; | ||||
|
|
||||
| // Sanitize sensitive properties - only mask actual credentials/tokens, not configuration | ||||
| bool isSensitive = key.IndexOf("password", StringComparison.OrdinalIgnoreCase) >= 0 || | ||||
| key.IndexOf("secret", StringComparison.OrdinalIgnoreCase) >= 0 || | ||||
| key.Equals(AdbcOptions.Password, StringComparison.OrdinalIgnoreCase) || | ||||
| key.Equals(SparkParameters.AccessToken, StringComparison.OrdinalIgnoreCase) || | ||||
| key.Equals(DatabricksParameters.OAuthClientSecret, StringComparison.OrdinalIgnoreCase); | ||||
|
|
||||
| string logValue = isSensitive ? "***" : value; | ||||
|
|
||||
| activity.SetTag(key, logValue); | ||||
| } | ||||
|
|
||||
| activity.AddEvent("connection.properties.end"); | ||||
| } | ||||
|
|
||||
| public override IEnumerable<KeyValuePair<string, object?>>? GetActivitySourceTags(IReadOnlyDictionary<string, string> properties) | ||||
| { | ||||
| IEnumerable<KeyValuePair<string, object?>>? tags = base.GetActivitySourceTags(properties); | ||||
|
|
@@ -668,17 +695,34 @@ public override AdbcStatement CreateStatement() | |||
|
|
||||
| protected override TOpenSessionReq CreateSessionRequest() | ||||
| { | ||||
| // Log driver information at the beginning of the connection | ||||
| Activity.Current?.AddEvent("connection.driver.info", [ | ||||
| new("driver.name", "Apache Arrow ADBC Databricks Driver"), | ||||
| new("driver.version", s_assemblyVersion), | ||||
| new("driver.assembly", s_assemblyName) | ||||
| ]); | ||||
|
|
||||
| // Log connection properties (sanitize sensitive values) | ||||
| LogConnectionProperties(Activity.Current); | ||||
|
|
||||
| var req = new TOpenSessionReq | ||||
| { | ||||
| Client_protocol = TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V7, | ||||
| Client_protocol_i64 = (long)TProtocolVersion.SPARK_CLI_SERVICE_PROTOCOL_V7, | ||||
| CanUseMultipleCatalogs = _enableMultipleCatalogSupport, | ||||
| }; | ||||
|
|
||||
| // Log OpenSession request details | ||||
| Activity.Current?.AddEvent("connection.open_session_request.creating"); | ||||
| Activity.Current?.SetTag("connection.client_protocol", req.Client_protocol.ToString()); | ||||
| Activity.Current?.SetTag("connection.can_use_multiple_catalogs", _enableMultipleCatalogSupport); | ||||
|
|
||||
| // Set default namespace if available | ||||
| if (_defaultNamespace != null) | ||||
| { | ||||
| req.InitialNamespace = _defaultNamespace; | ||||
| Activity.Current?.SetTag("connection.initial_namespace.catalog", _defaultNamespace.CatalogName ?? "(none)"); | ||||
| Activity.Current?.SetTag("connection.initial_namespace.schema", _defaultNamespace.SchemaName ?? "(none)"); | ||||
eric-wang-1990 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| } | ||||
| req.Configuration = new Dictionary<string, string>(); | ||||
| // merge timestampConfig with serverSideProperties | ||||
|
|
@@ -695,31 +739,88 @@ protected override TOpenSessionReq CreateSessionRequest() | |||
| req.Configuration[property.Key] = property.Value; | ||||
| } | ||||
| } | ||||
|
|
||||
| Activity.Current?.SetTag("connection.configuration_count", req.Configuration.Count); | ||||
| Activity.Current?.AddEvent("connection.open_session_request.created"); | ||||
|
|
||||
| return req; | ||||
| } | ||||
|
|
||||
| protected override async Task HandleOpenSessionResponse(TOpenSessionResp? session, Activity? activity = default) | ||||
| { | ||||
| activity?.AddEvent("connection.open_session_response.received"); | ||||
|
||||
| session = await Client.OpenSession(request, cancellationToken); |
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.
nit: remove extra blank line
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.
nit: remove extra blank line
Uh oh!
There was an error while loading. Please reload this page.