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


##########
csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryEventType.cs:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions
+{
+    /// <summary>
+    /// Defines the types of telemetry events that can be emitted by the 
driver.
+    /// Each event type has its own set of allowed tags defined in 
corresponding *Event classes.
+    /// </summary>
+    public enum TelemetryEventType

Review Comment:
   ```suggestion
       public enum TelemetryEventType
   ```
   This is only used from inside the driver, right? If it's not already that 
way, we can use `InternalsVisibleTo` to make it available to tests.



##########
csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.Collections.Generic;
+using System.Linq;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions
+{
+    public static class TelemetryTagRegistry

Review Comment:
   ```suggestion
       internal static class TelemetryTagRegistry
   ```
   This is only used from inside the driver, right?



##########
csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.Collections.Generic;
+using System.Linq;
+
+namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions
+{
+    public static class TelemetryTagRegistry
+    {
+        /// <summary>
+        /// Gets tags allowed for Databricks export (privacy whitelist).
+        /// </summary>
+        // TODO: Explore alternate approaches to avoid maintaining separate 
GetDatabricksExportTags methods in each event class.
+        public static IReadOnlyCollection<string> 
GetDatabricksExportTags(TelemetryEventType eventType)
+        {
+            return eventType switch
+            {
+                TelemetryEventType.ConnectionOpen => 
ConnectionOpenEvent.GetDatabricksExportTags(),
+                TelemetryEventType.StatementExecution => 
StatementExecutionEvent.GetDatabricksExportTags(),
+                TelemetryEventType.Error => 
ErrorEvent.GetDatabricksExportTags(),
+                _ => new HashSet<string>()
+            };
+        }
+
+        /// <summary>
+        /// Checks if a tag should be exported to Databricks.
+        /// </summary>
+        public static bool ShouldExportToDatabricks(TelemetryEventType 
eventType, string tagName)

Review Comment:
   While it's difficult to get a sense for how this code will be used before 
it's integrated with the rest of the code, it looks like this is probably the 
primary entry point to the list of tags. If I say something like 
`ShouldExportToDatabricks(TelemetryEventType.Error, "tag1") || 
ShouldExportToDatabricks(TelemetryEventType.Error, "tag2")` then the current 
code will end up instantiating the same `HashSet<string>` twice -- once per 
call to `ShouldExportToDatabricks`. If this is only called fairly rarely, then 
maybe that's not a big deal. But if this is going to be called fairly 
frequently then it probably makes more sense to cache the `HashSet<string>` as 
a static inside each class rather than instantiating a new one each time.



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

To unsubscribe, e-mail: [email protected]

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

Reply via email to