diff --git a/src/OpenTelemetry.Instrumentation.AspNet/MeterProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.AspNet/MeterProviderBuilderExtensions.cs index 48c23efd61..2b2b6cf3cc 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/MeterProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/MeterProviderBuilderExtensions.cs @@ -34,10 +34,7 @@ public static MeterProviderBuilder AddAspNetInstrumentation( { Guard.ThrowIfNull(builder); -#pragma warning disable CA2000 // Dispose objects before losing scope - var instrumentation = new AspNetMetrics(); -#pragma warning restore CA2000 // Dispose objects before losing scope builder.AddMeter(AspNetMetrics.InstrumentationName); - return builder.AddInstrumentation(() => instrumentation); + return builder.AddInstrumentation(() => new AspNetMetrics()); } }