CurtHagenlocher commented on code in PR #3577:
URL: https://github.com/apache/arrow-adbc/pull/3577#discussion_r2440976626


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -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");

Review Comment:
   @birschick-bq, you've spent the most time with `Activity`. Does this 
"start/end" pattern of emitting one event at the beginning of a block and 
another at the end look good to you?



##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -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)");

Review Comment:
   I think in the future we'll want to revisit logging of catalog and schema 
for redaction support. (And yes, I still need to look at Bruce's PR.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to