From 3c35717eb9b68d026db9f2991c1de666253e8696 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Wed, 24 May 2023 12:00:52 +0000 Subject: [PATCH 01/10] Update dependencies from https://github.com/dotnet/runtime build 20230524.1 Microsoft.Bcl.AsyncInterfaces , Microsoft.Extensions.Caching.Abstractions , Microsoft.Extensions.Caching.Memory , Microsoft.Extensions.Configuration , Microsoft.Extensions.Configuration.Abstractions , Microsoft.Extensions.Configuration.Binder , Microsoft.Extensions.Configuration.CommandLine , Microsoft.Extensions.Configuration.EnvironmentVariables , Microsoft.Extensions.Configuration.FileExtensions , Microsoft.Extensions.Configuration.Ini , Microsoft.Extensions.Configuration.Json , Microsoft.Extensions.Configuration.UserSecrets , Microsoft.Extensions.Configuration.Xml , Microsoft.Extensions.DependencyInjection , Microsoft.Extensions.DependencyInjection.Abstractions , Microsoft.Extensions.DependencyModel , Microsoft.Extensions.FileProviders.Abstractions , Microsoft.Extensions.FileProviders.Composite , Microsoft.Extensions.FileProviders.Physical , Microsoft.Extensions.FileSystemGlobbing , Microsoft.Extensions.HostFactoryResolver.Sources , Microsoft.Extensions.Hosting , Microsoft.Extensions.Hosting.Abstractions , Microsoft.Extensions.Http , Microsoft.Extensions.Logging , Microsoft.Extensions.Logging.Abstractions , Microsoft.Extensions.Logging.Configuration , Microsoft.Extensions.Logging.Console , Microsoft.Extensions.Logging.Debug , Microsoft.Extensions.Logging.EventLog , Microsoft.Extensions.Logging.EventSource , Microsoft.Extensions.Logging.TraceSource , Microsoft.Extensions.Options , Microsoft.Extensions.Options.ConfigurationExtensions , Microsoft.Extensions.Options.DataAnnotations , Microsoft.Extensions.Primitives , Microsoft.Internal.Runtime.AspNetCore.Transport , Microsoft.NET.Runtime.MonoAOTCompiler.Task , Microsoft.NET.Runtime.WebAssembly.Sdk , Microsoft.NETCore.App.Ref , Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.BrowserDebugHost.Transport , Microsoft.NETCore.Platforms , System.Configuration.ConfigurationManager , System.Diagnostics.DiagnosticSource , System.Diagnostics.EventLog , System.DirectoryServices.Protocols , System.IO.Pipelines , System.Net.Http.Json , System.Net.Http.WinHttpHandler , System.Reflection.Metadata , System.Resources.Extensions , System.Security.Cryptography.Pkcs , System.Security.Cryptography.Xml , System.Security.Permissions , System.ServiceProcess.ServiceController , System.Text.Encodings.Web , System.Text.Json , System.Threading.AccessControl , System.Threading.Channels , System.Threading.RateLimiting From Version 8.0.0-preview.5.23273.1 -> To Version 8.0.0-preview.5.23274.1 --- eng/Version.Details.xml | 248 ++++++++++++++++++++-------------------- eng/Versions.props | 124 ++++++++++---------- 2 files changed, 186 insertions(+), 186 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 5bf2d93ee5c3..d2bc4e47b03c 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -41,259 +41,259 @@ https://github.com/dotnet/efcore d3362f65007769fd1c8ef442743832d91c7a34cb - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 https://github.com/dotnet/source-build-externals 21d564f9e16f7986d8af0692258afb91a52dda80 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 https://github.com/dotnet/xdt @@ -326,9 +326,9 @@ - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 https://github.com/dotnet/arcade diff --git a/eng/Versions.props b/eng/Versions.props index 0bdde4945282..73f4c57ca800 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -63,69 +63,69 @@ --> - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23273.1 - 8.0.0-preview.5.23273.1 + 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 8.0.0-preview.6.23273.4 8.0.0-preview.6.23273.4 From d09780860568982621e1286d409b9d0a418d30ed Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 24 May 2023 13:38:39 +0800 Subject: [PATCH 02/10] Use Microsoft.Extensions.Diaganostics --- eng/Dependencies.props | 1 + eng/Version.Details.xml | 4 + eng/Versions.props | 1 + .../src/GenericHost/GenericWebHostBuilder.cs | 1 + .../src/GenericHost/SlimWebHostBuilder.cs | 1 + .../Hosting/src/Internal/HostingMetrics.cs | 4 +- .../src/Microsoft.AspNetCore.Hosting.csproj | 1 + src/Hosting/Hosting/src/WebHostBuilder.cs | 1 + .../HostingApplicationDiagnosticsTests.cs | 14 +-- .../Hosting/test/HostingApplicationTests.cs | 5 +- .../Hosting/test/HostingMetricsTests.cs | 17 ++- .../Microsoft.AspNetCore.Hosting.Tests.csproj | 1 + ...rosoft.AspNetCore.Http.Abstractions.csproj | 5 - .../DeveloperExceptionPageMiddlewareTest.cs | 9 +- .../test/UnitTests/ExceptionHandlerTest.cs | 9 +- ...rosoft.AspNetCore.Diagnostics.Tests.csproj | 2 + .../Microsoft.AspNetCore.RateLimiting.csproj | 1 + .../RateLimiterServiceCollectionExtensions.cs | 1 + .../RateLimiting/src/RateLimitingMetrics.cs | 4 +- ...osoft.AspNetCore.RateLimiting.Tests.csproj | 3 +- .../test/RateLimitingMetricsTests.cs | 57 +++++---- .../test/RateLimitingMiddlewareTests.cs | 1 - .../Internal/Infrastructure/KestrelMetrics.cs | 4 +- src/Servers/Kestrel/Core/src/KestrelServer.cs | 11 +- ...soft.AspNetCore.Server.Kestrel.Core.csproj | 1 + .../Kestrel/Core/test/KestrelServerTests.cs | 1 - ...spNetCore.Server.Kestrel.Core.Tests.csproj | 1 + .../test/KestrelConfigurationLoaderTests.cs | 1 - ...oft.AspNetCore.Server.Kestrel.Tests.csproj | 1 + ...Core.Server.Kestrel.Microbenchmarks.csproj | 1 + .../Kestrel/shared/test/TestContextFactory.cs | 1 - .../Kestrel/shared/test/TestServiceContext.cs | 1 - .../ConnectionLimitTests.cs | 4 +- .../HttpsConnectionMiddlewareTests.cs | 3 - .../InMemory.FunctionalTests/HttpsTests.cs | 7 -- .../InMemory.FunctionalTests.csproj | 1 + .../KestrelMetricsTests.cs | 44 +++---- .../Sockets.BindTests.csproj | 1 + .../Sockets.FunctionalTests.csproj | 1 + src/Shared/Metrics/DefaultMeterFactory.cs | 109 ------------------ src/Shared/Metrics/IMeterFactory.cs | 77 ------------- src/Shared/Metrics/InstrumentRecorder.cs | 69 ----------- .../Metrics/MetricsServiceExtensions.cs | 37 ------ src/Shared/Metrics/TestMeterFactory.cs | 53 ++++++--- .../src/Internal/HttpConnectionsMetrics.cs | 4 +- ...crosoft.AspNetCore.Http.Connections.csproj | 1 + .../test/HttpConnectionDispatcherTests.cs | 7 +- .../test/HttpConnectionManagerTests.cs | 9 +- ...t.AspNetCore.Http.Connections.Tests.csproj | 1 + .../SignalRDependencyInjectionExtensions.cs | 1 + 50 files changed, 163 insertions(+), 432 deletions(-) delete mode 100644 src/Shared/Metrics/DefaultMeterFactory.cs delete mode 100644 src/Shared/Metrics/IMeterFactory.cs delete mode 100644 src/Shared/Metrics/InstrumentRecorder.cs delete mode 100644 src/Shared/Metrics/MetricsServiceExtensions.cs diff --git a/eng/Dependencies.props b/eng/Dependencies.props index 663aca404a22..9cabf595285b 100644 --- a/eng/Dependencies.props +++ b/eng/Dependencies.props @@ -40,6 +40,7 @@ and are generated based on the last package release. + diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index d2bc4e47b03c..7c6d012ac6ce 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -97,6 +97,10 @@ https://github.com/dotnet/runtime 7a119156cbe958c5c34098434e84010526fac5f1 + + https://github.com/dotnet/runtime + 7a119156cbe958c5c34098434e84010526fac5f1 + https://github.com/dotnet/runtime 7a119156cbe958c5c34098434e84010526fac5f1 diff --git a/eng/Versions.props b/eng/Versions.props index 73f4c57ca800..cfc295665aea 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -84,6 +84,7 @@ 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 diff --git a/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs b/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs index c4c5488e958e..45c7a0215aa6 100644 --- a/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs +++ b/src/Hosting/Hosting/src/GenericHost/GenericWebHostBuilder.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Hosting; diff --git a/src/Hosting/Hosting/src/GenericHost/SlimWebHostBuilder.cs b/src/Hosting/Hosting/src/GenericHost/SlimWebHostBuilder.cs index ff99aed202a7..693f39a497c7 100644 --- a/src/Hosting/Hosting/src/GenericHost/SlimWebHostBuilder.cs +++ b/src/Hosting/Hosting/src/GenericHost/SlimWebHostBuilder.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Hosting; namespace Microsoft.AspNetCore.Hosting; diff --git a/src/Hosting/Hosting/src/Internal/HostingMetrics.cs b/src/Hosting/Hosting/src/Internal/HostingMetrics.cs index 87d3ddf796e5..5ab7ed20737e 100644 --- a/src/Hosting/Hosting/src/Internal/HostingMetrics.cs +++ b/src/Hosting/Hosting/src/Internal/HostingMetrics.cs @@ -5,7 +5,7 @@ using System.Diagnostics; using System.Diagnostics.Metrics; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Metrics; +using Microsoft.Extensions.Diagnostics.Metrics; namespace Microsoft.AspNetCore.Hosting; @@ -19,7 +19,7 @@ internal sealed class HostingMetrics : IDisposable public HostingMetrics(IMeterFactory meterFactory) { - _meter = meterFactory.CreateMeter(MeterName); + _meter = meterFactory.Create(MeterName); _currentRequestsCounter = _meter.CreateUpDownCounter( "current-requests", diff --git a/src/Hosting/Hosting/src/Microsoft.AspNetCore.Hosting.csproj b/src/Hosting/Hosting/src/Microsoft.AspNetCore.Hosting.csproj index d981ca6501fb..49974f5104af 100644 --- a/src/Hosting/Hosting/src/Microsoft.AspNetCore.Hosting.csproj +++ b/src/Hosting/Hosting/src/Microsoft.AspNetCore.Hosting.csproj @@ -25,6 +25,7 @@ + diff --git a/src/Hosting/Hosting/src/WebHostBuilder.cs b/src/Hosting/Hosting/src/WebHostBuilder.cs index f21d3593697e..aff8235a7b80 100644 --- a/src/Hosting/Hosting/src/WebHostBuilder.cs +++ b/src/Hosting/Hosting/src/WebHostBuilder.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; diff --git a/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs b/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs index b42bb72e1bce..e58eda72de6b 100644 --- a/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs +++ b/src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs @@ -2,13 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.Metrics; using System.Diagnostics.Tracing; using System.Reflection; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Internal; +using Microsoft.AspNetCore.Testing; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Metrics; using Moq; namespace Microsoft.AspNetCore.Hosting.Tests; @@ -44,17 +46,15 @@ public async Task EventCountersAndMetricsValues() }); var testMeterFactory1 = new TestMeterFactory(); - var testMeterRegister1 = new TestMeterRegistry(testMeterFactory1.Meters); var testMeterFactory2 = new TestMeterFactory(); - var testMeterRegister2 = new TestMeterRegistry(testMeterFactory2.Meters); var hostingApplication1 = CreateApplication(out var features1, eventSource: hostingEventSource, meterFactory: testMeterFactory1); var hostingApplication2 = CreateApplication(out var features2, eventSource: hostingEventSource, meterFactory: testMeterFactory2); - using var currentRequestsRecorder1 = new InstrumentRecorder(testMeterRegister1, HostingMetrics.MeterName, "current-requests"); - using var currentRequestsRecorder2 = new InstrumentRecorder(testMeterRegister2, HostingMetrics.MeterName, "current-requests"); - using var requestDurationRecorder1 = new InstrumentRecorder(testMeterRegister1, HostingMetrics.MeterName, "request-duration"); - using var requestDurationRecorder2 = new InstrumentRecorder(testMeterRegister2, HostingMetrics.MeterName, "request-duration"); + using var currentRequestsRecorder1 = new InstrumentRecorder(testMeterFactory1, HostingMetrics.MeterName, "current-requests"); + using var currentRequestsRecorder2 = new InstrumentRecorder(testMeterFactory2, HostingMetrics.MeterName, "current-requests"); + using var requestDurationRecorder1 = new InstrumentRecorder(testMeterFactory1, HostingMetrics.MeterName, "request-duration"); + using var requestDurationRecorder2 = new InstrumentRecorder(testMeterFactory2, HostingMetrics.MeterName, "request-duration"); // Act/Assert 1 var context1 = hostingApplication1.CreateContext(features1); diff --git a/src/Hosting/Hosting/test/HostingApplicationTests.cs b/src/Hosting/Hosting/test/HostingApplicationTests.cs index f3882d917f9e..37a0fe85ca15 100644 --- a/src/Hosting/Hosting/test/HostingApplicationTests.cs +++ b/src/Hosting/Hosting/test/HostingApplicationTests.cs @@ -2,17 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections; -using System.Collections.ObjectModel; using System.Diagnostics; -using System.Diagnostics.Metrics; -using Microsoft.AspNetCore.Hosting.Fakes; using Microsoft.AspNetCore.Hosting.Server.Abstractions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Metrics; using Moq; using static Microsoft.AspNetCore.Hosting.HostingApplication; diff --git a/src/Hosting/Hosting/test/HostingMetricsTests.cs b/src/Hosting/Hosting/test/HostingMetricsTests.cs index 72877540bce7..bbea161096ca 100644 --- a/src/Hosting/Hosting/test/HostingMetricsTests.cs +++ b/src/Hosting/Hosting/test/HostingMetricsTests.cs @@ -9,8 +9,8 @@ using Microsoft.AspNetCore.Internal; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Metrics; namespace Microsoft.AspNetCore.Hosting.Tests; @@ -21,13 +21,12 @@ public void MultipleRequests() { // Arrange var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); var hostingApplication = CreateApplication(meterFactory: meterFactory); var httpContext = new DefaultHttpContext(); var meter = meterFactory.Meters.Single(); - using var requestDurationRecorder = new InstrumentRecorder(meterRegistry, HostingMetrics.MeterName, "request-duration"); - using var currentRequestsRecorder = new InstrumentRecorder(meterRegistry, HostingMetrics.MeterName, "current-requests"); + using var requestDurationRecorder = new InstrumentRecorder(meterFactory, HostingMetrics.MeterName, "request-duration"); + using var currentRequestsRecorder = new InstrumentRecorder(meterFactory, HostingMetrics.MeterName, "current-requests"); // Act/Assert Assert.Equal(HostingMetrics.MeterName, meter.Name); @@ -111,7 +110,6 @@ public async Task StartListeningDuringRequest_NotMeasured() // Arrange var syncPoint = new SyncPoint(); var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); var hostingApplication = CreateApplication(meterFactory: meterFactory, requestDelegate: async ctx => { await syncPoint.WaitToContinue(); @@ -130,8 +128,8 @@ public async Task StartListeningDuringRequest_NotMeasured() await syncPoint.WaitForSyncPoint().DefaultTimeout(); - using var requestDurationRecorder = new InstrumentRecorder(meterRegistry, HostingMetrics.MeterName, "request-duration"); - using var currentRequestsRecorder = new InstrumentRecorder(meterRegistry, HostingMetrics.MeterName, "current-requests"); + using var requestDurationRecorder = new InstrumentRecorder(meterFactory, HostingMetrics.MeterName, "request-duration"); + using var currentRequestsRecorder = new InstrumentRecorder(meterFactory, HostingMetrics.MeterName, "current-requests"); context1.HttpContext.Response.StatusCode = StatusCodes.Status200OK; syncPoint.Continue(); @@ -148,13 +146,12 @@ public void IHttpMetricsTagsFeatureNotUsedFromFeatureCollection() { // Arrange var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); var hostingApplication = CreateApplication(meterFactory: meterFactory); var httpContext = new DefaultHttpContext(); var meter = meterFactory.Meters.Single(); - using var requestDurationRecorder = new InstrumentRecorder(meterRegistry, HostingMetrics.MeterName, "request-duration"); - using var currentRequestsRecorder = new InstrumentRecorder(meterRegistry, HostingMetrics.MeterName, "current-requests"); + using var requestDurationRecorder = new InstrumentRecorder(meterFactory, HostingMetrics.MeterName, "request-duration"); + using var currentRequestsRecorder = new InstrumentRecorder(meterFactory, HostingMetrics.MeterName, "current-requests"); // Act/Assert Assert.Equal(HostingMetrics.MeterName, meter.Name); diff --git a/src/Hosting/Hosting/test/Microsoft.AspNetCore.Hosting.Tests.csproj b/src/Hosting/Hosting/test/Microsoft.AspNetCore.Hosting.Tests.csproj index 25a94cfc96a3..0fc87b4ba5c3 100644 --- a/src/Hosting/Hosting/test/Microsoft.AspNetCore.Hosting.Tests.csproj +++ b/src/Hosting/Hosting/test/Microsoft.AspNetCore.Hosting.Tests.csproj @@ -8,6 +8,7 @@ + diff --git a/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj b/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj index da6077afa1e8..8e21c01084c9 100644 --- a/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj +++ b/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj @@ -54,11 +54,6 @@ Microsoft.AspNetCore.Http.HttpResponse - - - - - diff --git a/src/Middleware/Diagnostics/test/UnitTests/DeveloperExceptionPageMiddlewareTest.cs b/src/Middleware/Diagnostics/test/UnitTests/DeveloperExceptionPageMiddlewareTest.cs index ba3f469038e0..24a1ced4f4a5 100644 --- a/src/Middleware/Diagnostics/test/UnitTests/DeveloperExceptionPageMiddlewareTest.cs +++ b/src/Middleware/Diagnostics/test/UnitTests/DeveloperExceptionPageMiddlewareTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.Metrics; using System.Net; using System.Net.Http; using System.Net.Http.Headers; @@ -14,8 +15,8 @@ using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Metrics; namespace Microsoft.AspNetCore.Diagnostics; @@ -540,9 +541,9 @@ public async Task UnhandledError_ExceptionNameTagAdded() var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); - var instrumentRecorder = new InstrumentRecorder(meterRegistry, "Microsoft.AspNetCore.Hosting", "request-duration"); - instrumentRecorder.Register(m => + using var instrumentRecorder = new InstrumentRecorder(meterFactory, "Microsoft.AspNetCore.Hosting", "request-duration"); + using var measurementReporter = new MeasurementReporter(meterFactory, "Microsoft.AspNetCore.Hosting", "request-duration"); + measurementReporter.Register(m => { tcs.SetResult(); }); diff --git a/src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs b/src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs index 6b9cc6f9e42b..725343f8c0b3 100644 --- a/src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs +++ b/src/Middleware/Diagnostics/test/UnitTests/ExceptionHandlerTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics; +using System.Diagnostics.Metrics; using System.Net; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -9,10 +10,10 @@ using Microsoft.AspNetCore.TestHost; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; -using Microsoft.Extensions.Metrics; namespace Microsoft.AspNetCore.Diagnostics; @@ -917,9 +918,9 @@ public async Task UnhandledError_ExceptionNameTagAdded() var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); - var instrumentRecorder = new InstrumentRecorder(meterRegistry, "Microsoft.AspNetCore.Hosting", "request-duration"); - instrumentRecorder.Register(m => + using var instrumentRecorder = new InstrumentRecorder(meterFactory, "Microsoft.AspNetCore.Hosting", "request-duration"); + using var measurementReporter = new MeasurementReporter(meterFactory, "Microsoft.AspNetCore.Hosting", "request-duration"); + measurementReporter.Register(m => { tcs.SetResult(); }); diff --git a/src/Middleware/Diagnostics/test/UnitTests/Microsoft.AspNetCore.Diagnostics.Tests.csproj b/src/Middleware/Diagnostics/test/UnitTests/Microsoft.AspNetCore.Diagnostics.Tests.csproj index b0a4f171d50f..d01bdacc7058 100644 --- a/src/Middleware/Diagnostics/test/UnitTests/Microsoft.AspNetCore.Diagnostics.Tests.csproj +++ b/src/Middleware/Diagnostics/test/UnitTests/Microsoft.AspNetCore.Diagnostics.Tests.csproj @@ -11,6 +11,8 @@ + + diff --git a/src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj b/src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj index 27ac36e46a85..a15b1fe9bf8c 100644 --- a/src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj +++ b/src/Middleware/RateLimiting/src/Microsoft.AspNetCore.RateLimiting.csproj @@ -14,6 +14,7 @@ + diff --git a/src/Middleware/RateLimiting/src/RateLimiterServiceCollectionExtensions.cs b/src/Middleware/RateLimiting/src/RateLimiterServiceCollectionExtensions.cs index 09f6f7ba7c5c..404f6a5e9b8c 100644 --- a/src/Middleware/RateLimiting/src/RateLimiterServiceCollectionExtensions.cs +++ b/src/Middleware/RateLimiting/src/RateLimiterServiceCollectionExtensions.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.RateLimiting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.Metrics; namespace Microsoft.AspNetCore.Builder; diff --git a/src/Middleware/RateLimiting/src/RateLimitingMetrics.cs b/src/Middleware/RateLimiting/src/RateLimitingMetrics.cs index 96d69256eea3..e06d8c405487 100644 --- a/src/Middleware/RateLimiting/src/RateLimitingMetrics.cs +++ b/src/Middleware/RateLimiting/src/RateLimitingMetrics.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Diagnostics.Metrics; using System.Runtime.CompilerServices; -using Microsoft.Extensions.Metrics; +using Microsoft.Extensions.Diagnostics.Metrics; namespace Microsoft.AspNetCore.RateLimiting; @@ -21,7 +21,7 @@ internal sealed class RateLimitingMetrics : IDisposable public RateLimitingMetrics(IMeterFactory meterFactory) { - _meter = meterFactory.CreateMeter(MeterName); + _meter = meterFactory.Create(MeterName); _currentLeasedRequestsCounter = _meter.CreateUpDownCounter( "current-leased-requests", diff --git a/src/Middleware/RateLimiting/test/Microsoft.AspNetCore.RateLimiting.Tests.csproj b/src/Middleware/RateLimiting/test/Microsoft.AspNetCore.RateLimiting.Tests.csproj index 22890a28eae9..7a307f93db64 100644 --- a/src/Middleware/RateLimiting/test/Microsoft.AspNetCore.RateLimiting.Tests.csproj +++ b/src/Middleware/RateLimiting/test/Microsoft.AspNetCore.RateLimiting.Tests.csproj @@ -9,6 +9,7 @@ - + + diff --git a/src/Middleware/RateLimiting/test/RateLimitingMetricsTests.cs b/src/Middleware/RateLimiting/test/RateLimitingMetricsTests.cs index 9f5f7388daf9..03b054d50725 100644 --- a/src/Middleware/RateLimiting/test/RateLimitingMetricsTests.cs +++ b/src/Middleware/RateLimiting/test/RateLimitingMetricsTests.cs @@ -10,9 +10,9 @@ using Microsoft.AspNetCore.Routing.Patterns; using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Metrics; using Microsoft.Extensions.Options; using Moq; @@ -25,7 +25,6 @@ public async Task Metrics_Rejected() { // Arrange var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); var options = CreateOptionsAccessor(); options.Value.GlobalLimiter = new TestPartitionedRateLimiter(new TestRateLimiter(false)); @@ -35,11 +34,11 @@ public async Task Metrics_Rejected() var context = new DefaultHttpContext(); - using var leaseRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "leased-request-duration"); - using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-leased-requests"); - using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-queued-requests"); - using var queuedRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "queued-request-duration"); - using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "lease-failed-requests"); + using var leaseRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "leased-request-duration"); + using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-leased-requests"); + using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-queued-requests"); + using var queuedRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "queued-request-duration"); + using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "lease-failed-requests"); // Act await middleware.Invoke(context).DefaultTimeout(); @@ -66,7 +65,6 @@ public async Task Metrics_Success() var syncPoint = new SyncPoint(); var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); var options = CreateOptionsAccessor(); options.Value.GlobalLimiter = new TestPartitionedRateLimiter(new TestRateLimiter(true)); @@ -83,11 +81,11 @@ public async Task Metrics_Success() var context = new DefaultHttpContext(); context.Request.Method = "GET"; - using var leaseRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "leased-request-duration"); - using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-leased-requests"); - using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-queued-requests"); - using var queuedRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "queued-request-duration"); - using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "lease-failed-requests"); + using var leaseRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "leased-request-duration"); + using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-leased-requests"); + using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-queued-requests"); + using var queuedRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "queued-request-duration"); + using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "lease-failed-requests"); // Act var middlewareTask = middleware.Invoke(context); @@ -122,7 +120,6 @@ public async Task Metrics_ListenInMiddleOfRequest_CurrentLeasesNotDecreased() var syncPoint = new SyncPoint(); var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); var options = CreateOptionsAccessor(); options.Value.GlobalLimiter = new TestPartitionedRateLimiter(new TestRateLimiter(true)); @@ -144,11 +141,11 @@ public async Task Metrics_ListenInMiddleOfRequest_CurrentLeasesNotDecreased() await syncPoint.WaitForSyncPoint().DefaultTimeout(); - using var leaseRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "leased-request-duration"); - using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-leased-requests"); - using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-queued-requests"); - using var queuedRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "queued-request-duration"); - using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "lease-failed-requests"); + using var leaseRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "leased-request-duration"); + using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-leased-requests"); + using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-queued-requests"); + using var queuedRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "queued-request-duration"); + using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "lease-failed-requests"); syncPoint.Continue(); @@ -169,7 +166,6 @@ public async Task Metrics_Queued() var syncPoint = new SyncPoint(); var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); var services = new ServiceCollection(); @@ -196,11 +192,11 @@ public async Task Metrics_Queued() routeEndpointBuilder.Metadata.Add(new EnableRateLimitingAttribute("concurrencyPolicy")); var endpoint = routeEndpointBuilder.Build(); - using var leaseRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "leased-request-duration"); - using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-leased-requests"); - using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-queued-requests"); - using var queuedRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "queued-request-duration"); - using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "lease-failed-requests"); + using var leaseRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "leased-request-duration"); + using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-leased-requests"); + using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-queued-requests"); + using var queuedRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "queued-request-duration"); + using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "lease-failed-requests"); // Act var context1 = new DefaultHttpContext(); @@ -241,7 +237,6 @@ public async Task Metrics_ListenInMiddleOfQueued_CurrentQueueNotDecreased() var syncPoint = new SyncPoint(); var meterFactory = new TestMeterFactory(); - var meterRegistry = new TestMeterRegistry(meterFactory.Meters); var services = new ServiceCollection(); @@ -284,11 +279,11 @@ public async Task Metrics_ListenInMiddleOfQueued_CurrentQueueNotDecreased() // Start listening while the second request is queued. - using var leaseRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "leased-request-duration"); - using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-leased-requests"); - using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "current-queued-requests"); - using var queuedRequestDurationRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "queued-request-duration"); - using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterRegistry, RateLimitingMetrics.MeterName, "lease-failed-requests"); + using var leaseRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "leased-request-duration"); + using var currentLeaseRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-leased-requests"); + using var currentRequestsQueuedRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "current-queued-requests"); + using var queuedRequestDurationRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "queued-request-duration"); + using var leaseFailedRequestsRecorder = new InstrumentRecorder(meterFactory, RateLimitingMetrics.MeterName, "lease-failed-requests"); Assert.Empty(currentRequestsQueuedRecorder.GetMeasurements()); Assert.Empty(queuedRequestDurationRecorder.GetMeasurements()); diff --git a/src/Middleware/RateLimiting/test/RateLimitingMiddlewareTests.cs b/src/Middleware/RateLimiting/test/RateLimitingMiddlewareTests.cs index b64c7a258195..3ad783a694e9 100644 --- a/src/Middleware/RateLimiting/test/RateLimitingMiddlewareTests.cs +++ b/src/Middleware/RateLimiting/test/RateLimitingMiddlewareTests.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging.Testing; -using Microsoft.Extensions.Metrics; using Microsoft.Extensions.Options; using Moq; diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelMetrics.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelMetrics.cs index 71102514ee60..8cfcc983b7b4 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelMetrics.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelMetrics.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.Connections; -using Microsoft.Extensions.Metrics; +using Microsoft.Extensions.Diagnostics.Metrics; using System.Diagnostics; using System.Diagnostics.Metrics; using System.Runtime.CompilerServices; @@ -27,7 +27,7 @@ internal sealed class KestrelMetrics public KestrelMetrics(IMeterFactory meterFactory) { - _meter = meterFactory.CreateMeter(MeterName); + _meter = meterFactory.Create(MeterName); _currentConnectionsCounter = _meter.CreateUpDownCounter( "current-connections", diff --git a/src/Servers/Kestrel/Core/src/KestrelServer.cs b/src/Servers/Kestrel/Core/src/KestrelServer.cs index cd8284a87304..c9f29f553c45 100644 --- a/src/Servers/Kestrel/Core/src/KestrelServer.cs +++ b/src/Servers/Kestrel/Core/src/KestrelServer.cs @@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Https.Internal; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Metrics; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Server.Kestrel.Core; @@ -71,9 +71,14 @@ public void Dispose() // This factory used when type is created without DI. For example, via KestrelServer. private sealed class DummyMeterFactory : IMeterFactory { - public Meter CreateMeter(string name) => new Meter(name); + public Meter Create(MeterOptions options) + { + return new Meter(options); + } - public Meter CreateMeter(MeterOptions options) => new Meter(options.Name, options.Version); + public void Dispose() + { + } } private sealed class SimpleHttpsConfigurationService : IHttpsConfigurationService diff --git a/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj b/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj index e4b328c02a61..28bdec552dd3 100644 --- a/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj +++ b/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj @@ -37,6 +37,7 @@ + diff --git a/src/Servers/Kestrel/Core/test/KestrelServerTests.cs b/src/Servers/Kestrel/Core/test/KestrelServerTests.cs index 39eea7cbb2cc..e13e3717688e 100644 --- a/src/Servers/Kestrel/Core/test/KestrelServerTests.cs +++ b/src/Servers/Kestrel/Core/test/KestrelServerTests.cs @@ -16,7 +16,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Metrics; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; diff --git a/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj b/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj index 1bc7490209d6..34d9d34335dc 100644 --- a/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj +++ b/src/Servers/Kestrel/Core/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj @@ -9,6 +9,7 @@ + diff --git a/src/Servers/Kestrel/Kestrel/test/KestrelConfigurationLoaderTests.cs b/src/Servers/Kestrel/Kestrel/test/KestrelConfigurationLoaderTests.cs index 1979300aa144..83777bc0e2aa 100644 --- a/src/Servers/Kestrel/Kestrel/test/KestrelConfigurationLoaderTests.cs +++ b/src/Servers/Kestrel/Kestrel/test/KestrelConfigurationLoaderTests.cs @@ -13,7 +13,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Metrics; using Microsoft.Extensions.Primitives; using Moq; diff --git a/src/Servers/Kestrel/Kestrel/test/Microsoft.AspNetCore.Server.Kestrel.Tests.csproj b/src/Servers/Kestrel/Kestrel/test/Microsoft.AspNetCore.Server.Kestrel.Tests.csproj index 99c9f591ee43..ea39d1e46d6f 100644 --- a/src/Servers/Kestrel/Kestrel/test/Microsoft.AspNetCore.Server.Kestrel.Tests.csproj +++ b/src/Servers/Kestrel/Kestrel/test/Microsoft.AspNetCore.Server.Kestrel.Tests.csproj @@ -7,6 +7,7 @@ + diff --git a/src/Servers/Kestrel/perf/Microbenchmarks/Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks.csproj b/src/Servers/Kestrel/perf/Microbenchmarks/Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks.csproj index acb6b02307c2..ae10ecd08351 100644 --- a/src/Servers/Kestrel/perf/Microbenchmarks/Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks.csproj +++ b/src/Servers/Kestrel/perf/Microbenchmarks/Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Servers/Kestrel/shared/test/TestContextFactory.cs b/src/Servers/Kestrel/shared/test/TestContextFactory.cs index 5413e4c13249..060457c4be2c 100644 --- a/src/Servers/Kestrel/shared/test/TestContextFactory.cs +++ b/src/Servers/Kestrel/shared/test/TestContextFactory.cs @@ -15,7 +15,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Metrics; namespace Microsoft.AspNetCore.Testing; diff --git a/src/Servers/Kestrel/shared/test/TestServiceContext.cs b/src/Servers/Kestrel/shared/test/TestServiceContext.cs index 49712725a9a9..0e6f8eb3b823 100644 --- a/src/Servers/Kestrel/shared/test/TestServiceContext.cs +++ b/src/Servers/Kestrel/shared/test/TestServiceContext.cs @@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Metrics; namespace Microsoft.AspNetCore.Testing; diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/ConnectionLimitTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/ConnectionLimitTests.cs index 15393c8950e1..8ccbd261b97e 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/ConnectionLimitTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/ConnectionLimitTests.cs @@ -15,7 +15,7 @@ using Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTransport; using Microsoft.AspNetCore.Server.Kestrel.Tests; using Microsoft.AspNetCore.Testing; -using Microsoft.Extensions.Metrics; +using Microsoft.Extensions.Diagnostics.Metrics; using Xunit; namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests; @@ -102,7 +102,7 @@ public async Task UpgradedConnectionsCountsAgainstDifferentLimit() public async Task RejectsConnectionsWhenLimitReached() { var testMeterFactory = new TestMeterFactory(); - using var rejectedConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "rejected-connections"); + using var rejectedConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "rejected-connections"); const int max = 10; var requestTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs index 3362f78150ea..cd589224aa11 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Globalization; -using System.Net; using System.Net.Http; using System.Net.Security; using System.Security.Authentication; @@ -24,7 +22,6 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Metrics; using Moq; namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests; diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsTests.cs index f0f223373bf4..4c252cb6ffbd 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsTests.cs @@ -1,14 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; using System.Net.Security; using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Text; -using System.Threading; -using System.Threading.Tasks; using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -24,10 +20,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Internal; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Metrics; -using Microsoft.Extensions.Options; using Moq; -using Xunit; namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests; diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj b/src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj index 576463f85fca..7f5ed843519d 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/InMemory.FunctionalTests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/KestrelMetricsTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/KestrelMetricsTests.cs index c0e8349a3bbb..86457feab09b 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/KestrelMetricsTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/KestrelMetricsTests.cs @@ -18,7 +18,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTransport; using Microsoft.AspNetCore.Testing; -using Microsoft.Extensions.Metrics; +using Microsoft.Extensions.Diagnostics.Metrics; namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests; @@ -46,9 +46,9 @@ public async Task Http1Connection() }); var testMeterFactory = new TestMeterFactory(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); - using var queuedConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); + using var queuedConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); @@ -122,9 +122,9 @@ public async Task Http1Connection_BeginListeningAfterConnectionStarted() // Wait for connection to start on the server. await sync.WaitForSyncPoint(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); - using var queuedConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); + using var queuedConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); // Signal that connection can continue. sync.Continue(); @@ -169,9 +169,9 @@ public async Task Http1Connection_IHttpConnectionTagsFeatureIgnoreFeatureSetOnTr }); var testMeterFactory = new TestMeterFactory(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); - using var queuedConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); + using var queuedConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); @@ -244,9 +244,9 @@ public async Task Http1Connection_Error() }); var testMeterFactory = new TestMeterFactory(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); - using var queuedConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); + using var queuedConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); @@ -287,9 +287,9 @@ public async Task Http1Connection_Upgrade() var listenOptions = new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0)); var testMeterFactory = new TestMeterFactory(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); - using var currentUpgradedRequests = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "current-upgraded-connections"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); + using var currentUpgradedRequests = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "current-upgraded-connections"); var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)); @@ -331,12 +331,12 @@ public async Task Http2Connection() var requestsReceived = 0; var testMeterFactory = new TestMeterFactory(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); - using var queuedConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); - using var queuedRequests = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "queued-requests"); - using var tlsHandshakeDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "tls-handshake-duration"); - using var currentTlsHandshakes = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), "Microsoft.AspNetCore.Server.Kestrel", "current-tls-handshakes"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "current-connections"); + using var queuedConnections = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "queued-connections"); + using var queuedRequests = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "queued-requests"); + using var tlsHandshakeDuration = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "tls-handshake-duration"); + using var currentTlsHandshakes = new InstrumentRecorder(testMeterFactory, "Microsoft.AspNetCore.Server.Kestrel", "current-tls-handshakes"); await using (var server = new TestServer(context => { diff --git a/src/Servers/Kestrel/test/Sockets.BindTests/Sockets.BindTests.csproj b/src/Servers/Kestrel/test/Sockets.BindTests/Sockets.BindTests.csproj index 5d7992a557a7..a584f2368fdf 100644 --- a/src/Servers/Kestrel/test/Sockets.BindTests/Sockets.BindTests.csproj +++ b/src/Servers/Kestrel/test/Sockets.BindTests/Sockets.BindTests.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Servers/Kestrel/test/Sockets.FunctionalTests/Sockets.FunctionalTests.csproj b/src/Servers/Kestrel/test/Sockets.FunctionalTests/Sockets.FunctionalTests.csproj index 2b8e9b81899c..4a45a7f70434 100644 --- a/src/Servers/Kestrel/test/Sockets.FunctionalTests/Sockets.FunctionalTests.csproj +++ b/src/Servers/Kestrel/test/Sockets.FunctionalTests/Sockets.FunctionalTests.csproj @@ -11,6 +11,7 @@ + diff --git a/src/Shared/Metrics/DefaultMeterFactory.cs b/src/Shared/Metrics/DefaultMeterFactory.cs deleted file mode 100644 index f6961526d1f7..000000000000 --- a/src/Shared/Metrics/DefaultMeterFactory.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.Metrics; -using System.Linq; -using Microsoft.Extensions.Options; - -namespace Microsoft.Extensions.Metrics; - -// TODO: Remove when Metrics DI intergration package is available https://github.com/dotnet/aspnetcore/issues/47618 -internal sealed class DefaultMeterFactory : IMeterFactory -{ - private readonly IOptions _options; - private readonly IMeterRegistry _meterRegistry; - private readonly Dictionary _meters = new Dictionary(); - - public DefaultMeterFactory(IOptions options, IMeterRegistry meterRegistry) - { - _options = options; - _meterRegistry = meterRegistry; - } - - public Meter CreateMeter(string name) - { - return CreateMeterCore(name, version: null, defaultTags: null); - } - - public Meter CreateMeter(MeterOptions options) - { - return CreateMeterCore(options.Name, options.Version, options.DefaultTags); - } - - private Meter CreateMeterCore(string name, string? version, IList>? defaultTags) - { - var tags = defaultTags?.ToArray(); - if (tags != null) - { - Array.Sort(tags, (t1, t2) => string.Compare(t1.Key, t2.Key, StringComparison.Ordinal)); - } - var key = new MeterKey(name, version, tags); - - if (_meters.TryGetValue(key, out var meter)) - { - return meter; - } - - // TODO: Configure meter with default tags. - meter = new Meter(name, version); - _meters[key] = meter; - _meterRegistry.Add(meter); - - return meter; - } - - private readonly struct MeterKey : IEquatable - { - public MeterKey(string name, string? version, KeyValuePair[]? defaultTags) - { - Name = name; - Version = version; - DefaultTags = defaultTags; - } - - public string Name { get; } - public string? Version { get; } - public IList>? DefaultTags { get; } - - public bool Equals(MeterKey other) - { - return Name == other.Name - && Version == other.Version - && TagsEqual(other); - } - - private bool TagsEqual(MeterKey other) - { - if (DefaultTags is null && other.DefaultTags is null) - { - return true; - } - if (DefaultTags is not null && other.DefaultTags is not null && DefaultTags.SequenceEqual(other.DefaultTags)) - { - return true; - } - return false; - } - - public override bool Equals(object? obj) - { - return obj is MeterKey key && Equals(key); - } - - public override int GetHashCode() - { - var hashCode = new HashCode(); - hashCode.Add(Name); - hashCode.Add(Version); - if (DefaultTags is not null) - { - foreach (var item in DefaultTags) - { - hashCode.Add(item); - } - } - - return hashCode.ToHashCode(); - } - } -} diff --git a/src/Shared/Metrics/IMeterFactory.cs b/src/Shared/Metrics/IMeterFactory.cs deleted file mode 100644 index 82563cc89701..000000000000 --- a/src/Shared/Metrics/IMeterFactory.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.Metrics; -using Microsoft.Extensions.DependencyInjection; - -namespace Microsoft.Extensions.Metrics; - -// TODO: Remove when Metrics DI intergration package is available https://github.com/dotnet/aspnetcore/issues/47618 -internal sealed class MetricsOptions -{ - public IList> DefaultTags { get; } = new List>(); -} - -internal interface IMetricsBuilder -{ - IServiceCollection Services { get; } -} - -internal sealed class MetricsBuilder : IMetricsBuilder -{ - public MetricsBuilder(IServiceCollection services) => Services = services; - public IServiceCollection Services { get; } -} - -internal sealed class MeterOptions -{ - public required string Name { get; set; } - public string? Version { get; set; } - public IList>? DefaultTags { get; set; } -} - -internal interface IMeterFactory -{ - Meter CreateMeter(string name); - Meter CreateMeter(MeterOptions options); -} - -internal interface IMeterRegistry -{ - void Add(Meter meter); - bool Contains(Meter meter); -} - -internal sealed class DefaultMeterRegistry : IMeterRegistry, IDisposable -{ - private readonly object _lock = new object(); - private readonly List _meters = new List(); - - public void Add(Meter meter) - { - lock (_lock) - { - _meters.Add(meter); - } - } - - public bool Contains(Meter meter) - { - lock (_lock) - { - return _meters.Contains(meter); - } - } - - public void Dispose() - { - lock (_lock) - { - foreach (var meter in _meters) - { - meter.Dispose(); - } - _meters.Clear(); - } - } -} diff --git a/src/Shared/Metrics/InstrumentRecorder.cs b/src/Shared/Metrics/InstrumentRecorder.cs deleted file mode 100644 index 33fb51ea8f4e..000000000000 --- a/src/Shared/Metrics/InstrumentRecorder.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.Metrics; - -namespace Microsoft.Extensions.Metrics; - -// TODO: Remove when Metrics DI intergration package is available https://github.com/dotnet/aspnetcore/issues/47618 -internal sealed class InstrumentRecorder : IDisposable where T : struct -{ - private readonly object _lock = new object(); - private readonly string _meterName; - private readonly string _instrumentName; - private readonly MeterListener _meterListener; - private readonly List> _values; - private readonly List>> _callbacks; - - public InstrumentRecorder(IMeterRegistry registry, string meterName, string instrumentName, object? state = null) - { - _meterName = meterName; - _instrumentName = instrumentName; - _callbacks = new List>>(); - _values = new List>(); - _meterListener = new MeterListener(); - _meterListener.InstrumentPublished = (instrument, listener) => - { - if (instrument.Meter.Name == _meterName && registry.Contains(instrument.Meter) && instrument.Name == _instrumentName) - { - listener.EnableMeasurementEvents(instrument, state); - } - }; - _meterListener.SetMeasurementEventCallback(OnMeasurementRecorded); - _meterListener.Start(); - } - - private void OnMeasurementRecorded(Instrument instrument, T measurement, ReadOnlySpan> tags, object? state) - { - lock (_lock) - { - var m = new Measurement(measurement, tags); - _values.Add(m); - - // Should this happen in the lock? - // Is there a better way to notify listeners that there are new measurements? - foreach (var callback in _callbacks) - { - callback(m); - } - } - } - - public void Register(Action> callback) - { - _callbacks.Add(callback); - } - - public IReadOnlyList> GetMeasurements() - { - lock (_lock) - { - return _values.ToArray(); - } - } - - public void Dispose() - { - _meterListener.Dispose(); - } -} diff --git a/src/Shared/Metrics/MetricsServiceExtensions.cs b/src/Shared/Metrics/MetricsServiceExtensions.cs deleted file mode 100644 index f18fa7148476..000000000000 --- a/src/Shared/Metrics/MetricsServiceExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Metrics; - -namespace Microsoft.Extensions.DependencyInjection; - -// TODO: Remove when Metrics DI intergration package is available https://github.com/dotnet/aspnetcore/issues/47618 -internal static class MetricsServiceExtensions -{ - public static IServiceCollection AddMetrics(this IServiceCollection services) - { - ArgumentNullException.ThrowIfNull(services); - - services.TryAddSingleton(); - services.TryAddSingleton(); - - return services; - } - - public static IServiceCollection AddMetrics(this IServiceCollection services, Action configure) - { - ArgumentNullException.ThrowIfNull(services); - - services.AddMetrics(); - configure(new MetricsBuilder(services)); - - return services; - } - - public static IMetricsBuilder AddDefaultTag(this IMetricsBuilder builder, string name, object? value) - { - builder.Services.Configure(o => o.DefaultTags.Add(new KeyValuePair(name, value))); - return builder; - } -} diff --git a/src/Shared/Metrics/TestMeterFactory.cs b/src/Shared/Metrics/TestMeterFactory.cs index 9f1f2495d247..deb79f72e8e8 100644 --- a/src/Shared/Metrics/TestMeterFactory.cs +++ b/src/Shared/Metrics/TestMeterFactory.cs @@ -2,43 +2,66 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.Metrics; +using Microsoft.Extensions.Diagnostics.Metrics; -namespace Microsoft.Extensions.Metrics; +namespace Microsoft.AspNetCore.Testing; -// TODO: Remove when Metrics DI intergration package is available https://github.com/dotnet/aspnetcore/issues/47618 internal class TestMeterFactory : IMeterFactory { public List Meters { get; } = new List(); - public Meter CreateMeter(string name) + public Meter Create(MeterOptions options) { - var meter = new Meter(name); + var meter = new Meter(options.Name, options.Version, Array.Empty>(), scope: this); Meters.Add(meter); return meter; } - public Meter CreateMeter(MeterOptions options) + public void Dispose() { - var meter = new Meter(options.Name, options.Version); - Meters.Add(meter); - return meter; } } -internal class TestMeterRegistry : IMeterRegistry +internal class MeasurementReporter : IDisposable where T : struct { - private readonly List _meters; + private readonly string _meterName; + private readonly string _instrumentName; + private readonly List>> _callbacks; + private readonly MeterListener _meterListener; - public TestMeterRegistry() : this(new List()) + public MeasurementReporter(IMeterFactory factory, string meterName, string instrumentName, object state = null) { + _meterName = meterName; + _instrumentName = instrumentName; + _callbacks = new List>>(); + _meterListener = new MeterListener(); + _meterListener.InstrumentPublished = (instrument, listener) => + { + if (instrument.Meter.Name == _meterName && instrument.Meter.Scope == factory && instrument.Name == _instrumentName) + { + listener.EnableMeasurementEvents(instrument, state); + } + }; + _meterListener.SetMeasurementEventCallback(OnMeasurementRecorded); + _meterListener.Start(); } - public TestMeterRegistry(List meters) + private void OnMeasurementRecorded(Instrument instrument, T measurement, ReadOnlySpan> tags, object state) { - _meters = meters; + var m = new Measurement(measurement, tags); + foreach (var callback in _callbacks) + { + callback(m); + } } - public void Add(Meter meter) => _meters.Add(meter); + public void Register(Action> callback) + { + _callbacks.Add(callback); + } - public bool Contains(Meter meter) => _meters.Contains(meter); + public void Dispose() + { + _meterListener.Dispose(); + } } diff --git a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsMetrics.cs b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsMetrics.cs index 80807c5d0534..9637def5df6f 100644 --- a/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsMetrics.cs +++ b/src/SignalR/common/Http.Connections/src/Internal/HttpConnectionsMetrics.cs @@ -3,7 +3,7 @@ using System.Diagnostics; using System.Diagnostics.Metrics; -using Microsoft.Extensions.Metrics; +using Microsoft.Extensions.Diagnostics.Metrics; namespace Microsoft.AspNetCore.Http.Connections.Internal; @@ -32,7 +32,7 @@ internal sealed class HttpConnectionsMetrics : IDisposable public HttpConnectionsMetrics(IMeterFactory meterFactory) { - _meter = meterFactory.CreateMeter(MeterName); + _meter = meterFactory.Create(MeterName); _currentConnectionsCounter = _meter.CreateUpDownCounter( "current-connections", diff --git a/src/SignalR/common/Http.Connections/src/Microsoft.AspNetCore.Http.Connections.csproj b/src/SignalR/common/Http.Connections/src/Microsoft.AspNetCore.Http.Connections.csproj index e6ee74ec7735..03cbb1beac26 100644 --- a/src/SignalR/common/Http.Connections/src/Microsoft.AspNetCore.Http.Connections.csproj +++ b/src/SignalR/common/Http.Connections/src/Microsoft.AspNetCore.Http.Connections.csproj @@ -36,6 +36,7 @@ + diff --git a/src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs b/src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs index 9d16f32f4a6b..d08c52699d7c 100644 --- a/src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs +++ b/src/SignalR/common/Http.Connections/test/HttpConnectionDispatcherTests.cs @@ -36,7 +36,6 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; -using Microsoft.Extensions.Metrics; using Microsoft.Extensions.Options; using Microsoft.Extensions.Primitives; using Microsoft.IdentityModel.Tokens; @@ -1091,9 +1090,9 @@ public async Task Metrics() using (StartVerifiableLog()) { var testMeterFactory = new TestMeterFactory(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), HttpConnectionsMetrics.MeterName, "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), HttpConnectionsMetrics.MeterName, "current-connections"); - using var currentTransports = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), HttpConnectionsMetrics.MeterName, "current-transports"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, HttpConnectionsMetrics.MeterName, "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, HttpConnectionsMetrics.MeterName, "current-connections"); + using var currentTransports = new InstrumentRecorder(testMeterFactory, HttpConnectionsMetrics.MeterName, "current-transports"); var metrics = new HttpConnectionsMetrics(testMeterFactory); var manager = CreateConnectionManager(LoggerFactory, metrics); diff --git a/src/SignalR/common/Http.Connections/test/HttpConnectionManagerTests.cs b/src/SignalR/common/Http.Connections/test/HttpConnectionManagerTests.cs index ff067e567f4a..d2a9ca4adbb6 100644 --- a/src/SignalR/common/Http.Connections/test/HttpConnectionManagerTests.cs +++ b/src/SignalR/common/Http.Connections/test/HttpConnectionManagerTests.cs @@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Metrics; using Microsoft.Extensions.Options; using Xunit; @@ -430,8 +429,8 @@ public void Metrics() using (StartVerifiableLog()) { var testMeterFactory = new TestMeterFactory(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), HttpConnectionsMetrics.MeterName, "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), HttpConnectionsMetrics.MeterName, "current-connections"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, HttpConnectionsMetrics.MeterName, "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, HttpConnectionsMetrics.MeterName, "current-connections"); var connectionManager = CreateConnectionManager(LoggerFactory, metrics: new HttpConnectionsMetrics(testMeterFactory)); var connection = connectionManager.CreateConnection(); @@ -459,8 +458,8 @@ public void Metrics_ListenStartAfterConnection_Empty() var connectionManager = CreateConnectionManager(LoggerFactory, metrics: new HttpConnectionsMetrics(testMeterFactory)); var connection = connectionManager.CreateConnection(); - using var connectionDuration = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), HttpConnectionsMetrics.MeterName, "connection-duration"); - using var currentConnections = new InstrumentRecorder(new TestMeterRegistry(testMeterFactory.Meters), HttpConnectionsMetrics.MeterName, "current-connections"); + using var connectionDuration = new InstrumentRecorder(testMeterFactory, HttpConnectionsMetrics.MeterName, "connection-duration"); + using var currentConnections = new InstrumentRecorder(testMeterFactory, HttpConnectionsMetrics.MeterName, "current-connections"); Assert.NotNull(connection.ConnectionId); diff --git a/src/SignalR/common/Http.Connections/test/Microsoft.AspNetCore.Http.Connections.Tests.csproj b/src/SignalR/common/Http.Connections/test/Microsoft.AspNetCore.Http.Connections.Tests.csproj index 552dad1c1e05..28671b344a4f 100644 --- a/src/SignalR/common/Http.Connections/test/Microsoft.AspNetCore.Http.Connections.Tests.csproj +++ b/src/SignalR/common/Http.Connections/test/Microsoft.AspNetCore.Http.Connections.Tests.csproj @@ -8,6 +8,7 @@ + diff --git a/src/SignalR/server/SignalR/src/SignalRDependencyInjectionExtensions.cs b/src/SignalR/server/SignalR/src/SignalRDependencyInjectionExtensions.cs index ed613ec73f96..628fee8b5f12 100644 --- a/src/SignalR/server/SignalR/src/SignalRDependencyInjectionExtensions.cs +++ b/src/SignalR/server/SignalR/src/SignalRDependencyInjectionExtensions.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Diagnostics.Metrics; using Microsoft.Extensions.Options; namespace Microsoft.Extensions.DependencyInjection; From f961887e7747847ac032b3a4e749a20a6a89c968 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 24 May 2023 21:08:23 +0800 Subject: [PATCH 03/10] Add to shared framework --- eng/SharedFramework.External.props | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/SharedFramework.External.props b/eng/SharedFramework.External.props index 2f7d2bdc3786..63a588bf37ec 100644 --- a/eng/SharedFramework.External.props +++ b/eng/SharedFramework.External.props @@ -21,6 +21,7 @@ + From edf1a13d627282064287a084b785e60cb3119587 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 24 May 2023 12:36:46 -0500 Subject: [PATCH 04/10] Add Diagnostics.Abstractions to shared fx. --- eng/SharedFramework.External.props | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/SharedFramework.External.props b/eng/SharedFramework.External.props index 63a588bf37ec..175c7848407a 100644 --- a/eng/SharedFramework.External.props +++ b/eng/SharedFramework.External.props @@ -21,6 +21,7 @@ + From ec12b84d5f159ce9b8ef86fa416a4247c97f6dab Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 24 May 2023 12:45:16 -0500 Subject: [PATCH 05/10] Remove InternalsVisibleTo workaround. Add some dispose logic to TestMeterFactory. --- ...crosoft.AspNetCore.Http.Abstractions.csproj | 18 ------------------ src/Servers/Kestrel/Core/src/KestrelServer.cs | 9 ++------- ...osoft.AspNetCore.Server.Kestrel.Core.csproj | 2 ++ src/Shared/Metrics/TestMeterFactory.cs | 6 ++++++ 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj b/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj index 8e21c01084c9..6c763eeb07f6 100644 --- a/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj +++ b/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj @@ -54,24 +54,6 @@ Microsoft.AspNetCore.Http.HttpResponse - - - - - - - - - - - - - - - - - - diff --git a/src/Servers/Kestrel/Core/src/KestrelServer.cs b/src/Servers/Kestrel/Core/src/KestrelServer.cs index c9f29f553c45..54fc492304f8 100644 --- a/src/Servers/Kestrel/Core/src/KestrelServer.cs +++ b/src/Servers/Kestrel/Core/src/KestrelServer.cs @@ -71,14 +71,9 @@ public void Dispose() // This factory used when type is created without DI. For example, via KestrelServer. private sealed class DummyMeterFactory : IMeterFactory { - public Meter Create(MeterOptions options) - { - return new Meter(options); - } + public Meter Create(MeterOptions options) => new Meter(options); - public void Dispose() - { - } + public void Dispose() { } } private sealed class SimpleHttpsConfigurationService : IHttpsConfigurationService diff --git a/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj b/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj index 28bdec552dd3..cb48c665434f 100644 --- a/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj +++ b/src/Servers/Kestrel/Core/src/Microsoft.AspNetCore.Server.Kestrel.Core.csproj @@ -20,6 +20,8 @@ + + diff --git a/src/Shared/Metrics/TestMeterFactory.cs b/src/Shared/Metrics/TestMeterFactory.cs index deb79f72e8e8..bac254f5801d 100644 --- a/src/Shared/Metrics/TestMeterFactory.cs +++ b/src/Shared/Metrics/TestMeterFactory.cs @@ -19,6 +19,12 @@ public Meter Create(MeterOptions options) public void Dispose() { + foreach (var meter in Meters) + { + meter.Dispose(); + } + + Meters.Clear(); } } From 07a304398dd8d639bc976377f077300e28d04126 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 24 May 2023 12:47:33 -0500 Subject: [PATCH 06/10] Add Abstractions --- eng/Dependencies.props | 1 + eng/Version.Details.xml | 4 ++++ eng/Versions.props | 1 + 3 files changed, 6 insertions(+) diff --git a/eng/Dependencies.props b/eng/Dependencies.props index 9cabf595285b..0413b558a486 100644 --- a/eng/Dependencies.props +++ b/eng/Dependencies.props @@ -40,6 +40,7 @@ and are generated based on the last package release. + diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 7c6d012ac6ce..2fdc9457efbd 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -97,6 +97,10 @@ https://github.com/dotnet/runtime 7a119156cbe958c5c34098434e84010526fac5f1 + + https://github.com/dotnet/runtime + 7a119156cbe958c5c34098434e84010526fac5f1 + https://github.com/dotnet/runtime 7a119156cbe958c5c34098434e84010526fac5f1 diff --git a/eng/Versions.props b/eng/Versions.props index cfc295665aea..186d0393a653 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -84,6 +84,7 @@ 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 From 17da4df7592a82d70f1fcd5e95a6c67fd655a0cd Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 24 May 2023 14:03:35 -0500 Subject: [PATCH 07/10] Fix test build. Add new assemblies to shared fx --- src/Framework/test/TestData.cs | 4 ++++ src/Shared/Metrics/TestMeterFactory.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Framework/test/TestData.cs b/src/Framework/test/TestData.cs index 98de16bb3587..5e665cc06516 100644 --- a/src/Framework/test/TestData.cs +++ b/src/Framework/test/TestData.cs @@ -119,6 +119,8 @@ static TestData() "Microsoft.Extensions.Configuration.Xml", "Microsoft.Extensions.DependencyInjection", "Microsoft.Extensions.DependencyInjection.Abstractions", + "Microsoft.Extensions.Diagnostics", + "Microsoft.Extensions.Diagnostics.Abstractions", "Microsoft.Extensions.Diagnostics.HealthChecks", "Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions", "Microsoft.Extensions.FileProviders.Abstractions", @@ -268,6 +270,8 @@ static TestData() { "Microsoft.Extensions.Configuration" }, { "Microsoft.Extensions.DependencyInjection.Abstractions" }, { "Microsoft.Extensions.DependencyInjection" }, + { "Microsoft.Extensions.Diagnostics.Abstractions" }, + { "Microsoft.Extensions.Diagnostics" }, { "Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" }, { "Microsoft.Extensions.Diagnostics.HealthChecks" }, { "Microsoft.Extensions.Features" }, diff --git a/src/Shared/Metrics/TestMeterFactory.cs b/src/Shared/Metrics/TestMeterFactory.cs index bac254f5801d..9553f06dce04 100644 --- a/src/Shared/Metrics/TestMeterFactory.cs +++ b/src/Shared/Metrics/TestMeterFactory.cs @@ -6,7 +6,7 @@ namespace Microsoft.AspNetCore.Testing; -internal class TestMeterFactory : IMeterFactory +internal sealed class TestMeterFactory : IMeterFactory { public List Meters { get; } = new List(); @@ -28,7 +28,7 @@ public void Dispose() } } -internal class MeasurementReporter : IDisposable where T : struct +internal sealed class MeasurementReporter : IDisposable where T : struct { private readonly string _meterName; private readonly string _instrumentName; From 39e99485b59e57a393d10bf35b427ad5daf93c56 Mon Sep 17 00:00:00 2001 From: wtgodbe Date: Wed, 24 May 2023 12:12:13 -0700 Subject: [PATCH 08/10] Fix new deps --- eng/Version.Details.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 7db33b4e8004..54ab653893f7 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -287,25 +287,25 @@ 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 1e421670a6456d9c5b924b7ffea14cab8559a2e9 + 7a119156cbe958c5c34098434e84010526fac5f1 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 https://github.com/dotnet/xdt @@ -355,9 +355,9 @@ - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 https://github.com/dotnet/arcade diff --git a/eng/Versions.props b/eng/Versions.props index 70a3bddb6324..21defccc3bf4 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -63,77 +63,77 @@ --> - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 8.0.0-preview.5.23274.1 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 8.0.0-preview.6.23273.4 8.0.0-preview.6.23273.4 From d4bcbb276f6a5d2a01ad93b325ea7fcbcdad4f95 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Thu, 25 May 2023 08:30:53 -0500 Subject: [PATCH 10/10] Update new dependencies to new runtime build --- eng/Version.Details.xml | 8 ++++---- eng/Versions.props | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index f81675c26759..c251f994225a 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -97,13 +97,13 @@ https://github.com/dotnet/runtime 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 - + https://github.com/dotnet/runtime - 7a119156cbe958c5c34098434e84010526fac5f1 + 7cf329b773fa5ed544a9377587018713751c73e3 https://github.com/dotnet/runtime diff --git a/eng/Versions.props b/eng/Versions.props index 21defccc3bf4..58ca8ed98253 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -84,8 +84,8 @@ 8.0.0-preview.5.23274.13 8.0.0-preview.5.23274.13 8.0.0-preview.5.23274.13 - 8.0.0-preview.5.23274.1 - 8.0.0-preview.5.23274.1 + 8.0.0-preview.5.23274.13 + 8.0.0-preview.5.23274.13 8.0.0-preview.5.23274.13 8.0.0-preview.5.23274.13 8.0.0-preview.5.23274.13