Skip to content

Commit

Permalink
Limit character set according to spec (#3821)
Browse files Browse the repository at this point in the history
  • Loading branch information
mic-max committed Oct 28, 2022
1 parent 9b37202 commit 1a65aec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Fix instrument naming enforcement implementation to match the spec.
([#3821](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3821))

* Added support for loading environment variables from `IConfiguration` when
using the `MetricReaderOptions` & `BatchExportActivityProcessorOptions`
classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace OpenTelemetry.Metrics
internal sealed class MeterProviderBuilderSdk : MeterProviderBuilderBase
{
private static readonly Regex InstrumentNameRegex = new(
@"^[a-zA-Z][-.\w]{0,62}$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
@"^[a-z][a-z0-9-._]{0,62}$", RegexOptions.IgnoreCase | RegexOptions.Compiled);

public MeterProviderBuilderSdk()
{
Expand Down
2 changes: 2 additions & 0 deletions test/OpenTelemetry.Tests/Metrics/MetricTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static IEnumerable<object[]> InvalidInstrumentNames
new object[] { "1first-char-not-alphabetic" },
new object[] { "invalid+separator" },
new object[] { new string('m', 64) },
new object[] { "a\xb5" }, // `\xb5` is the Micro character
};

public static IEnumerable<object[]> ValidInstrumentNames
Expand All @@ -39,6 +40,7 @@ public static IEnumerable<object[]> ValidInstrumentNames
new object[] { "my.metric" },
new object[] { "my_metric2" },
new object[] { new string('m', 63) },
new object[] { "CaSe-InSeNsItIvE" },
};

public static IEnumerable<object[]> InvalidHistogramBoundaries
Expand Down

0 comments on commit 1a65aec

Please sign in to comment.