Limit character set according to spec (#3821)

This commit is contained in:
Michael Maxwell 2022-10-27 20:55:05 -07:00 committed by GitHub
parent 9b372023a9
commit 1a65aec968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -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.

View File

@ -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()
{

View File

@ -28,6 +28,7 @@ namespace OpenTelemetry.Metrics.Tests
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
@ -39,6 +40,7 @@ namespace OpenTelemetry.Metrics.Tests
new object[] { "my.metric" },
new object[] { "my_metric2" },
new object[] { new string('m', 63) },
new object[] { "CaSe-InSeNsItIvE" },
};
public static IEnumerable<object[]> InvalidHistogramBoundaries