jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2261673832


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -281,6 +292,43 @@ private void ValidateProperties()
             {
                 _identityFederationClientId = identityFederationClientId;
             }
+
+            //Telemetry
+            var connectionParams = new DriverConnectionParameters();
+            var hostDetails = new HostDetails();
+            var clientContext = new ClientContext();
+            string? token = null;
+
+            if (Properties.TryGetValue(SparkParameters.AuthType, out string? 
authType))
+            {
+                connectionParams.AuthMech = Util.StringToAuthMech(authType);
+            }
+
+            if (Properties.TryGetValue(SparkParameters.HostName, out string? 
host))
+            {
+                hostDetails.HostUrl = host;
+            }
+            if (Properties.TryGetValue(SparkParameters.Port, out string? port))
+            {
+                hostDetails.Port = Int32.Parse(port);
+            }
+            connectionParams.HostInfo = hostDetails;
+
+            if (Properties.TryGetValue(SparkParameters.UserAgentEntry, out 
string? userAgent))
+            {
+                clientContext.UserAgent = userAgent;
+            }
+            
+            if(Properties.TryGetValue(SparkParameters.AccessToken, out string? 
accessToken))
+            {
+                token = accessToken;
+            }   
+            else if(Properties.TryGetValue(SparkParameters.Token, out string? 
accesstoken))
+            {
+                token = accesstoken;
+            }
+            _telemetryHelper = new TelemetryHelper(hostDetails.HostUrl, token);

Review Comment:
   updated



##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryHelper.cs:
##########
@@ -0,0 +1,174 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Reflection;
+using System.Diagnostics;
+using System.Collections.Concurrent;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Runtime.InteropServices;
+using System.Threading;
+using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using Apache.Arrow.Adbc.Drivers.Apache.Spark;
+using System.Text.Json;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class TelemetryHelper
+    {
+        private static readonly ConcurrentQueue<TelemetryFrontendLog> 
EventsBatch = new ConcurrentQueue<TelemetryFrontendLog>();
+        private long _lastFlushTimeMillis;
+        private readonly Timer _flushTimer;
+
+        private TelemetryClient? _telemetryClient;
+
+        private ClientContext? _clientContext;
+        private string? _accessToken;
+        private string? _hostUrl;
+        private DriverConnectionParameters? _connectionParameters;
+        private readonly DriverSystemConfiguration _systemConfiguration;
+
+        public TelemetryHelper(string? hostUrl, string? accessToken)
+        {
+            _hostUrl = hostUrl;

Review Comment:
   updated



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to