Skip to content

Commit 43a0aeb

Browse files
CodeBlanchKielek
andauthored
[onecollector] Prevent event full name mappings with "namespace.*" form (open-telemetry#2043)
Co-authored-by: Piotr Kiełkowicz <[email protected]>
1 parent 8606d7d commit 43a0aeb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/OpenTelemetry.Exporter.OneCollector/Internal/EventFullName.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,9 @@ internal void Validate(string key)
8686
throw new OneCollectorExporterValidationException($"The event full name mapping value provided for key '{key}' is shorter or longer than what is allowed.");
8787
}
8888
}
89+
else if (this.EventNamespace.Length != 0)
90+
{
91+
throw new OneCollectorExporterValidationException($"The event full name mapping value provided for key '{key}' has an invalid wild card pattern.");
92+
}
8993
}
9094
}

test/OpenTelemetry.Exporter.OneCollector.Tests/OneCollectorLogExporterOptionsTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,14 @@ public void ValidDefaultEventFullNameTests(string defaultEventNamespace, string
109109
[InlineData("Prefix", "ABC")]
110110
[InlineData("Prefix", "_.EventName")]
111111
[InlineData("Prefix", "Namespace.Event_Name")]
112+
[InlineData("Prefix", "Event_Name")]
112113
[InlineData("Prefix", "Namespace.")]
114+
[InlineData("Prefix", ".")]
113115
[InlineData("*", "*.EventName")]
114116
[InlineData("*", "*.*")]
117+
[InlineData("*", "Namespace.*")]
118+
[InlineData("Valid", "Invalid*")]
119+
[InlineData("Valid", "In*valid")]
115120
public void InvalidEventFullNameMappingTests(string key, string? value)
116121
{
117122
var options = new OneCollectorLogExporterOptions()
@@ -129,9 +134,14 @@ public void InvalidEventFullNameMappingTests(string key, string? value)
129134

130135
[Theory]
131136
[InlineData("*", "ABCD")]
137+
[InlineData("Some.Prefix", "ABCD")]
132138
[InlineData("*", "A.BC")]
139+
[InlineData("Some.Prefix", "A.BC")]
133140
[InlineData("*", "A.B.C")]
141+
[InlineData("Some.Prefix", "A.B.C")]
134142
[InlineData("*", "*")]
143+
[InlineData("Some.Prefix", "*")]
144+
[InlineData("Some_Name", "New.Name")]
135145
public void ValidEventFullNameMappingTests(string key, string? value)
136146
{
137147
var options = new OneCollectorLogExporterOptions()

0 commit comments

Comments
 (0)