Skip to content

Commit

Permalink
Allowing tags to start with _ (#5478)
Browse files Browse the repository at this point in the history
* 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 _

* Adding test that checks if a tag can start with _
  • Loading branch information
carolineRe13 authored Oct 10, 2024
1 parent 9ea3e76 commit b4734e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Generators/Microsoft.Gen.Metrics/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/Generators/Microsoft.Gen.Metrics/Unit/ParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}");

Expand Down

0 comments on commit b4734e2

Please sign in to comment.