diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/ResourceExtensions.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/ResourceExtensions.cs index b4c24d207a7ce..f38ca549afd76 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/ResourceExtensions.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/ResourceExtensions.cs @@ -123,7 +123,7 @@ internal static class ResourceExtensions try { var exportResource = Environment.GetEnvironmentVariable(EnvironmentVariableConstants.EXPORT_RESOURCE_METRIC); - if (exportResource.Equals("true", StringComparison.OrdinalIgnoreCase)) + if (exportResource != null && exportResource.Equals("true", StringComparison.OrdinalIgnoreCase)) { shouldReportMetricTelemetry = true; }