From 59f8b2372325de5b25432d4d0ce0c21e177a3869 Mon Sep 17 00:00:00 2001 From: Sreekanth Vadigi Date: Thu, 30 Oct 2025 16:00:29 +0530 Subject: [PATCH 1/2] feat(csharp/src/Drivers/Databricks): Implement telemetry tag definitions (phase 1) --- .../TagDefinitions/ConnectionOpenEvent.cs | 85 ++++++++++++++++++ .../Telemetry/TagDefinitions/ErrorEvent.cs | 70 +++++++++++++++ .../TagDefinitions/StatementExecutionEvent.cs | 89 +++++++++++++++++++ .../TagDefinitions/TelemetryEventType.cs | 44 +++++++++ .../Telemetry/TagDefinitions/TelemetryTag.cs | 51 +++++++++++ .../TagDefinitions/TelemetryTagRegistry.cs | 53 +++++++++++ .../Telemetry/TelemetryTagRegistryTests.cs | 52 +++++++++++ 7 files changed, 444 insertions(+) create mode 100644 csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ConnectionOpenEvent.cs create mode 100644 csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ErrorEvent.cs create mode 100644 csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/StatementExecutionEvent.cs create mode 100644 csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryEventType.cs create mode 100644 csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTag.cs create mode 100644 csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs create mode 100644 csharp/test/Drivers/Databricks/Unit/Telemetry/TelemetryTagRegistryTests.cs diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ConnectionOpenEvent.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ConnectionOpenEvent.cs new file mode 100644 index 0000000000..b43af29dee --- /dev/null +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ConnectionOpenEvent.cs @@ -0,0 +1,85 @@ +/* + * 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; + +namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions +{ + /// + /// Tag definitions for Connection.Open events. + /// + internal static class ConnectionOpenEvent + { + public const string EventName = "Connection.Open"; + + // Identity + [TelemetryTag("workspace.id", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Workspace ID")] + public const string WorkspaceId = "workspace.id"; + + [TelemetryTag("session.id", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Session ID")] + public const string SessionId = "session.id"; + + // Driver Configuration + [TelemetryTag("driver.version", ExportScope = TagExportScope.ExportAll, Description = "Driver version")] + public const string DriverVersion = "driver.version"; + + [TelemetryTag("driver.os", ExportScope = TagExportScope.ExportAll, Description = "Operating system")] + public const string DriverOS = "driver.os"; + + [TelemetryTag("driver.runtime", ExportScope = TagExportScope.ExportAll, Description = ".NET runtime")] + public const string DriverRuntime = "driver.runtime"; + + // Feature Flags + [TelemetryTag("feature.cloudfetch", ExportScope = TagExportScope.ExportDatabricks, Description = "CloudFetch enabled")] + public const string FeatureCloudFetch = "feature.cloudfetch"; + + [TelemetryTag("feature.lz4", ExportScope = TagExportScope.ExportDatabricks, Description = "LZ4 compression enabled")] + public const string FeatureLz4 = "feature.lz4"; + + [TelemetryTag("feature.direct_results", ExportScope = TagExportScope.ExportDatabricks, Description = "Direct results enabled")] + public const string FeatureDirectResults = "feature.direct_results"; + + [TelemetryTag("feature.multiple_catalog", ExportScope = TagExportScope.ExportDatabricks, Description = "Multiple catalog enabled")] + public const string FeatureMultipleCatalog = "feature.multiple_catalog"; + + [TelemetryTag("feature.trace_propagation", ExportScope = TagExportScope.ExportDatabricks, Description = "Trace propagation enabled")] + public const string FeatureTracePropagation = "feature.trace_propagation"; + + [TelemetryTag("server.address", ExportScope = TagExportScope.ExportLocal, Description = "Server address")] + public const string ServerAddress = "server.address"; + + /// + /// Returns tags allowed for Databricks export (privacy filter). + /// + public static IReadOnlyCollection GetDatabricksExportTags() + { + return new HashSet + { + WorkspaceId, + SessionId, + DriverVersion, + DriverOS, + DriverRuntime, + FeatureCloudFetch, + FeatureLz4, + FeatureDirectResults, + FeatureMultipleCatalog, + FeatureTracePropagation + }; + } + } +} diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ErrorEvent.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ErrorEvent.cs new file mode 100644 index 0000000000..5db4c91971 --- /dev/null +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ErrorEvent.cs @@ -0,0 +1,70 @@ +/* + * 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; + +namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions +{ + /// + /// Tag definitions for Error events. + /// + internal static class ErrorEvent + { + public const string EventName = "Error"; + + // Error Classification + [TelemetryTag("error.type", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Error type")] + public const string ErrorType = "error.type"; + + [TelemetryTag("http.status_code", ExportScope = TagExportScope.ExportDatabricks, Description = "HTTP status code")] + public const string HttpStatusCode = "http.status_code"; + + [TelemetryTag("db.sql_state", ExportScope = TagExportScope.ExportDatabricks, Description = "SQL state")] + public const string DbSqlState = "db.sql_state"; + + [TelemetryTag("error.operation", ExportScope = TagExportScope.ExportDatabricks, Description = "Failed operation")] + public const string ErrorOperation = "error.operation"; + + [TelemetryTag("error.retried", ExportScope = TagExportScope.ExportDatabricks, Description = "Was retried")] + public const string ErrorRetried = "error.retried"; + + [TelemetryTag("error.retry_count", ExportScope = TagExportScope.ExportDatabricks, Description = "Retry count")] + public const string ErrorRetryCount = "error.retry_count"; + + [TelemetryTag("error.message", ExportScope = TagExportScope.ExportLocal, Description = "Error message")] + public const string ErrorMessage = "error.message"; + + [TelemetryTag("error.stack_trace", ExportScope = TagExportScope.ExportLocal, Description = "Stack trace")] + public const string ErrorStackTrace = "error.stack_trace"; + + /// + /// Returns tags allowed for Databricks export (privacy filter). + /// + public static IReadOnlyCollection GetDatabricksExportTags() + { + return new HashSet + { + ErrorType, + HttpStatusCode, + DbSqlState, + ErrorOperation, + ErrorRetried, + ErrorRetryCount + }; + } + } +} diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/StatementExecutionEvent.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/StatementExecutionEvent.cs new file mode 100644 index 0000000000..64089ba0ae --- /dev/null +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/StatementExecutionEvent.cs @@ -0,0 +1,89 @@ +/* + * 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; + +namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions +{ + /// + /// Tag definitions for Statement execution events. + /// + internal static class StatementExecutionEvent + { + public const string EventName = "Statement.Execute"; + + // Identity + [TelemetryTag("statement.id", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Statement ID")] + public const string StatementId = "statement.id"; + + [TelemetryTag("session.id", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Session ID")] + public const string SessionId = "session.id"; + + // Result Metrics + [TelemetryTag("result.format", ExportScope = TagExportScope.ExportDatabricks, Description = "Result format")] + public const string ResultFormat = "result.format"; + + [TelemetryTag("result.chunk_count", ExportScope = TagExportScope.ExportDatabricks, Description = "Chunk count")] + public const string ResultChunkCount = "result.chunk_count"; + + [TelemetryTag("result.bytes_downloaded", ExportScope = TagExportScope.ExportDatabricks, Description = "Bytes downloaded")] + public const string ResultBytesDownloaded = "result.bytes_downloaded"; + + [TelemetryTag("result.compression_enabled", ExportScope = TagExportScope.ExportDatabricks, Description = "Compression enabled")] + public const string ResultCompressionEnabled = "result.compression_enabled"; + + [TelemetryTag("result.row_count", ExportScope = TagExportScope.ExportDatabricks, Description = "Row count")] + public const string ResultRowCount = "result.row_count"; + + // Polling Metrics + [TelemetryTag("poll.count", ExportScope = TagExportScope.ExportDatabricks, Description = "Poll count")] + public const string PollCount = "poll.count"; + + [TelemetryTag("poll.latency_ms", ExportScope = TagExportScope.ExportDatabricks, Description = "Poll latency")] + public const string PollLatencyMs = "poll.latency_ms"; + + // Operation Type + [TelemetryTag("db.operation", ExportScope = TagExportScope.ExportDatabricks, Description = "Operation type")] + public const string DbOperation = "db.operation"; + + [TelemetryTag("db.statement", ExportScope = TagExportScope.ExportLocal, Description = "SQL statement")] + public const string DbStatement = "db.statement"; + + [TelemetryTag("db.catalog", ExportScope = TagExportScope.ExportLocal, Description = "Catalog name")] + public const string DbCatalog = "db.catalog"; + + [TelemetryTag("db.schema", ExportScope = TagExportScope.ExportLocal, Description = "Schema name")] + public const string DbSchema = "db.schema"; + + public static IReadOnlyCollection GetDatabricksExportTags() + { + return new HashSet + { + StatementId, + SessionId, + ResultFormat, + ResultChunkCount, + ResultBytesDownloaded, + ResultCompressionEnabled, + ResultRowCount, + PollCount, + PollLatencyMs, + DbOperation + }; + } + } +} diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryEventType.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryEventType.cs new file mode 100644 index 0000000000..93ffc7b25b --- /dev/null +++ b/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 +{ + /// + /// 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. + /// + public enum TelemetryEventType + { + /// + /// Connection open event. Emitted when a connection is established. + /// Tags defined in: + /// + ConnectionOpen, + + /// + /// Statement execution event. Emitted when a query or statement is executed. + /// Tags defined in: + /// + StatementExecution, + + /// + /// Error event. Emitted when an error occurs during any operation. + /// Tags defined in: + /// + Error + } +} diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTag.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTag.cs new file mode 100644 index 0000000000..842d9bd8a3 --- /dev/null +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTag.cs @@ -0,0 +1,51 @@ +/* + * 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; + +namespace Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions +{ + /// + /// Controls where telemetry tags can be exported. + /// + [Flags] + internal enum TagExportScope + { + None = 0, + ExportLocal = 1, // Local diagnostics only + ExportDatabricks = 2, // Safe for Databricks service + ExportAll = ExportLocal | ExportDatabricks + } + + /// + /// Attribute for defining telemetry tags with export controls. + /// + [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] + internal sealed class TelemetryTagAttribute : Attribute + { + public string TagName { get; } + public TagExportScope ExportScope { get; set; } + public string? Description { get; set; } + public bool Required { get; set; } + + public TelemetryTagAttribute(string tagName) + { + TagName = tagName ?? throw new ArgumentNullException(nameof(tagName)); + ExportScope = TagExportScope.ExportAll; + } + } +} diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs new file mode 100644 index 0000000000..e691ce7853 --- /dev/null +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs @@ -0,0 +1,53 @@ +/* + * 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 + { + /// + /// Gets tags allowed for Databricks export (privacy whitelist). + /// + public static IReadOnlyCollection GetDatabricksExportTags(TelemetryEventType eventType) + { + return eventType switch + { + TelemetryEventType.ConnectionOpen => ConnectionOpenEvent.GetDatabricksExportTags(), + TelemetryEventType.StatementExecution => StatementExecutionEvent.GetDatabricksExportTags(), + TelemetryEventType.Error => ErrorEvent.GetDatabricksExportTags(), + _ => new HashSet() + }; + } + + /// + /// Checks if a tag should be exported to Databricks. + /// + public static bool ShouldExportToDatabricks(TelemetryEventType eventType, string tagName) + { + if (string.IsNullOrEmpty(tagName)) + { + return false; + } + + var allowedTags = GetDatabricksExportTags(eventType); + return allowedTags.Contains(tagName); + } + } +} diff --git a/csharp/test/Drivers/Databricks/Unit/Telemetry/TelemetryTagRegistryTests.cs b/csharp/test/Drivers/Databricks/Unit/Telemetry/TelemetryTagRegistryTests.cs new file mode 100644 index 0000000000..786015649b --- /dev/null +++ b/csharp/test/Drivers/Databricks/Unit/Telemetry/TelemetryTagRegistryTests.cs @@ -0,0 +1,52 @@ +/* +* 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 Apache.Arrow.Adbc.Drivers.Databricks.Telemetry.TagDefinitions; +using Xunit; + +namespace Apache.Arrow.Adbc.Tests.Drivers.Databricks.Unit.Telemetry +{ + public class TelemetryTagRegistryTests + { + [Theory] + [InlineData(TelemetryEventType.StatementExecution, "db.statement")] + [InlineData(TelemetryEventType.ConnectionOpen, "server.address")] + [InlineData(TelemetryEventType.Error, "error.message")] + public void ShouldExportToDatabricks_SensitiveTags_ReturnsFalse(TelemetryEventType eventType, string tagName) + { + var shouldExport = TelemetryTagRegistry.ShouldExportToDatabricks(eventType, tagName); + Assert.False(shouldExport); + } + + [Theory] + [InlineData(TelemetryEventType.ConnectionOpen, "workspace.id")] + [InlineData(TelemetryEventType.StatementExecution, "result.chunk_count")] + [InlineData(TelemetryEventType.Error, "error.type")] + public void ShouldExportToDatabricks_NonSensitiveTags_ReturnsTrue(TelemetryEventType eventType, string tagName) + { + var shouldExport = TelemetryTagRegistry.ShouldExportToDatabricks(eventType, tagName); + Assert.True(shouldExport); + } + + [Fact] + public void GetDatabricksExportTags_UnknownEventType_ReturnsEmpty() + { + var tags = TelemetryTagRegistry.GetDatabricksExportTags((TelemetryEventType)999); + Assert.Empty(tags); + } + } +} From a9439d642a45439ff89d5eab1669ccda87be822d Mon Sep 17 00:00:00 2001 From: Sreekanth Vadigi Date: Fri, 31 Oct 2025 14:39:15 +0530 Subject: [PATCH 2/2] default export local tag in constructor and export all scope for defined tags --- .../TagDefinitions/ConnectionOpenEvent.cs | 14 ++++++------- .../Telemetry/TagDefinitions/ErrorEvent.cs | 12 +++++------ .../TagDefinitions/StatementExecutionEvent.cs | 20 +++++++++---------- .../Telemetry/TagDefinitions/TelemetryTag.cs | 2 +- .../TagDefinitions/TelemetryTagRegistry.cs | 1 + 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ConnectionOpenEvent.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ConnectionOpenEvent.cs index b43af29dee..d9839f1b52 100644 --- a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ConnectionOpenEvent.cs +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ConnectionOpenEvent.cs @@ -27,10 +27,10 @@ internal static class ConnectionOpenEvent public const string EventName = "Connection.Open"; // Identity - [TelemetryTag("workspace.id", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Workspace ID")] + [TelemetryTag("workspace.id", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Workspace ID")] public const string WorkspaceId = "workspace.id"; - [TelemetryTag("session.id", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Session ID")] + [TelemetryTag("session.id", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Session ID")] public const string SessionId = "session.id"; // Driver Configuration @@ -44,19 +44,19 @@ internal static class ConnectionOpenEvent public const string DriverRuntime = "driver.runtime"; // Feature Flags - [TelemetryTag("feature.cloudfetch", ExportScope = TagExportScope.ExportDatabricks, Description = "CloudFetch enabled")] + [TelemetryTag("feature.cloudfetch", ExportScope = TagExportScope.ExportAll, Description = "CloudFetch enabled")] public const string FeatureCloudFetch = "feature.cloudfetch"; - [TelemetryTag("feature.lz4", ExportScope = TagExportScope.ExportDatabricks, Description = "LZ4 compression enabled")] + [TelemetryTag("feature.lz4", ExportScope = TagExportScope.ExportAll, Description = "LZ4 compression enabled")] public const string FeatureLz4 = "feature.lz4"; - [TelemetryTag("feature.direct_results", ExportScope = TagExportScope.ExportDatabricks, Description = "Direct results enabled")] + [TelemetryTag("feature.direct_results", ExportScope = TagExportScope.ExportAll, Description = "Direct results enabled")] public const string FeatureDirectResults = "feature.direct_results"; - [TelemetryTag("feature.multiple_catalog", ExportScope = TagExportScope.ExportDatabricks, Description = "Multiple catalog enabled")] + [TelemetryTag("feature.multiple_catalog", ExportScope = TagExportScope.ExportAll, Description = "Multiple catalog enabled")] public const string FeatureMultipleCatalog = "feature.multiple_catalog"; - [TelemetryTag("feature.trace_propagation", ExportScope = TagExportScope.ExportDatabricks, Description = "Trace propagation enabled")] + [TelemetryTag("feature.trace_propagation", ExportScope = TagExportScope.ExportAll, Description = "Trace propagation enabled")] public const string FeatureTracePropagation = "feature.trace_propagation"; [TelemetryTag("server.address", ExportScope = TagExportScope.ExportLocal, Description = "Server address")] diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ErrorEvent.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ErrorEvent.cs index 5db4c91971..7cd9194e41 100644 --- a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ErrorEvent.cs +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/ErrorEvent.cs @@ -27,22 +27,22 @@ internal static class ErrorEvent public const string EventName = "Error"; // Error Classification - [TelemetryTag("error.type", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Error type")] + [TelemetryTag("error.type", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Error type")] public const string ErrorType = "error.type"; - [TelemetryTag("http.status_code", ExportScope = TagExportScope.ExportDatabricks, Description = "HTTP status code")] + [TelemetryTag("http.status_code", ExportScope = TagExportScope.ExportAll, Description = "HTTP status code")] public const string HttpStatusCode = "http.status_code"; - [TelemetryTag("db.sql_state", ExportScope = TagExportScope.ExportDatabricks, Description = "SQL state")] + [TelemetryTag("db.sql_state", ExportScope = TagExportScope.ExportAll, Description = "SQL state")] public const string DbSqlState = "db.sql_state"; - [TelemetryTag("error.operation", ExportScope = TagExportScope.ExportDatabricks, Description = "Failed operation")] + [TelemetryTag("error.operation", ExportScope = TagExportScope.ExportAll, Description = "Failed operation")] public const string ErrorOperation = "error.operation"; - [TelemetryTag("error.retried", ExportScope = TagExportScope.ExportDatabricks, Description = "Was retried")] + [TelemetryTag("error.retried", ExportScope = TagExportScope.ExportAll, Description = "Was retried")] public const string ErrorRetried = "error.retried"; - [TelemetryTag("error.retry_count", ExportScope = TagExportScope.ExportDatabricks, Description = "Retry count")] + [TelemetryTag("error.retry_count", ExportScope = TagExportScope.ExportAll, Description = "Retry count")] public const string ErrorRetryCount = "error.retry_count"; [TelemetryTag("error.message", ExportScope = TagExportScope.ExportLocal, Description = "Error message")] diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/StatementExecutionEvent.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/StatementExecutionEvent.cs index 64089ba0ae..9998e94d3e 100644 --- a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/StatementExecutionEvent.cs +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/StatementExecutionEvent.cs @@ -27,37 +27,37 @@ internal static class StatementExecutionEvent public const string EventName = "Statement.Execute"; // Identity - [TelemetryTag("statement.id", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Statement ID")] + [TelemetryTag("statement.id", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Statement ID")] public const string StatementId = "statement.id"; - [TelemetryTag("session.id", ExportScope = TagExportScope.ExportDatabricks, Required = true, Description = "Session ID")] + [TelemetryTag("session.id", ExportScope = TagExportScope.ExportAll, Required = true, Description = "Session ID")] public const string SessionId = "session.id"; // Result Metrics - [TelemetryTag("result.format", ExportScope = TagExportScope.ExportDatabricks, Description = "Result format")] + [TelemetryTag("result.format", ExportScope = TagExportScope.ExportAll, Description = "Result format")] public const string ResultFormat = "result.format"; - [TelemetryTag("result.chunk_count", ExportScope = TagExportScope.ExportDatabricks, Description = "Chunk count")] + [TelemetryTag("result.chunk_count", ExportScope = TagExportScope.ExportAll, Description = "Chunk count")] public const string ResultChunkCount = "result.chunk_count"; - [TelemetryTag("result.bytes_downloaded", ExportScope = TagExportScope.ExportDatabricks, Description = "Bytes downloaded")] + [TelemetryTag("result.bytes_downloaded", ExportScope = TagExportScope.ExportAll, Description = "Bytes downloaded")] public const string ResultBytesDownloaded = "result.bytes_downloaded"; - [TelemetryTag("result.compression_enabled", ExportScope = TagExportScope.ExportDatabricks, Description = "Compression enabled")] + [TelemetryTag("result.compression_enabled", ExportScope = TagExportScope.ExportAll, Description = "Compression enabled")] public const string ResultCompressionEnabled = "result.compression_enabled"; - [TelemetryTag("result.row_count", ExportScope = TagExportScope.ExportDatabricks, Description = "Row count")] + [TelemetryTag("result.row_count", ExportScope = TagExportScope.ExportAll, Description = "Row count")] public const string ResultRowCount = "result.row_count"; // Polling Metrics - [TelemetryTag("poll.count", ExportScope = TagExportScope.ExportDatabricks, Description = "Poll count")] + [TelemetryTag("poll.count", ExportScope = TagExportScope.ExportAll, Description = "Poll count")] public const string PollCount = "poll.count"; - [TelemetryTag("poll.latency_ms", ExportScope = TagExportScope.ExportDatabricks, Description = "Poll latency")] + [TelemetryTag("poll.latency_ms", ExportScope = TagExportScope.ExportAll, Description = "Poll latency")] public const string PollLatencyMs = "poll.latency_ms"; // Operation Type - [TelemetryTag("db.operation", ExportScope = TagExportScope.ExportDatabricks, Description = "Operation type")] + [TelemetryTag("db.operation", ExportScope = TagExportScope.ExportAll, Description = "Operation type")] public const string DbOperation = "db.operation"; [TelemetryTag("db.statement", ExportScope = TagExportScope.ExportLocal, Description = "SQL statement")] diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTag.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTag.cs index 842d9bd8a3..f34e1bf405 100644 --- a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTag.cs +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTag.cs @@ -45,7 +45,7 @@ internal sealed class TelemetryTagAttribute : Attribute public TelemetryTagAttribute(string tagName) { TagName = tagName ?? throw new ArgumentNullException(nameof(tagName)); - ExportScope = TagExportScope.ExportAll; + ExportScope = TagExportScope.ExportLocal; } } } diff --git a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs index e691ce7853..130630fcee 100644 --- a/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs +++ b/csharp/src/Drivers/Databricks/Telemetry/TagDefinitions/TelemetryTagRegistry.cs @@ -25,6 +25,7 @@ public static class TelemetryTagRegistry /// /// Gets tags allowed for Databricks export (privacy whitelist). /// + // TODO: Explore alternate approaches to avoid maintaining separate GetDatabricksExportTags methods in each event class. public static IReadOnlyCollection GetDatabricksExportTags(TelemetryEventType eventType) { return eventType switch