From d0cec10fae1188c8e432af0894030b99f0fc3804 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Mon, 27 Mar 2023 16:03:36 -0700 Subject: [PATCH] [GenevaExporter] Remove extra table name mapping validation (#1109) --- .../GenevaExporterOptions.cs | 3 +- .../Internal/TableNameSerializer.cs | 40 ------------------- .../GenevaLogExporterTests.cs | 1 + 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs b/src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs index 3af00bb09c..5d781ec8ac 100644 --- a/src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs +++ b/src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs @@ -62,6 +62,7 @@ public IReadOnlyDictionary TableNameMappings throw new ArgumentException($"The table name mapping value '{entry.Value}' provided for key '{entry.Key}' contained non-ASCII characters.", nameof(this.TableNameMappings)); } + /* Note: Validation disabled because it broke previously released versions. if (entry.Value != "*") { if (!TableNameSerializer.IsValidTableName(entry.Value)) @@ -73,7 +74,7 @@ public IReadOnlyDictionary TableNameMappings { throw new ArgumentException($"The table name mapping value '{entry.Value}' provided for key '{entry.Key}' is reserved and cannot be specified.", nameof(this.TableNameMappings)); } - } + }*/ copy[entry.Key] = entry.Value; } diff --git a/src/OpenTelemetry.Exporter.Geneva/Internal/TableNameSerializer.cs b/src/OpenTelemetry.Exporter.Geneva/Internal/TableNameSerializer.cs index 0996827a48..f22ff8336b 100644 --- a/src/OpenTelemetry.Exporter.Geneva/Internal/TableNameSerializer.cs +++ b/src/OpenTelemetry.Exporter.Geneva/Internal/TableNameSerializer.cs @@ -49,7 +49,6 @@ public TableNameSerializer(GenevaExporterOptions options, string defaultTableNam { Debug.Assert(options != null, "options were null"); Debug.Assert(!string.IsNullOrWhiteSpace(defaultTableName), "defaultEventName was null or whitespace"); - Debug.Assert(IsValidTableName(defaultTableName), "defaultEventName was invalid"); this.m_defaultTableName = BuildStr8BufferForAsciiString(defaultTableName); @@ -83,45 +82,6 @@ public TableNameSerializer(GenevaExporterOptions options, string defaultTableNam } } - public static bool IsReservedTableName(string tableName) - { - Debug.Assert(!string.IsNullOrWhiteSpace(tableName), "tableName was null or whitespace"); - - // TODO: Implement this if needed. - - return false; - } - - public static bool IsValidTableName(string tableName) - { - Debug.Assert(!string.IsNullOrWhiteSpace(tableName), "tableName was null or whitespace"); - - var length = tableName.Length; - if (length > MaxSanitizedCategoryNameLength) - { - return false; - } - - char firstChar = tableName[0]; - if (firstChar < 'A' || firstChar > 'Z') - { - return false; - } - - for (int i = 1; i < length; i++) - { - char cur = tableName[i]; - if ((cur >= 'a' && cur <= 'z') || (cur >= 'A' && cur <= 'Z') || (cur >= '0' && cur <= '9')) - { - continue; - } - - return false; - } - - return true; - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public int ResolveAndSerializeTableNameForCategoryName(byte[] destination, int offset, string categoryName, out ReadOnlySpan tableName) { diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs index ad823c1b12..04f3c055db 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs @@ -135,6 +135,7 @@ public void IncompatibleConnectionString_Linux() [InlineData("categoryB", "TableB")] [InlineData("categoryA", "TableA", "categoryB", "TableB")] [InlineData("categoryA", "TableA", "*", "CatchAll")] + [InlineData("Example.DefaultService", "myTableName")] [InlineData(null)] public void TableNameMappingTest(params string[] category) {