Skip to content

Commit

Permalink
[GenevaExporter] Remove extra table name mapping validation (open-tel…
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Mar 29, 2023
1 parent 7f153f1 commit d0cec10
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 41 deletions.
3 changes: 2 additions & 1 deletion src/OpenTelemetry.Exporter.Geneva/GenevaExporterOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public IReadOnlyDictionary<string, string> 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))
Expand All @@ -73,7 +74,7 @@ public IReadOnlyDictionary<string, string> 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;
}
Expand Down
40 changes: 0 additions & 40 deletions src/OpenTelemetry.Exporter.Geneva/Internal/TableNameSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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<byte> tableName)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit d0cec10

Please sign in to comment.