Skip to content

Commit

Permalink
PR review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopgrassi committed Oct 8, 2021
1 parent f558e37 commit 465af0e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/MeterProviderBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static MeterProviderBuilder AddReader(this MeterProviderBuilder meterProv
public static MeterProviderBuilder AddView(this MeterProviderBuilder meterProviderBuilder, string instrumentName, string name)
{
// we only need to validate the custom view name in case something was actually provided
if (!string.IsNullOrWhiteSpace(name) && !MeterProviderBuilderSdk.ViewNameValid(name))
if (!string.IsNullOrWhiteSpace(name) && !MeterProviderBuilderSdk.IsViewNameValid(name))
{
throw new ArgumentException($"Custom view name {name} is invalid.", nameof(name));
}
Expand All @@ -78,7 +78,7 @@ public static MeterProviderBuilder AddView(this MeterProviderBuilder meterProvid
public static MeterProviderBuilder AddView(this MeterProviderBuilder meterProviderBuilder, string instrumentName, MetricStreamConfiguration metricStreamConfiguration)
{
// we only need to validate the custom view name in case something was actually provided
if (!string.IsNullOrWhiteSpace(metricStreamConfiguration.Name) && !MeterProviderBuilderSdk.ViewNameValid(metricStreamConfiguration.Name))
if (!string.IsNullOrWhiteSpace(metricStreamConfiguration.Name) && !MeterProviderBuilderSdk.IsViewNameValid(metricStreamConfiguration.Name))
{
throw new ArgumentException($"Custom view name {metricStreamConfiguration.Name} is invalid.", nameof(metricStreamConfiguration.Name));
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/MeterProviderBuilderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class MeterProviderBuilderSdk : MeterProviderBuilderBase
/// <remarks>See specification: <see href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument"/>.</remarks>
/// <param name="instrumentName">The instrument name.</param>
/// <returns>Boolean indicating if the instrument is valid.</returns>
internal static bool InstrumentNameValid(string instrumentName)
internal static bool IsInstrumentNameValid(string instrumentName)
{
if (string.IsNullOrWhiteSpace(instrumentName))
{
Expand All @@ -45,7 +45,7 @@ internal static bool InstrumentNameValid(string instrumentName)
/// <remarks>See specification: <see href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument"/>.</remarks>
/// <param name="customViewName">The view name.</param>
/// <returns>Boolean indicating if the instrument is valid.</returns>
internal static bool ViewNameValid(string customViewName)
internal static bool IsViewNameValid(string customViewName)
{
return InstrumentNameRegex.IsMatch(customViewName);
}
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/MeterProviderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ internal MeterProviderSdk(
var metricStreamConfig = metricStreamConfigs[i];
var metricStreamName = metricStreamConfig?.Name ?? instrument.Name;

if (!MeterProviderBuilderSdk.InstrumentNameValid(metricStreamName))
if (!MeterProviderBuilderSdk.IsInstrumentNameValid(metricStreamName))
{
OpenTelemetrySdkEventSource.Log.MetricInstrumentIgnored(instrument.Name, instrument.Meter.Name, "Metric name is invalid.", "The name must comply with the OpenTelemetry specification: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument");
continue;
Expand Down Expand Up @@ -206,7 +206,7 @@ internal MeterProviderSdk(
{
try
{
if (!MeterProviderBuilderSdk.InstrumentNameValid(instrument.Name))
if (!MeterProviderBuilderSdk.IsInstrumentNameValid(instrument.Name))
{
OpenTelemetrySdkEventSource.Log.MetricInstrumentIgnored(instrument.Name, instrument.Meter.Name, "Metric name is invalid.", "The name must comply with the OpenTelemetry specification: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument");
return;
Expand Down
2 changes: 1 addition & 1 deletion test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void ViewToRenameMetricConditionally()
}

[Theory]
[MemberData(nameof(MetricsTestData.InvalidInstrumentNames), MemberType = typeof(MetricsTestData))]
[MemberData(nameof(MetricsTestData.InvalidViewNames), MemberType = typeof(MetricsTestData))]
public void ViewWithInvalidNameIgnoredConditionally(string viewNewName)
{
using var meter1 = new Meter("ViewToRenameMetricConditionallyTest");
Expand Down

0 comments on commit 465af0e

Please sign in to comment.