From 15ebf6c081106bd93b7c1c999b10a0bb0d70f7ff Mon Sep 17 00:00:00 2001 From: carolineRe13 <60150268+carolineRe13@users.noreply.github.com> Date: Tue, 8 Oct 2024 15:31:05 +0200 Subject: [PATCH 1/2] Allowing namespaces to start with _ Making it possible for namespaces to start with _. This is necessary to use OT exporter as it requires namespace overrides to start with _ --- src/Generators/Microsoft.Gen.Metrics/Parser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/Microsoft.Gen.Metrics/Parser.cs b/src/Generators/Microsoft.Gen.Metrics/Parser.cs index b9d5697e24e..da05c6a51ec 100644 --- a/src/Generators/Microsoft.Gen.Metrics/Parser.cs +++ b/src/Generators/Microsoft.Gen.Metrics/Parser.cs @@ -22,7 +22,7 @@ internal sealed class Parser private const int MaxTagNames = 30; private static readonly Regex _regex = new("^[A-Z]+[A-za-z0-9]*$", RegexOptions.Compiled); - private static readonly Regex _regexTagNames = new("^[A-Za-z]+[A-Za-z0-9_.:-]*$", RegexOptions.Compiled); + private static readonly Regex _regexTagNames = new("^[A-Za-z_]+[A-Za-z0-9_.:-]*$", RegexOptions.Compiled); private static readonly SymbolDisplayFormat _typeSymbolFormat = SymbolDisplayFormat.FullyQualifiedFormat.WithMiscellaneousOptions( SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier); From 17fd8467ac05f4859ce18d8b163867d9d46398a6 Mon Sep 17 00:00:00 2001 From: carolineRe13 <60150268+carolineRe13@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:28:39 +0200 Subject: [PATCH 2/2] Adding test that checks if a tag can start with _ --- test/Generators/Microsoft.Gen.Metrics/Unit/ParserTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Generators/Microsoft.Gen.Metrics/Unit/ParserTests.cs b/test/Generators/Microsoft.Gen.Metrics/Unit/ParserTests.cs index 865315511f6..d6496ac10f3 100644 --- a/test/Generators/Microsoft.Gen.Metrics/Unit/ParserTests.cs +++ b/test/Generators/Microsoft.Gen.Metrics/Unit/ParserTests.cs @@ -144,7 +144,7 @@ public async Task ValidDimensionsKeyNames() var d = await RunGenerator(@" partial class C { - [Counter(""Env.Name"", ""clustr:region"", ""Req_Name"", ""Req-Status"")] + [Counter(""Env.Name"", ""clustr:region"", ""Req_Name"", ""Req-Status"", ""_microsoft_metrics_namespace"")] static partial TestCounter CreateMetricName(Meter meter, string env, string region); }");