diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index e8defa1924b..58f6682bb88 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Fix null reference exception when a metric view does not match an instrument. + ([#3285](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3285)) + ## 1.3.0-beta.2 Released 2022-May-16 diff --git a/src/OpenTelemetry/Metrics/MeterProviderSdk.cs b/src/OpenTelemetry/Metrics/MeterProviderSdk.cs index 7906e27e532..437685f32a4 100644 --- a/src/OpenTelemetry/Metrics/MeterProviderSdk.cs +++ b/src/OpenTelemetry/Metrics/MeterProviderSdk.cs @@ -167,7 +167,7 @@ internal MeterProviderSdk( // The SDK provides some static MetricStreamConfigurations. // For example, the Drop configuration. The static ViewId // should not be changed for these configurations. - if (!metricStreamConfig.ViewId.HasValue) + if (metricStreamConfig != null && !metricStreamConfig.ViewId.HasValue) { metricStreamConfig.ViewId = i; }