You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jeremytang-db (via GitHub)" <gi...@apache.org> on 2025/07/23 17:12:38 UTC

[PR] [WIP] Implement Telemetry Reporting for Databricks [arrow-adbc]

jeremytang-db opened a new pull request, #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191

   Created Telemetry models to fit Telemetry data in required format. 
   Uses ActivityListener to collect activities.
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2237843841


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -66,13 +71,22 @@ internal class DatabricksConnection : SparkHttpConnection
         private string _traceParentHeaderName = "traceparent";
         private bool _traceStateEnabled = false;
 
+        private DatabricksActivityListener _listener;
+        private DriverConnectionParameters _connectionParams;
+        private HostDetails _hostDetails;
+        private ClientContext _clientContext;
+
         // Default namespace
         private TNamespace? _defaultNamespace;
 
         private HttpClient? _authHttpClient;
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _listener = new DatabricksActivityListener();

Review Comment:
   Yea, I think so. I wasn't sure where to initialize this, but maybe I should move it in `TelemetryHelper.cs`



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2237624729


##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,73 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System.IO;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()
+        {
+            this._activityListener = new ActivityListener
+            {
+                //ShouldListenTo = (activitySource) => activitySource.Name == sourceName,
+                ShouldListenTo = _ => true,

Review Comment:
   Oh yea, I think I should ask Bruce about this, but from my testing, I couldn't figure out the source name it should use to capture all the relevant activities. I think it's defined like `GetType().Assembly.GetName().Name!` in ActivityTrace.cs, but the _trace field in TracingConnection.cs is marked as private so it's not accessible.



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#issuecomment-3145140934

   @CurtHagenlocher @birschick-bq @jadewang-db  
   Thanks for all the feedback. I believe I have addressed everything. Could you take another quick look when you get the chance?


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2240620236


##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()
+        {
+            this._activityListener = new ActivityListener
+            {
+                //ShouldListenTo = (activitySource) => activitySource.Name == sourceName,
+                ShouldListenTo = _ => true,
+                Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
+                ActivityStarted = OnActivityStarted,
+                ActivityStopped = OnActivityStopped,
+            };
+            ActivitySource.AddActivityListener(_activityListener);
+        }
+
+        private void OnActivityStarted(Activity activity)
+        {
+        }
+
+        private void OnActivityStopped(Activity activity)
+        {       
+            if(activity.OperationName == "ExecuteStatementAsync")

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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "birschick-bq (via GitHub)" <gi...@apache.org>.
birschick-bq commented on PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#issuecomment-3134364889

   @jeremytang-db - I'm working on a change to allow the `ActivitySource` tags to be set. I'll also expose the `ActivitySource.Name`


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "CurtHagenlocher (via GitHub)" <gi...@apache.org>.
CurtHagenlocher commented on PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#issuecomment-3234451414

   The subject of client-side telemetry is often a contentious one. I think there should be an opt-out for it on the connection string.
   
   Unrelated to that, there may have been a merge or rebase error as this doesn't currently appear to build.


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2237876898


##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryClient.cs:
##########
@@ -0,0 +1,124 @@
+/*
+* 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.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class TelemetryClient
+    {
+        private readonly HttpClient _httpClient;
+        private readonly string? _telemetryUrl;
+        private readonly string? _accessToken;
+
+        public TelemetryClient(string? hostUrl, string? accessToken)
+        {
+            _httpClient = new HttpClient();

Review Comment:
   Updated to pass in _authHttpClient



##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryHelper.cs:
##########
@@ -0,0 +1,170 @@
+/*
+* 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
+{
+    public class TelemetryHelper
+    {
+        private static List<TelemetryFrontendLog> _eventsBatch = new List<TelemetryFrontendLog>();
+        private static readonly object _eventsBatchLock = new object();
+        private static readonly int _maxBatchSize = 5;

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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#issuecomment-3129918889

   @birschick-bq Could you take a look at this PR? Especially with the logic in DatabricksActivityListener.cs.


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2261674382


##########
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);
+            _telemetryHelper.SetParameters(connectionParams, clientContext);

Review Comment:
   updated by adding a new method for telemetry



##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -76,15 +86,16 @@ internal class DatabricksConnection : SparkHttpConnection
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _guid = Guid.NewGuid();
             ValidateProperties();
+            _databricksActivityListener = new DatabricksActivityListener(_telemetryHelper, this.AssemblyName, _guid);
         }
 
         public override IEnumerable<KeyValuePair<string, object?>>? GetActivitySourceTags(IReadOnlyDictionary<string, string> properties)
         {
             IEnumerable<KeyValuePair<string, object?>>? tags = base.GetActivitySourceTags(properties);
-            // TODO: Add any additional tags specific to Databricks connection
-            //tags ??= [];
-            //tags.Concat([new("key", "value")]);
+            tags ??= [];
+            tags.Concat([new("guid",_guid)]);

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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "birschick-bq (via GitHub)" <gi...@apache.org>.
birschick-bq commented on PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#issuecomment-3130676692

   P.S. You should normally work on a feature branch and not `main` in your fork. This will make it easier to sync your `main` with the upstream repository. Let me know if you want a further explanation?


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2237608291


##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryClient.cs:
##########
@@ -0,0 +1,124 @@
+/*
+* 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.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class TelemetryClient
+    {
+        private readonly HttpClient _httpClient;
+        private readonly string? _telemetryUrl;
+        private readonly string? _accessToken;
+
+        public TelemetryClient(string? hostUrl, string? accessToken)
+        {
+            _httpClient = new HttpClient();

Review Comment:
   Do you mean pass in "_authHttpClient" from DatabricksConnection.cs or a handler, or something else? 



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2240685963


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -66,13 +71,22 @@ internal class DatabricksConnection : SparkHttpConnection
         private string _traceParentHeaderName = "traceparent";
         private bool _traceStateEnabled = false;
 
+        private DatabricksActivityListener _listener;
+        private DriverConnectionParameters _connectionParams;
+        private HostDetails _hostDetails;
+        private ClientContext _clientContext;
+
         // Default namespace
         private TNamespace? _defaultNamespace;
 
         private HttpClient? _authHttpClient;
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _listener = new DatabricksActivityListener();

Review Comment:
   Update: because of Bruce's comment, I updated TelemetryHelper to be non static. So to avoid duplicate reports, I made DatabricksActivityListener static.



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2240685963


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -66,13 +71,22 @@ internal class DatabricksConnection : SparkHttpConnection
         private string _traceParentHeaderName = "traceparent";
         private bool _traceStateEnabled = false;
 
+        private DatabricksActivityListener _listener;
+        private DriverConnectionParameters _connectionParams;
+        private HostDetails _hostDetails;
+        private ClientContext _clientContext;
+
         // Default namespace
         private TNamespace? _defaultNamespace;
 
         private HttpClient? _authHttpClient;
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _listener = new DatabricksActivityListener();

Review Comment:
   Update: because of Bruce's comment, I updated TelemetryHelper to be non static. So to avoid duplicate reports, I made DatabricksActivityListener static.



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db closed pull request #3191: feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks
URL: https://github.com/apache/arrow-adbc/pull/3191


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "birschick-bq (via GitHub)" <gi...@apache.org>.
birschick-bq commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2258263885


##########
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:
   This `_hostUrl` is never used. It's duplicated in `DriverConnectionParameters`.



##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -76,15 +86,16 @@ internal class DatabricksConnection : SparkHttpConnection
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _guid = Guid.NewGuid();
             ValidateProperties();
+            _databricksActivityListener = new DatabricksActivityListener(_telemetryHelper, this.AssemblyName, _guid);
         }
 
         public override IEnumerable<KeyValuePair<string, object?>>? GetActivitySourceTags(IReadOnlyDictionary<string, string> properties)
         {
             IEnumerable<KeyValuePair<string, object?>>? tags = base.GetActivitySourceTags(properties);
-            // TODO: Add any additional tags specific to Databricks connection
-            //tags ??= [];
-            //tags.Concat([new("key", "value")]);
+            tags ??= [];
+            tags.Concat([new("guid",_guid)]);

Review Comment:
   Need to use the returned collection.
   ```suggestion
               tags = tags.Concat([new("guid",_guid)]);
   ```



##########
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:
   You don't need to send `hostDetails.HostUrl`.



##########
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);
+            _telemetryHelper.SetParameters(connectionParams, clientContext);

Review Comment:
   You should just pass these in the constructor, above.



##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -757,6 +806,16 @@ protected override void Dispose(bool disposing)
             if (disposing)
             {
                 _authHttpClient?.Dispose();
+                _databricksActivityListener?.Dispose();
+                
+                try
+                {
+                    _telemetryHelper?.ForceFlushAsync().Wait(TimeSpan.FromSeconds(2));

Review Comment:
   I would have thought that you want to flush before disposing `_authHttpClient`?



##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,69 @@
+/*
+* 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.Diagnostics;
+using System.IO;
+using System.Linq;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Apache;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class DatabricksActivityListener : IDisposable
+    {
+        private readonly ActivityListener _activityListener;
+        private TelemetryHelper? _telemetryHelper;
+
+        public DatabricksActivityListener(TelemetryHelper? telemetryHelper, string sourceName, Guid guid)
+        {
+            this._telemetryHelper = telemetryHelper;
+            this._activityListener = new ActivityListener
+            {
+                ShouldListenTo = (activitySource) => activitySource.Tags?.Any(kvp => kvp.Key == "guid" && kvp.Value?.Equals(guid) == true) == true,
+                Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
+                ActivityStopped = OnActivityStopped,
+            };
+            ActivitySource.AddActivityListener(_activityListener);
+        }
+
+        private void OnActivityStopped(Activity activity)
+        {       
+            if(_telemetryHelper == null)
+            {
+                return;
+            }
+
+            if(activity.OperationName?.EndsWith("ExecuteStatementAsync") == true)
+            {
+                var sqlExecutionEvent = new SqlExecutionEvent();
+                var operationDetail = new OperationDetail();
+                operationDetail.OperationType = Util.StringToOperationType("EXECUTE_STATEMENT_ASYNC");

Review Comment:
   Why not use the `enum` directly? (`OperationType.EXECUTE_STATEMENT_ASYNC`)



##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -76,15 +86,16 @@ internal class DatabricksConnection : SparkHttpConnection
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _guid = Guid.NewGuid();
             ValidateProperties();
+            _databricksActivityListener = new DatabricksActivityListener(_telemetryHelper, this.AssemblyName, _guid);
         }
 
         public override IEnumerable<KeyValuePair<string, object?>>? GetActivitySourceTags(IReadOnlyDictionary<string, string> properties)
         {
             IEnumerable<KeyValuePair<string, object?>>? tags = base.GetActivitySourceTags(properties);
-            // TODO: Add any additional tags specific to Databricks connection
-            //tags ??= [];
-            //tags.Concat([new("key", "value")]);
+            tags ??= [];
+            tags.Concat([new("guid",_guid)]);

Review Comment:
   I would recommend a key with "databricks. ..." in the namespace so as not to accidentally be confused with a tag from another trace source. Also use a constant to reduce chance of spelling mistake.



##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryClient.cs:
##########
@@ -0,0 +1,124 @@
+/*
+* 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.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class TelemetryClient
+    {
+        private readonly HttpClient _httpClient;
+        private readonly string? _telemetryUrl;
+        private readonly string? _accessToken;
+
+        public TelemetryClient(HttpClient httpClient, string? hostUrl, string? accessToken)
+        {
+            _httpClient = httpClient;
+            _accessToken = accessToken;
+            _telemetryUrl = !string.IsNullOrEmpty(hostUrl) ? accessToken != null ? $"https://{hostUrl}/telemetry-ext" : $"https://{hostUrl}/telemetry-unauth" : null;
+        }
+
+        /// <summary>
+        /// Sends a batch of telemetry events asynchronously
+        /// </summary>
+        /// <param name="telemetryBatch">List of telemetry events to send</param>
+        /// <returns>Task representing the async operation</returns>
+        public async Task<bool> SendTelemetryBatchAsync(List<TelemetryFrontendLog> telemetryBatch)
+        {
+            if (string.IsNullOrEmpty(_telemetryUrl) || telemetryBatch.Count == 0)
+            {
+                return false;
+            }
+
+            try
+            {
+                var request = new HttpRequestMessage(HttpMethod.Post, _telemetryUrl);
+                
+                // Serialize the batch to JSON
+                var telemetryRequest = new TelemetryRequest();
+                telemetryRequest.UploadTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                telemetryRequest.ProtoLogs = telemetryBatch.Select(x => JsonSerializer.Serialize(x)).ToList();
+                request.Content = new StringContent(JsonSerializer.Serialize(telemetryRequest));
+                
+                // Set headers
+                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+                request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+                if(_accessToken != null)
+                {
+                    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken);
+                }
+
+                var response = await _httpClient.SendAsync(request);
+                return response.IsSuccessStatusCode;
+            }
+            catch (Exception ex)
+            {
+                // Log the exception but don't throw to prevent telemetry failures from affecting main functionality
+                System.Diagnostics.Debug.WriteLine($"Failed to send telemetry: {ex.Message}");
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Sends a single telemetry event asynchronously
+        /// </summary>
+        /// <param name="telemetryEvent">Single telemetry event to send</param>
+        /// <returns>Task representing the async operation</returns>
+        public async Task<bool> SendTelemetryAsync(TelemetryFrontendLog telemetryEvent)

Review Comment:
   This seems to be same as `SendTelemetryBatchAsync` but is not actually used anywhere. I don't think you need it.



##########
csharp/src/Drivers/Databricks/Telemetry/Util.cs:
##########
@@ -0,0 +1,107 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class Util
+    {
+        private static string DRIVER_VERSION = GetAssemblyVersion(typeof(DatabricksConnection));
+
+        private static string DRIVER_NAME = GetAssemblyName(typeof(DatabricksConnection));
+
+        private static string GetAssemblyName(Type type) => type.Assembly.GetName().Name!;
+
+        private static string GetAssemblyVersion(Type type) => FileVersionInfo.GetVersionInfo(type.Assembly.Location).ProductVersion ?? string.Empty;
+

Review Comment:
   nit. extra line
   ```suggestion
   ```



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#issuecomment-3186098617

   @birschick-bq  Sorry, I pushed to the wrong branch. It should be updated now.
   
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2261675241


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -76,15 +86,16 @@ internal class DatabricksConnection : SparkHttpConnection
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _guid = Guid.NewGuid();
             ValidateProperties();
+            _databricksActivityListener = new DatabricksActivityListener(_telemetryHelper, this.AssemblyName, _guid);
         }
 
         public override IEnumerable<KeyValuePair<string, object?>>? GetActivitySourceTags(IReadOnlyDictionary<string, string> properties)
         {
             IEnumerable<KeyValuePair<string, object?>>? tags = base.GetActivitySourceTags(properties);
-            // TODO: Add any additional tags specific to Databricks connection
-            //tags ??= [];
-            //tags.Concat([new("key", "value")]);
+            tags ??= [];
+            tags.Concat([new("guid",_guid)]);

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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jadewang-db (via GitHub)" <gi...@apache.org>.
jadewang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2237552832


##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,73 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more

Review Comment:
   please add a readme file in this folder, on how is the file generated. 



##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryHelper.cs:
##########
@@ -0,0 +1,170 @@
+/*
+* 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
+{
+    public class TelemetryHelper
+    {
+        private static List<TelemetryFrontendLog> _eventsBatch = new List<TelemetryFrontendLog>();
+        private static readonly object _eventsBatchLock = new object();
+        private static readonly int _maxBatchSize = 5;

Review Comment:
   please add config



##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,73 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System.IO;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()
+        {
+            this._activityListener = new ActivityListener
+            {
+                //ShouldListenTo = (activitySource) => activitySource.Name == sourceName,
+                ShouldListenTo = _ => true,

Review Comment:
   make these passed in or configurable?



##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -66,13 +71,22 @@ internal class DatabricksConnection : SparkHttpConnection
         private string _traceParentHeaderName = "traceparent";
         private bool _traceStateEnabled = false;
 
+        private DatabricksActivityListener _listener;
+        private DriverConnectionParameters _connectionParams;
+        private HostDetails _hostDetails;
+        private ClientContext _clientContext;
+
         // Default namespace
         private TNamespace? _defaultNamespace;
 
         private HttpClient? _authHttpClient;
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _listener = new DatabricksActivityListener();

Review Comment:
   will this cause duplicate report ?  



##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryClient.cs:
##########
@@ -0,0 +1,124 @@
+/*
+* 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.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class TelemetryClient
+    {
+        private readonly HttpClient _httpClient;
+        private readonly string? _telemetryUrl;
+        private readonly string? _accessToken;
+
+        public TelemetryClient(string? hostUrl, string? accessToken)
+        {
+            _httpClient = new HttpClient();

Review Comment:
   should we have this passed in?



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "birschick-bq (via GitHub)" <gi...@apache.org>.
birschick-bq commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2238456800


##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()

Review Comment:
   You could pass in the source name using `ApacheUtility.GetAssemblyName(typeof(DatabricksConnection))`. Or from `connection.AssemblyName` (if you access to the connection object).



##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryHelper.cs:
##########
@@ -0,0 +1,173 @@
+/*
+* 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
+{
+    public class TelemetryHelper
+    {
+        private static List<TelemetryFrontendLog> _eventsBatch = new List<TelemetryFrontendLog>();
+        private static readonly object _eventsBatchLock = new object();
+        private static long _lastFlushTimeMillis;
+        private static readonly Timer _flushTimer;
+
+        private static TelemetryClient? _telemetryClient;
+        private static DatabricksActivityListener? _activityListener;
+
+        private static ClientContext? _clientContext;
+        private static string? _accessToken;
+        private static DriverConnectionParameters? _connectionParameters;
+        private static readonly DriverSystemConfiguration _systemConfiguration = new DriverSystemConfiguration()
+        {
+            DriverVersion = Util.GetDriverVersion(),
+            DriverName = Util.GetDriverName(),
+            OsName = Environment.OSVersion.Platform.ToString(),
+            OsVersion = Environment.OSVersion.Version.ToString(),
+            OsArch = Environment.OSVersion.Platform.ToString(),
+            RuntimeName = Assembly.GetExecutingAssembly().GetName().Name,
+            RuntimeVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(),
+            RuntimeVendor = RuntimeInformation.FrameworkDescription,
+            ClientAppName = null,
+            LocaleName = CultureInfo.CurrentCulture.Name,
+            ProcessName = Process.GetCurrentProcess().ProcessName
+        };
+
+        static TelemetryHelper()

Review Comment:
   I believe this should be an instance class and not static. 
   It should be instanced by the these two value: `_connectionParameters.HostInfo.HostUrl, _accessToken`
   
   Why? Because if you had more than one instance of DatabricksConnection (with different HostUrl), the second one would overwrite the HostUrl and accessToken and the original would now be sending telemetry to the second connection's host.



##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;

Review Comment:
   ```suggestion
           private readonly ActivityListener _activityListener;
   ```



##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()
+        {
+            this._activityListener = new ActivityListener
+            {
+                //ShouldListenTo = (activitySource) => activitySource.Name == sourceName,
+                ShouldListenTo = _ => true,
+                Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
+                ActivityStarted = OnActivityStarted,
+                ActivityStopped = OnActivityStopped,
+            };
+            ActivitySource.AddActivityListener(_activityListener);
+        }
+
+        private void OnActivityStarted(Activity activity)
+        {
+        }
+
+        private void OnActivityStopped(Activity activity)
+        {       
+            if(activity.OperationName == "ExecuteStatementAsync")

Review Comment:
   You might consider `.EndsWith()`.



##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()
+        {
+            this._activityListener = new ActivityListener
+            {
+                //ShouldListenTo = (activitySource) => activitySource.Name == sourceName,
+                ShouldListenTo = _ => true,
+                Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
+                ActivityStarted = OnActivityStarted,
+                ActivityStopped = OnActivityStopped,
+            };
+            ActivitySource.AddActivityListener(_activityListener);
+        }
+
+        private void OnActivityStarted(Activity activity)
+        {
+        }
+
+        private void OnActivityStopped(Activity activity)
+        {       
+            if(activity.OperationName == "ExecuteStatementAsync")
+            {
+                var sqlExecutionEvent = new SqlExecutionEvent();
+                var operationDetail = new OperationDetail();
+                operationDetail.OperationType = Util.StringToOperationType("EXECUTE_STATEMENT_ASYNC");
+                sqlExecutionEvent.OperationDetail = operationDetail;
+                TelemetryHelper.AddSqlExecutionEvent(sqlExecutionEvent);
+            }
+            // iterate over the tags and create a telemetry event
+            foreach (var tag in activity.Tags)
+            {
+                // example tag and handling
+                if(tag.Key == "sql.query")

Review Comment:
   You should use `SemanticConventions.Db.Query.Text` for this and instrumentation.



##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()
+        {
+            this._activityListener = new ActivityListener
+            {
+                //ShouldListenTo = (activitySource) => activitySource.Name == sourceName,
+                ShouldListenTo = _ => true,
+                Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
+                ActivityStarted = OnActivityStarted,
+                ActivityStopped = OnActivityStopped,
+            };
+            ActivitySource.AddActivityListener(_activityListener);
+        }
+
+        private void OnActivityStarted(Activity activity)
+        {
+        }
+
+        private void OnActivityStopped(Activity activity)
+        {       
+            if(activity.OperationName == "ExecuteStatementAsync")
+            {
+                var sqlExecutionEvent = new SqlExecutionEvent();
+                var operationDetail = new OperationDetail();
+                operationDetail.OperationType = Util.StringToOperationType("EXECUTE_STATEMENT_ASYNC");
+                sqlExecutionEvent.OperationDetail = operationDetail;
+                TelemetryHelper.AddSqlExecutionEvent(sqlExecutionEvent);
+            }
+            // iterate over the tags and create a telemetry event
+            foreach (var tag in activity.Tags)
+            {
+                // example tag and handling
+                if(tag.Key == "sql.query")
+                {
+                    var sqlExecutionEvent = new SqlExecutionEvent();
+                    var operationDetail = new OperationDetail();
+                    operationDetail.OperationType = Util.StringToOperationType(tag.Value);
+                    sqlExecutionEvent.StatementType = StatementType.QUERY;
+                    sqlExecutionEvent.OperationDetail = operationDetail;
+                    TelemetryHelper.AddSqlExecutionEvent(sqlExecutionEvent);
+                }
+            }
+        }
+
+        public void Dispose()
+        {   
+            this._activityListener.Dispose();
+        }
+    }
+}

Review Comment:
   nit: empty line at EOF.
   ```suggestion
   }
   
   ```



##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()
+        {
+            this._activityListener = new ActivityListener
+            {
+                //ShouldListenTo = (activitySource) => activitySource.Name == sourceName,
+                ShouldListenTo = _ => true,
+                Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
+                ActivityStarted = OnActivityStarted,

Review Comment:
   No need to set this properties if you intend it to be empty.



##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+

Review Comment:
   nit
   ```suggestion
   ```



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2255292427


##########
csharp/src/Drivers/Databricks/Telemetry/Util.cs:
##########
@@ -0,0 +1,101 @@
+/*
+* 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 Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class Util
+    {
+        private static string DRIVER_VERSION = "1.0.0";

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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "davidhcoe (via GitHub)" <gi...@apache.org>.
davidhcoe commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2255000474


##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryClient.cs:
##########
@@ -0,0 +1,124 @@
+/*
+* 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.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class TelemetryClient
+    {
+        private readonly HttpClient _httpClient;
+        private readonly string? _telemetryUrl;
+        private readonly string? _accessToken;
+
+        public TelemetryClient(HttpClient httpClient, string? hostUrl, string? accessToken)
+        {
+            _httpClient = httpClient;
+            _accessToken = accessToken;
+            _telemetryUrl = !string.IsNullOrEmpty(hostUrl) ? accessToken != null ? $"https://{hostUrl}/telemetry" : $"https://{hostUrl}/telemetry-unauth" : null;

Review Comment:
   I don't think this should be included with the driver. We have OpenTelemetry implemented, and the way to get this is via the OTEL logger. This is basically forcing extra traffic (especially on the service side) that isn't needed.



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2261675048


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -757,6 +806,16 @@ protected override void Dispose(bool disposing)
             if (disposing)
             {
                 _authHttpClient?.Dispose();
+                _databricksActivityListener?.Dispose();
+                
+                try
+                {
+                    _telemetryHelper?.ForceFlushAsync().Wait(TimeSpan.FromSeconds(2));

Review Comment:
   yes 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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2267453115


##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryClient.cs:
##########
@@ -0,0 +1,124 @@
+/*
+* 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.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class TelemetryClient
+    {
+        private readonly HttpClient _httpClient;
+        private readonly string? _telemetryUrl;
+        private readonly string? _accessToken;
+
+        public TelemetryClient(HttpClient httpClient, string? hostUrl, string? accessToken)
+        {
+            _httpClient = httpClient;
+            _accessToken = accessToken;
+            _telemetryUrl = !string.IsNullOrEmpty(hostUrl) ? accessToken != null ? $"https://{hostUrl}/telemetry-ext" : $"https://{hostUrl}/telemetry-unauth" : null;
+        }
+
+        /// <summary>
+        /// Sends a batch of telemetry events asynchronously
+        /// </summary>
+        /// <param name="telemetryBatch">List of telemetry events to send</param>
+        /// <returns>Task representing the async operation</returns>
+        public async Task<bool> SendTelemetryBatchAsync(List<TelemetryFrontendLog> telemetryBatch)
+        {
+            if (string.IsNullOrEmpty(_telemetryUrl) || telemetryBatch.Count == 0)
+            {
+                return false;
+            }
+
+            try
+            {
+                var request = new HttpRequestMessage(HttpMethod.Post, _telemetryUrl);
+                
+                // Serialize the batch to JSON
+                var telemetryRequest = new TelemetryRequest();
+                telemetryRequest.UploadTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                telemetryRequest.ProtoLogs = telemetryBatch.Select(x => JsonSerializer.Serialize(x)).ToList();
+                request.Content = new StringContent(JsonSerializer.Serialize(telemetryRequest));
+                
+                // Set headers
+                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+                request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+                if(_accessToken != null)
+                {
+                    request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken);
+                }
+
+                var response = await _httpClient.SendAsync(request);
+                return response.IsSuccessStatusCode;
+            }
+            catch (Exception ex)
+            {
+                // Log the exception but don't throw to prevent telemetry failures from affecting main functionality
+                System.Diagnostics.Debug.WriteLine($"Failed to send telemetry: {ex.Message}");
+                return false;
+            }
+        }
+
+        /// <summary>
+        /// Sends a single telemetry event asynchronously
+        /// </summary>
+        /// <param name="telemetryEvent">Single telemetry event to send</param>
+        /// <returns>Task representing the async operation</returns>
+        public async Task<bool> SendTelemetryAsync(TelemetryFrontendLog telemetryEvent)

Review Comment:
   removed



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2237877417


##########
csharp/src/Drivers/Databricks/DatabricksConnection.cs:
##########
@@ -66,13 +71,22 @@ internal class DatabricksConnection : SparkHttpConnection
         private string _traceParentHeaderName = "traceparent";
         private bool _traceStateEnabled = false;
 
+        private DatabricksActivityListener _listener;
+        private DriverConnectionParameters _connectionParams;
+        private HostDetails _hostDetails;
+        private ClientContext _clientContext;
+
         // Default namespace
         private TNamespace? _defaultNamespace;
 
         private HttpClient? _authHttpClient;
 
         public DatabricksConnection(IReadOnlyDictionary<string, string> properties) : base(properties)
         {
+            _listener = new DatabricksActivityListener();

Review Comment:
   Moved



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "davidhcoe (via GitHub)" <gi...@apache.org>.
davidhcoe commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2255029545


##########
csharp/src/Drivers/Databricks/Telemetry/Util.cs:
##########
@@ -0,0 +1,101 @@
+/*
+* 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 Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class Util
+    {
+        private static string DRIVER_VERSION = "1.0.0";

Review Comment:
   These should follow the same pattern that the other drivers in the repo do. The name is the DLL name and the version is the assembly version. See https://github.com/apache/arrow-adbc/blob/15e161e3657563f0c49decd0b3eefa30ed6673e8/csharp/src/Drivers/BigQuery/BigQueryUtils.cs#L38.



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2255090927


##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryClient.cs:
##########
@@ -0,0 +1,124 @@
+/*
+* 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.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class TelemetryClient
+    {
+        private readonly HttpClient _httpClient;
+        private readonly string? _telemetryUrl;
+        private readonly string? _accessToken;
+
+        public TelemetryClient(HttpClient httpClient, string? hostUrl, string? accessToken)
+        {
+            _httpClient = httpClient;
+            _accessToken = accessToken;
+            _telemetryUrl = !string.IsNullOrEmpty(hostUrl) ? accessToken != null ? $"https://{hostUrl}/telemetry" : $"https://{hostUrl}/telemetry-unauth" : null;

Review Comment:
   Oh I was unaware of this. Can you point me to how to access the OTEL logger? Thank you!



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#issuecomment-3133600314

   Thanks for your review. Please take a look again when you get the chance. 
   
   > P.S. You should normally work on a feature branch and not `main` in your fork. This will make it easier to sync your `main` with the upstream repository. Let me know if you want a further explanation?
   
   I see, is there a need to replace this 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: github-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2240618107


##########
csharp/src/Drivers/Databricks/Telemetry/TelemetryHelper.cs:
##########
@@ -0,0 +1,173 @@
+/*
+* 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
+{
+    public class TelemetryHelper
+    {
+        private static List<TelemetryFrontendLog> _eventsBatch = new List<TelemetryFrontendLog>();
+        private static readonly object _eventsBatchLock = new object();
+        private static long _lastFlushTimeMillis;
+        private static readonly Timer _flushTimer;
+
+        private static TelemetryClient? _telemetryClient;
+        private static DatabricksActivityListener? _activityListener;
+
+        private static ClientContext? _clientContext;
+        private static string? _accessToken;
+        private static DriverConnectionParameters? _connectionParameters;
+        private static readonly DriverSystemConfiguration _systemConfiguration = new DriverSystemConfiguration()
+        {
+            DriverVersion = Util.GetDriverVersion(),
+            DriverName = Util.GetDriverName(),
+            OsName = Environment.OSVersion.Platform.ToString(),
+            OsVersion = Environment.OSVersion.Version.ToString(),
+            OsArch = Environment.OSVersion.Platform.ToString(),
+            RuntimeName = Assembly.GetExecutingAssembly().GetName().Name,
+            RuntimeVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(),
+            RuntimeVendor = RuntimeInformation.FrameworkDescription,
+            ClientAppName = null,
+            LocaleName = CultureInfo.CurrentCulture.Name,
+            ProcessName = Process.GetCurrentProcess().ProcessName
+        };
+
+        static TelemetryHelper()

Review Comment:
   That makes sense. I have updated this.



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2240619701


##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,79 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+using System;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    public class DatabricksActivityListener : IDisposable
+    {
+
+        private ActivityListener _activityListener;
+
+        public DatabricksActivityListener()
+        {
+            this._activityListener = new ActivityListener
+            {
+                //ShouldListenTo = (activitySource) => activitySource.Name == sourceName,
+                ShouldListenTo = _ => true,
+                Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
+                ActivityStarted = OnActivityStarted,

Review Comment:
   Currently unsure if it is necessary, but removed for now.



-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2261675479


##########
csharp/src/Drivers/Databricks/Telemetry/Util.cs:
##########
@@ -0,0 +1,107 @@
+/*
+* 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.Diagnostics;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class Util
+    {
+        private static string DRIVER_VERSION = GetAssemblyVersion(typeof(DatabricksConnection));
+
+        private static string DRIVER_NAME = GetAssemblyName(typeof(DatabricksConnection));
+
+        private static string GetAssemblyName(Type type) => type.Assembly.GetName().Name!;
+
+        private static string GetAssemblyVersion(Type type) => FileVersionInfo.GetVersionInfo(type.Assembly.Location).ProductVersion ?? string.Empty;
+

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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "jeremytang-db (via GitHub)" <gi...@apache.org>.
jeremytang-db commented on code in PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#discussion_r2267453842


##########
csharp/src/Drivers/Databricks/Telemetry/DatabricksActivityListener.cs:
##########
@@ -0,0 +1,69 @@
+/*
+* 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.Diagnostics;
+using System.IO;
+using System.Linq;
+using Apache.Arrow.Adbc.Tracing;
+using Apache.Arrow.Adbc.Drivers.Apache;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Model;
+using Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.Enums;
+
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry
+{
+    internal class DatabricksActivityListener : IDisposable
+    {
+        private readonly ActivityListener _activityListener;
+        private TelemetryHelper? _telemetryHelper;
+
+        public DatabricksActivityListener(TelemetryHelper? telemetryHelper, string sourceName, Guid guid)
+        {
+            this._telemetryHelper = telemetryHelper;
+            this._activityListener = new ActivityListener
+            {
+                ShouldListenTo = (activitySource) => activitySource.Tags?.Any(kvp => kvp.Key == "guid" && kvp.Value?.Equals(guid) == true) == true,
+                Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
+                ActivityStopped = OnActivityStopped,
+            };
+            ActivitySource.AddActivityListener(_activityListener);
+        }
+
+        private void OnActivityStopped(Activity activity)
+        {       
+            if(_telemetryHelper == null)
+            {
+                return;
+            }
+
+            if(activity.OperationName?.EndsWith("ExecuteStatementAsync") == true)
+            {
+                var sqlExecutionEvent = new SqlExecutionEvent();
+                var operationDetail = new OperationDetail();
+                operationDetail.OperationType = Util.StringToOperationType("EXECUTE_STATEMENT_ASYNC");

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-unsubscribe@arrow.apache.org

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


Re: [PR] feat(csharp/src/Drivers/Databricks): Implement Telemetry Reporting for Databricks [arrow-adbc]

Posted by "birschick-bq (via GitHub)" <gi...@apache.org>.
birschick-bq commented on PR #3191:
URL: https://github.com/apache/arrow-adbc/pull/3191#issuecomment-3185861710

   @jeremytang-db - I see you updated the comments, but I don't see any new pushed commits. Do you any commits that aren't pushed yet? Is it on another branch?


-- 
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-unsubscribe@arrow.apache.org

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