Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit character set according to spec #3821

Merged
merged 4 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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