Skip to content

Commit

Permalink
Lazily create AspNetMetrics
Browse files Browse the repository at this point in the history
Create `AspNetMetrics` in the func to remove code analysis warning.
  • Loading branch information
martincostello committed Feb 7, 2023
1 parent 1397add commit f3864e3
Showing 1 changed file with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit f3864e3

Please sign in to comment.