From 3bd2c0f9d17060eff09eb36861f25a7b5fcfe768 Mon Sep 17 00:00:00 2001 From: Claudiu Guiman Date: Fri, 31 May 2024 13:47:41 -0400 Subject: [PATCH] Remove HostingStartup (#6751) --- documentation/api/parameters.md | 2 - dotnet-monitor.sln | 14 --- eng/AfterSolutionBuild.targets | 1 - .../HostingStartup.cs | 31 ------- ...agnostics.Monitoring.HostingStartup.csproj | 45 --------- .../ProjectsToPublish.props | 15 --- .../IMethodDescription.cs | 2 +- .../AspNetHostingStartupLoader.cs | 69 -------------- .../DiagnosticsBootstrapper.cs | 11 --- ....Diagnostics.Monitoring.StartupHook.csproj | 3 - .../IInProcessFeatures.cs | 2 - .../KeyValueLogScope.cs | 4 - .../KeyValueLogScopeExtensions.cs | 8 +- .../Models/CaptureParametersConfiguration.cs | 2 +- .../Models/MethodDescription.cs | 2 +- .../ProfilerMessage.cs | 5 +- ...Monitoring.HostingStartup.UnitTests.csproj | 13 --- ...t.Diagnostics.Monitoring.TestCommon.csproj | 1 - .../TestAppScenarios.cs | 12 --- .../FunctionProbesTests.cs | 2 +- .../HostingStartupTests.cs | 62 ------------- ...ics.Monitoring.Tool.FunctionalTests.csproj | 1 - .../StartupHookTests.cs | 2 +- ....Diagnostics.Monitoring.UnitTestApp.csproj | 1 - .../Program.cs | 1 - .../Scenarios/HostingStartupScenario.cs | 81 ----------------- .../Commands/CollectCommandHandler.cs | 1 - .../HostingStartup/HostingStartupService.cs | 91 ------------------- .../InProcessFeatures/InProcessFeatures.cs | 6 +- ...cessFeaturesEndpointInfoSourceCallbacks.cs | 2 +- .../InProcessFeaturesIdentifiers.cs | 3 +- .../InProcessFeaturesService.cs | 2 +- src/Tools/dotnet-monitor/LoggingExtensions.cs | 11 --- .../CaptureParametersOperation.cs | 9 +- .../Profiler/ProfilerMessagePayloads.cs | 2 +- .../ServiceCollectionExtensions.cs | 8 -- .../StartupHook/StartupHookIdentifiers.cs | 16 ---- src/Tools/dotnet-monitor/Strings.Designer.cs | 27 ------ src/Tools/dotnet-monitor/Strings.resx | 63 ++++++------- .../dotnet-monitor/dotnet-monitor.csproj | 8 -- .../dotnet-monitor-base/Package.props | 1 - 41 files changed, 41 insertions(+), 601 deletions(-) delete mode 100644 src/Microsoft.Diagnostics.Monitoring.HostingStartup/HostingStartup.cs delete mode 100644 src/Microsoft.Diagnostics.Monitoring.HostingStartup/Microsoft.Diagnostics.Monitoring.HostingStartup.csproj delete mode 100644 src/Microsoft.Diagnostics.Monitoring.HostingStartup/ProjectsToPublish.props delete mode 100644 src/Microsoft.Diagnostics.Monitoring.StartupHook/AspNetHostingStartupLoader.cs delete mode 100644 src/Tests/Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests/Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests.csproj delete mode 100644 src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/HostingStartupTests.cs delete mode 100644 src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Scenarios/HostingStartupScenario.cs delete mode 100644 src/Tools/dotnet-monitor/HostingStartup/HostingStartupService.cs delete mode 100644 src/Tools/dotnet-monitor/StartupHook/StartupHookIdentifiers.cs diff --git a/documentation/api/parameters.md b/documentation/api/parameters.md index 2bf5c886d..d20f54313 100644 --- a/documentation/api/parameters.md +++ b/documentation/api/parameters.md @@ -131,8 +131,6 @@ Content-Type: application/x-ndjson - The target application must use ASP.NET Core. - The target application cannot have [Hot Reload](https://learn.microsoft.com/visualstudio/debugger/hot-reload) enabled. - `dotnet-monitor` must be set to `Listen` mode, and the target application must start suspended. See [diagnostic port configuration](../configuration/diagnostic-port-configuration.md) for information on how to do this. -- The target application must have [`ILogger`](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger) available via [ASP.NET Core's dependency injection](https://learn.microsoft.com/aspnet/core/fundamentals/dependency-injection). -- This feature relies on a hosting startup assembly. If the target application [disabled automatic loading](https://learn.microsoft.com/aspnet/core/fundamentals/host/platform-specific-configuration#disable-automatic-loading-of-hosting-startup-assemblies) of these, this feature will not be available. - This feature relies on a [ICorProfilerCallback](https://docs.microsoft.com/dotnet/framework/unmanaged-api/profiling/icorprofilercallback-interface) implementation. If the target application is already using an `ICorProfiler` that isn't notify-only, this feature will not be available. - If a target application is using .NET 7 then the `dotnet-monitor` startup hook must be configured. This is automatically done in .NET 8+. diff --git a/dotnet-monitor.sln b/dotnet-monitor.sln index a44a392a5..338f5bdc0 100644 --- a/dotnet-monitor.sln +++ b/dotnet-monitor.sln @@ -70,10 +70,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monit EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{D3FEE1C0-E1E7-4796-A217-B46E3B6CCCCD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.HostingStartup", "src\Microsoft.Diagnostics.Monitoring.HostingStartup\Microsoft.Diagnostics.Monitoring.HostingStartup.csproj", "{86BDA5CD-6A18-4EC2-9F13-F1A2723DD864}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests", "src\Tests\Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests\Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests.csproj", "{B9216DD7-F216-490A-A388-BBE0EC946EF2}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -188,14 +184,6 @@ Global {E7EA323B-0CFE-4D42-9844-4C322A3BC54A}.Debug|Any CPU.Build.0 = Debug|Any CPU {E7EA323B-0CFE-4D42-9844-4C322A3BC54A}.Release|Any CPU.ActiveCfg = Release|Any CPU {E7EA323B-0CFE-4D42-9844-4C322A3BC54A}.Release|Any CPU.Build.0 = Release|Any CPU - {86BDA5CD-6A18-4EC2-9F13-F1A2723DD864}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {86BDA5CD-6A18-4EC2-9F13-F1A2723DD864}.Debug|Any CPU.Build.0 = Debug|Any CPU - {86BDA5CD-6A18-4EC2-9F13-F1A2723DD864}.Release|Any CPU.ActiveCfg = Release|Any CPU - {86BDA5CD-6A18-4EC2-9F13-F1A2723DD864}.Release|Any CPU.Build.0 = Release|Any CPU - {B9216DD7-F216-490A-A388-BBE0EC946EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B9216DD7-F216-490A-A388-BBE0EC946EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9216DD7-F216-490A-A388-BBE0EC946EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9216DD7-F216-490A-A388-BBE0EC946EF2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -231,8 +219,6 @@ Global {72EC615C-E1BE-4D27-A0FC-C0FEE483D3D2} = {19FAB78C-3351-4911-8F0C-8C6056401740} {E7EA323B-0CFE-4D42-9844-4C322A3BC54A} = {C7568468-1C79-4944-8136-18812A7F9EA7} {D3FEE1C0-E1E7-4796-A217-B46E3B6CCCCD} = {19FAB78C-3351-4911-8F0C-8C6056401740} - {86BDA5CD-6A18-4EC2-9F13-F1A2723DD864} = {19FAB78C-3351-4911-8F0C-8C6056401740} - {B9216DD7-F216-490A-A388-BBE0EC946EF2} = {C7568468-1C79-4944-8136-18812A7F9EA7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {46465737-C938-44FC-BE1A-4CE139EBB5E0} diff --git a/eng/AfterSolutionBuild.targets b/eng/AfterSolutionBuild.targets index af7ca5f7f..809cbd183 100644 --- a/eng/AfterSolutionBuild.targets +++ b/eng/AfterSolutionBuild.targets @@ -3,7 +3,6 @@ - diff --git a/src/Microsoft.Diagnostics.Monitoring.HostingStartup/HostingStartup.cs b/src/Microsoft.Diagnostics.Monitoring.HostingStartup/HostingStartup.cs deleted file mode 100644 index 91ea0e086..000000000 --- a/src/Microsoft.Diagnostics.Monitoring.HostingStartup/HostingStartup.cs +++ /dev/null @@ -1,31 +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.AspNetCore.Hosting; -using Microsoft.Diagnostics.Monitoring.HostingStartup; -using Microsoft.Diagnostics.Tools.Monitor; -using Microsoft.Diagnostics.Tools.Monitor.HostingStartup; -using System.Threading; - -[assembly: HostingStartup(typeof(HostingStartup))] -namespace Microsoft.Diagnostics.Monitoring.HostingStartup -{ - internal sealed class HostingStartup : IHostingStartup - { - public static int InvocationCount; - - public void Configure(IWebHostBuilder builder) - { - builder.ConfigureServices(services => - { - // Keep track of how many times this hosting startup has been invoked for easy - // validation in tests. - Interlocked.Increment(ref InvocationCount); - - // TODO: remove the HostingStartup project. - }); - - ToolIdentifiers.EnableEnvVar(InProcessFeaturesIdentifiers.EnvironmentVariables.AvailableInfrastructure.HostingStartup); - } - } -} diff --git a/src/Microsoft.Diagnostics.Monitoring.HostingStartup/Microsoft.Diagnostics.Monitoring.HostingStartup.csproj b/src/Microsoft.Diagnostics.Monitoring.HostingStartup/Microsoft.Diagnostics.Monitoring.HostingStartup.csproj deleted file mode 100644 index 904e8f903..000000000 --- a/src/Microsoft.Diagnostics.Monitoring.HostingStartup/Microsoft.Diagnostics.Monitoring.HostingStartup.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - - net6.0 - true - Library - $(DefineConstants);HOSTINGSTARTUP - enable - True - - - - - - - - - - - - - - - - - - - - - - True - True - ParameterCapturingStrings.resx - - - - - - ResXFileCodeGenerator - ParameterCapturingStrings.Designer.cs - - - - diff --git a/src/Microsoft.Diagnostics.Monitoring.HostingStartup/ProjectsToPublish.props b/src/Microsoft.Diagnostics.Monitoring.HostingStartup/ProjectsToPublish.props deleted file mode 100644 index 958e293fe..000000000 --- a/src/Microsoft.Diagnostics.Monitoring.HostingStartup/ProjectsToPublish.props +++ /dev/null @@ -1,15 +0,0 @@ - - - net6.0 - Microsoft.Diagnostics.Monitoring.HostingStartup - $(ArtifactsDir)pub\$(HostingStartupLibraryName)\$(Configuration)\$(HostingStartupTargetFramework)\ - $(HostingStartupPublishPath)$(HostingStartupLibraryName).dll - $(HostingStartupPublishPath)$(HostingStartupLibraryName).pdb - - - - - TargetFramework=$(HostingStartupTargetFramework);RuntimeIdentifier=;PublishDir=$(HostingStartupPublishPath) - - - diff --git a/src/Microsoft.Diagnostics.Monitoring.Options/IMethodDescription.cs b/src/Microsoft.Diagnostics.Monitoring.Options/IMethodDescription.cs index a2c5c1b11..7191e1f99 100644 --- a/src/Microsoft.Diagnostics.Monitoring.Options/IMethodDescription.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/IMethodDescription.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; -#if STARTUPHOOK || HOSTINGSTARTUP +#if STARTUPHOOK namespace Microsoft.Diagnostics.Monitoring.StartupHook.MonitorMessageDispatcher.Models #else namespace Microsoft.Diagnostics.Monitoring.Options diff --git a/src/Microsoft.Diagnostics.Monitoring.StartupHook/AspNetHostingStartupLoader.cs b/src/Microsoft.Diagnostics.Monitoring.StartupHook/AspNetHostingStartupLoader.cs deleted file mode 100644 index 158a17fe3..000000000 --- a/src/Microsoft.Diagnostics.Monitoring.StartupHook/AspNetHostingStartupLoader.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; -using System.IO; -using System.Reflection; -using System.Runtime.Loader; - -namespace Microsoft.Diagnostics.Monitoring.StartupHook -{ - internal sealed class AspNetHostingStartupLoader : IDisposable - { - private readonly string _filePath; - private readonly string _simpleAssemblyName; - - private long _disposedState; - - public AspNetHostingStartupLoader(string filePath) - { - _filePath = filePath; - _simpleAssemblyName = CalculateSimpleAssemblyName(filePath); - - RegisterHostingStartupAssembly(_simpleAssemblyName); - AssemblyLoadContext.Default.Resolving += AssemblyResolver; - } - - private Assembly? AssemblyResolver(AssemblyLoadContext context, AssemblyName assemblyName) - { - if (_simpleAssemblyName.Equals(assemblyName.Name, StringComparison.OrdinalIgnoreCase)) - { - return AssemblyLoadContext.Default.LoadFromAssemblyPath(_filePath); - } - - return null; - } - - private static string CalculateSimpleAssemblyName(string filePath) - { - string fileName = Path.GetFileName(filePath); - const string dllExtension = ".dll"; - if (dllExtension.Equals(Path.GetExtension(fileName), StringComparison.OrdinalIgnoreCase)) - { - return fileName[..^dllExtension.Length]; - } - - return fileName; - } - - private static void RegisterHostingStartupAssembly(string simpleAssemblyName) - { - const string HostingStartupEnvVariable = "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES"; - // aspnetcore explicitly uses ; as the delimiter for the above environment variable. - // ref: https://github.com/dotnet/aspnetcore/blob/898c164a1f537a8210a26eaf388bdc92531f6b09/src/Hosting/Hosting/src/Internal/WebHostOptions.cs#L79 - const char Delimiter = ';'; - - string? curValue = Environment.GetEnvironmentVariable(HostingStartupEnvVariable); - string newValue = string.IsNullOrWhiteSpace(curValue) ? simpleAssemblyName : string.Concat(curValue, Delimiter, simpleAssemblyName); - Environment.SetEnvironmentVariable(HostingStartupEnvVariable, newValue); - } - - public void Dispose() - { - if (!DisposableHelper.CanDispose(ref _disposedState)) - return; - - AssemblyLoadContext.Default.Resolving -= AssemblyResolver; - } - } -} diff --git a/src/Microsoft.Diagnostics.Monitoring.StartupHook/DiagnosticsBootstrapper.cs b/src/Microsoft.Diagnostics.Monitoring.StartupHook/DiagnosticsBootstrapper.cs index 66d068615..080201c31 100644 --- a/src/Microsoft.Diagnostics.Monitoring.StartupHook/DiagnosticsBootstrapper.cs +++ b/src/Microsoft.Diagnostics.Monitoring.StartupHook/DiagnosticsBootstrapper.cs @@ -5,11 +5,9 @@ using Microsoft.Diagnostics.Monitoring.StartupHook.Exceptions; using Microsoft.Diagnostics.Monitoring.StartupHook.Monitoring; using Microsoft.Diagnostics.Monitoring.StartupHook.ParameterCapturing; using Microsoft.Diagnostics.Tools.Monitor; -using Microsoft.Diagnostics.Tools.Monitor.HostingStartup; using Microsoft.Diagnostics.Tools.Monitor.Profiler; using Microsoft.Diagnostics.Tools.Monitor.StartupHook; using System; -using System.IO; using MessageDispatcher = Microsoft.Diagnostics.Monitoring.StartupHook.MonitorMessageDispatcher; namespace Microsoft.Diagnostics.Monitoring.StartupHook @@ -18,7 +16,6 @@ namespace Microsoft.Diagnostics.Monitoring.StartupHook IDisposable { private readonly CurrentAppDomainExceptionProcessor _exceptionProcessor; - private readonly AspNetHostingStartupLoader? _hostingStartupLoader; private readonly ParameterCapturingService? _parameterCapturingService; private long _disposedState; @@ -30,13 +27,6 @@ namespace Microsoft.Diagnostics.Monitoring.StartupHook using IDisposable _ = MonitorExecutionContextTracker.MonitorScope(); - string? hostingStartupPath = Environment.GetEnvironmentVariable(StartupHookIdentifiers.EnvironmentVariables.HostingStartupPath); - // TODO: Log if specified hosting startup assembly doesn't exist - if (File.Exists(hostingStartupPath)) - { - _hostingStartupLoader = new AspNetHostingStartupLoader(hostingStartupPath); - } - try { // Check that the profiler is loaded before establishing the dispatcher, which has a dependency on the existence of the profiler @@ -68,7 +58,6 @@ namespace Microsoft.Diagnostics.Monitoring.StartupHook _exceptionProcessor.Dispose(); _parameterCapturingService?.Stop(); _parameterCapturingService?.Dispose(); - _hostingStartupLoader?.Dispose(); SharedInternals.MessageDispatcher?.Dispose(); } } diff --git a/src/Microsoft.Diagnostics.Monitoring.StartupHook/Microsoft.Diagnostics.Monitoring.StartupHook.csproj b/src/Microsoft.Diagnostics.Monitoring.StartupHook/Microsoft.Diagnostics.Monitoring.StartupHook.csproj index 8459975bc..353f6c571 100644 --- a/src/Microsoft.Diagnostics.Monitoring.StartupHook/Microsoft.Diagnostics.Monitoring.StartupHook.csproj +++ b/src/Microsoft.Diagnostics.Monitoring.StartupHook/Microsoft.Diagnostics.Monitoring.StartupHook.csproj @@ -14,7 +14,6 @@ - @@ -27,9 +26,7 @@ - - diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/IInProcessFeatures.cs b/src/Microsoft.Diagnostics.Monitoring.WebApi/IInProcessFeatures.cs index e0c7b2123..3ce243d9c 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/IInProcessFeatures.cs +++ b/src/Microsoft.Diagnostics.Monitoring.WebApi/IInProcessFeatures.cs @@ -10,8 +10,6 @@ namespace Microsoft.Diagnostics.Monitoring.WebApi bool IsStartupHookRequired { get; } - bool IsHostingStartupRequired { get; } - bool IsLibrarySharingRequired { get; } } } diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/KeyValueLogScope.cs b/src/Microsoft.Diagnostics.Monitoring.WebApi/KeyValueLogScope.cs index 76f62de66..803953969 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/KeyValueLogScope.cs +++ b/src/Microsoft.Diagnostics.Monitoring.WebApi/KeyValueLogScope.cs @@ -5,11 +5,7 @@ using System.Collections; using System.Collections.Generic; using System.Text; -#if HOSTINGSTARTUP -namespace Microsoft.Diagnostics.Monitoring.HostingStartup -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { // Logger implementations have different ways of serializing log scopes. This class helps those loggers // serialize the scope information in the best way possible for each of the implementations. diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/KeyValueLogScopeExtensions.cs b/src/Microsoft.Diagnostics.Monitoring.WebApi/KeyValueLogScopeExtensions.cs index b94b3e097..43f0f238c 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/KeyValueLogScopeExtensions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.WebApi/KeyValueLogScopeExtensions.cs @@ -2,14 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; - -#if HOSTINGSTARTUP -namespace Microsoft.Diagnostics.Monitoring.HostingStartup -#else using System.Globalization; namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { internal static class KeyValueLogScopeExtensions { @@ -17,7 +12,7 @@ namespace Microsoft.Diagnostics.Monitoring.WebApi { values.Add(new KeyValuePair(key, value)); } -#if !HOSTINGSTARTUP + public static void AddArtifactType(this KeyValueLogScope scope, string artifactType) { scope.Values.Add("ArtifactType", artifactType); @@ -32,6 +27,5 @@ namespace Microsoft.Diagnostics.Monitoring.WebApi ArtifactMetadataNames.ArtifactSource.RuntimeInstanceCookie, endpointInfo.RuntimeInstanceCookie.ToString("N")); } -#endif } } diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/CaptureParametersConfiguration.cs b/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/CaptureParametersConfiguration.cs index e967a080b..e0c4a7181 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/CaptureParametersConfiguration.cs +++ b/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/CaptureParametersConfiguration.cs @@ -5,7 +5,7 @@ using System; using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; -#if STARTUPHOOK || HOSTINGSTARTUP +#if STARTUPHOOK namespace Microsoft.Diagnostics.Monitoring.StartupHook.MonitorMessageDispatcher.Models #else namespace Microsoft.Diagnostics.Monitoring.WebApi.Models diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/MethodDescription.cs b/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/MethodDescription.cs index 62aea680e..8a7b18afc 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/MethodDescription.cs +++ b/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/MethodDescription.cs @@ -4,7 +4,7 @@ using System; using System.ComponentModel.DataAnnotations; -#if STARTUPHOOK || HOSTINGSTARTUP +#if STARTUPHOOK namespace Microsoft.Diagnostics.Monitoring.StartupHook.MonitorMessageDispatcher.Models #else using Microsoft.Diagnostics.Monitoring.Options; diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/ProfilerMessage.cs b/src/Microsoft.Diagnostics.Monitoring.WebApi/ProfilerMessage.cs index 6255ace92..f40475a94 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/ProfilerMessage.cs +++ b/src/Microsoft.Diagnostics.Monitoring.WebApi/ProfilerMessage.cs @@ -6,7 +6,7 @@ using System.Text; using System.Text.Json; -#if STARTUPHOOK || HOSTINGSTARTUP +#if STARTUPHOOK namespace Microsoft.Diagnostics.Monitoring.StartupHook.Monitoring #else namespace Microsoft.Diagnostics.Monitoring @@ -29,9 +29,6 @@ namespace Microsoft.Diagnostics.Monitoring Callstack }; - /// - /// Shared between the StartupHook and HostingStartup assembly. - /// public enum StartupHookCommand : ushort { StartCapturingParameters, diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests/Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests/Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests.csproj deleted file mode 100644 index a20295d2c..000000000 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests/Microsoft.Diagnostics.Monitoring.HostingStartup.UnitTests.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - $(TestTargetFrameworks) - True - enable - - - - - - - diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Microsoft.Diagnostics.Monitoring.TestCommon.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Microsoft.Diagnostics.Monitoring.TestCommon.csproj index a8410dac8..3544d5bfd 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Microsoft.Diagnostics.Monitoring.TestCommon.csproj +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Microsoft.Diagnostics.Monitoring.TestCommon.csproj @@ -33,7 +33,6 @@ - diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/TestAppScenarios.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/TestAppScenarios.cs index f73606f94..fe4766ef2 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/TestAppScenarios.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/TestAppScenarios.cs @@ -120,18 +120,6 @@ namespace Microsoft.Diagnostics.Monitoring.TestCommon } } - public static class HostingStartup - { - public const string Name = nameof(HostingStartup); - - public static class SubScenarios - { - public const string VerifyAspNetAppWithoutHostingStartup = nameof(VerifyAspNetAppWithoutHostingStartup); - public const string VerifyAspNetApp = nameof(VerifyAspNetApp); - public const string VerifyNonAspNetAppNotImpacted = nameof(VerifyNonAspNetAppNotImpacted); - } - } - public static class Stacks { public const string Name = nameof(Stacks); diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/FunctionProbesTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/FunctionProbesTests.cs index df5676931..cea57664c 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/FunctionProbesTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/FunctionProbesTests.cs @@ -4,7 +4,7 @@ using Microsoft.Diagnostics.Monitoring.TestCommon; using Microsoft.Diagnostics.Monitoring.TestCommon.Runners; using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.Fixtures; -using Microsoft.Diagnostics.Tools.Monitor.HostingStartup; +using Microsoft.Diagnostics.Tools.Monitor.StartupHook; using Microsoft.Extensions.DependencyInjection; using System.Collections.Generic; using System.Linq; diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/HostingStartupTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/HostingStartupTests.cs deleted file mode 100644 index fee42ee1b..000000000 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/HostingStartupTests.cs +++ /dev/null @@ -1,62 +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.Diagnostics.Monitoring.TestCommon; -using Microsoft.Diagnostics.Monitoring.TestCommon.Options; -using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.Fixtures; -using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.Runners; -using Microsoft.Diagnostics.Monitoring.WebApi; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using System.Net.Http; -using System.Threading.Tasks; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests -{ - [TargetFrameworkMonikerTrait(TargetFrameworkMonikerExtensions.CurrentTargetFrameworkMoniker)] - [Collection(DefaultCollectionFixture.Name)] - public class HostingStartupTests - { - private readonly IHttpClientFactory _httpClientFactory; - private readonly ITestOutputHelper _outputHelper; - - public HostingStartupTests(ITestOutputHelper outputHelper, ServiceProviderFixture serviceProviderFixture) - { - _httpClientFactory = serviceProviderFixture.ServiceProvider.GetService(); - _outputHelper = outputHelper; - } - - - [Theory] - [InlineData(TestAppScenarios.HostingStartup.SubScenarios.VerifyAspNetApp, true)] - [InlineData(TestAppScenarios.HostingStartup.SubScenarios.VerifyAspNetAppWithoutHostingStartup, false)] - [InlineData(TestAppScenarios.HostingStartup.SubScenarios.VerifyNonAspNetAppNotImpacted, true)] - - public async Task HostingStartupLoadTests(string subScenario, bool tryLoadHostingStartup) - { - await ScenarioRunner.SingleTarget( - _outputHelper, - _httpClientFactory, - DiagnosticPortConnectionMode.Listen, - TestAppScenarios.HostingStartup.Name, - appValidate: (runner, client) => { return Task.CompletedTask; }, - configureApp: runner => - { - runner.EnableMonitorStartupHook = true; - }, - configureTool: runner => - { - runner.ConfigurationFromEnvironment.EnableInProcessFeatures(); - // Enable a feature that requires the hosting startup assembly. - runner.ConfigurationFromEnvironment.InProcessFeatures.ParameterCapturing = new() - { - Enabled = tryLoadHostingStartup - }; - }, - profilerLogLevel: LogLevel.Trace, - subScenarioName: subScenario); - } - } -} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.csproj index 3b6326396..c2373b90b 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.csproj +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.csproj @@ -85,7 +85,6 @@ - diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.UnitTests/StartupHookTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.UnitTests/StartupHookTests.cs index 25358ee9d..d9cf19c26 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.UnitTests/StartupHookTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.UnitTests/StartupHookTests.cs @@ -4,7 +4,7 @@ using Microsoft.Diagnostics.Monitoring.TestCommon; using Microsoft.Diagnostics.Monitoring.TestCommon.Runners; using Microsoft.Diagnostics.NETCore.Client; -using Microsoft.Diagnostics.Tools.Monitor.HostingStartup; +using Microsoft.Diagnostics.Tools.Monitor.StartupHook; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Microsoft.Diagnostics.Monitoring.UnitTestApp.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Microsoft.Diagnostics.Monitoring.UnitTestApp.csproj index dee001131..cd3ab6d95 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Microsoft.Diagnostics.Monitoring.UnitTestApp.csproj +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Microsoft.Diagnostics.Monitoring.UnitTestApp.csproj @@ -12,7 +12,6 @@ - diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Program.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Program.cs index 256bdd5cf..f5cfd0d8d 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Program.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Program.cs @@ -22,7 +22,6 @@ namespace Microsoft.Diagnostics.Monitoring.UnitTestApp FunctionProbesScenario.Command(), LoggerScenario.Command(), ParameterCapturingScenario.Command(), - HostingStartupScenario.Command(), SpinWaitScenario.Command(), EnvironmentVariablesScenario.Command(), StacksScenario.Command(), diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Scenarios/HostingStartupScenario.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Scenarios/HostingStartupScenario.cs deleted file mode 100644 index 582aeab61..000000000 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.UnitTestApp/Scenarios/HostingStartupScenario.cs +++ /dev/null @@ -1,81 +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.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.Diagnostics.Monitoring.TestCommon; -using Microsoft.Extensions.DependencyInjection; -using System.CommandLine; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Diagnostics.Monitoring.UnitTestApp.Scenarios -{ - internal sealed class HostingStartupScenario - { - public static CliCommand Command() - { - CliCommand aspnetAppNoHostingStartupCommand = new(TestAppScenarios.HostingStartup.SubScenarios.VerifyAspNetAppWithoutHostingStartup); - aspnetAppNoHostingStartupCommand.SetAction(VerifyAspNetAppWithoutHostingStartupAsync); - - CliCommand aspnetAppCommand = new(TestAppScenarios.HostingStartup.SubScenarios.VerifyAspNetApp); - aspnetAppCommand.SetAction(VerifyAspNetAppAsync); - - CliCommand nonAspNetAppCommand = new(TestAppScenarios.HostingStartup.SubScenarios.VerifyNonAspNetAppNotImpacted); - nonAspNetAppCommand.SetAction(VerifyNonAspNetAppNotImpactedAsync); - - CliCommand scenarioCommand = new(TestAppScenarios.HostingStartup.Name); - scenarioCommand.Subcommands.Add(aspnetAppNoHostingStartupCommand); - scenarioCommand.Subcommands.Add(aspnetAppCommand); - scenarioCommand.Subcommands.Add(nonAspNetAppCommand); - return scenarioCommand; - } - - public static Task VerifyNonAspNetAppNotImpactedAsync(ParseResult result, CancellationToken token) - { - return ScenarioHelpers.RunScenarioAsync(logger => - { - Assert.Equal(0, HostingStartup.HostingStartup.InvocationCount); - return Task.FromResult(0); - }, token); - } - - public static Task VerifyAspNetAppWithoutHostingStartupAsync(ParseResult result, CancellationToken token) - { - return ScenarioHelpers.RunWebScenarioAsync(logger => - { - Assert.Equal(0, HostingStartup.HostingStartup.InvocationCount); - return Task.FromResult(0); - }, token); - } - - public static Task VerifyAspNetAppAsync(ParseResult result, CancellationToken token) - { - return ScenarioHelpers.RunWebScenarioAsync(logger => - { - Assert.Equal(1, HostingStartup.HostingStartup.InvocationCount); - return Task.FromResult(0); - }, token); - } - - private sealed class Startup - { - public static void ConfigureServices(IServiceCollection services) - { - services.AddControllers(); - } - - public static void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - endpoints.MapGet("/", () => Results.Ok()); - }); - } - } - } -} diff --git a/src/Tools/dotnet-monitor/Commands/CollectCommandHandler.cs b/src/Tools/dotnet-monitor/Commands/CollectCommandHandler.cs index 799ff74c8..32b2f930c 100644 --- a/src/Tools/dotnet-monitor/Commands/CollectCommandHandler.cs +++ b/src/Tools/dotnet-monitor/Commands/CollectCommandHandler.cs @@ -133,7 +133,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor.Commands services.ConfigureLibrarySharing(); services.ConfigureProfiler(); services.ConfigureStartupHook(); - services.ConfigureHostingStartup(); services.ConfigureExceptions(); services.ConfigureStartupLoggers(authConfigurator); services.ConfigureInProcessFeatures(context.Configuration); diff --git a/src/Tools/dotnet-monitor/HostingStartup/HostingStartupService.cs b/src/Tools/dotnet-monitor/HostingStartup/HostingStartupService.cs deleted file mode 100644 index 9836d4b2f..000000000 --- a/src/Tools/dotnet-monitor/HostingStartup/HostingStartupService.cs +++ /dev/null @@ -1,91 +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.Diagnostics.Monitoring.WebApi; -using Microsoft.Diagnostics.NETCore.Client; -using Microsoft.Diagnostics.Tools.Monitor.LibrarySharing; -using Microsoft.Diagnostics.Tools.Monitor.StartupHook; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Logging; -using System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.Diagnostics.Tools.Monitor.HostingStartup -{ - internal sealed class HostingStartupService - : IDiagnosticLifetimeService - { - // Intent is to ship a single TFM of the hosting startup, which should be the lowest supported version. - private const string HostingStartupFileName = "Microsoft.Diagnostics.Monitoring.HostingStartup.dll"; - private const string HostingStartupTargetFramework = "net6.0"; - - private readonly IEndpointInfo _endpointInfo; - private readonly StartupHookService _startupHookService; - private readonly IInProcessFeatures _inProcessFeatures; - private readonly ISharedLibraryService _sharedLibraryService; - private readonly ILogger _logger; - - public HostingStartupService( - IEndpointInfo endpointInfo, - StartupHookService startupHookService, - ISharedLibraryService sharedLibraryService, - IInProcessFeatures inProcessFeatures, - ILogger logger) - { - _endpointInfo = endpointInfo; - _startupHookService = startupHookService; - _inProcessFeatures = inProcessFeatures; - _sharedLibraryService = sharedLibraryService; - _logger = logger; - } - - public async ValueTask StartAsync(CancellationToken cancellationToken) - { - if (!_inProcessFeatures.IsHostingStartupRequired) - { - return; - } - - // Hosting startup is only supported on .NET 6+ - if (_endpointInfo.RuntimeVersion == null || _endpointInfo.RuntimeVersion.Major < 6) - { - return; - } - - try - { - // Hosting startup requires the startup hook - if (!await _startupHookService.Applied.WaitAsync(cancellationToken)) - { - return; - } - - IFileProviderFactory fileProviderFactory = await _sharedLibraryService.GetFactoryAsync(cancellationToken); - IFileProvider managedFileProvider = fileProviderFactory.CreateManaged(HostingStartupTargetFramework); - - IFileInfo hostingStartupLibraryFileInfo = managedFileProvider.GetFileInfo(HostingStartupFileName); - if (!hostingStartupLibraryFileInfo.Exists) - { - throw new FileNotFoundException(Strings.ErrorMessage_UnableToFindHostingStartupAssembly, hostingStartupLibraryFileInfo.Name); - } - - DiagnosticsClient client = new DiagnosticsClient(_endpointInfo.Endpoint); - await client.SetEnvironmentVariableAsync( - StartupHookIdentifiers.EnvironmentVariables.HostingStartupPath, - hostingStartupLibraryFileInfo.PhysicalPath, - cancellationToken); - } - catch (Exception ex) - { - _logger.UnableToApplyHostingStartup(ex); - } - } - - public ValueTask StopAsync(CancellationToken cancellationToken) - { - return ValueTask.CompletedTask; - } - } -} diff --git a/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeatures.cs b/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeatures.cs index 55f99c6d7..8d48f0313 100644 --- a/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeatures.cs +++ b/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeatures.cs @@ -32,10 +32,8 @@ namespace Microsoft.Diagnostics.Tools.Monitor public bool IsMutatingProfilerRequired => IsParameterCapturingEnabled; - public bool IsStartupHookRequired => IsHostingStartupRequired || IsExceptionsEnabled; + public bool IsStartupHookRequired => IsParameterCapturingEnabled || IsExceptionsEnabled; - public bool IsHostingStartupRequired => IsParameterCapturingEnabled; - - public bool IsLibrarySharingRequired => IsProfilerRequired || IsStartupHookRequired || IsHostingStartupRequired; + public bool IsLibrarySharingRequired => IsProfilerRequired || IsStartupHookRequired; } } diff --git a/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesEndpointInfoSourceCallbacks.cs b/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesEndpointInfoSourceCallbacks.cs index f194c6bf7..0c3aa4449 100644 --- a/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesEndpointInfoSourceCallbacks.cs +++ b/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesEndpointInfoSourceCallbacks.cs @@ -5,7 +5,7 @@ using Microsoft.Diagnostics.Monitoring.WebApi; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.Diagnostics.Tools.Monitor.HostingStartup +namespace Microsoft.Diagnostics.Tools.Monitor.StartupHook { internal sealed class InProcessFeaturesEndpointInfoSourceCallbacks : IEndpointInfoSourceCallbacks { diff --git a/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesIdentifiers.cs b/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesIdentifiers.cs index 3e2606a04..c4e2118d2 100644 --- a/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesIdentifiers.cs +++ b/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesIdentifiers.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -namespace Microsoft.Diagnostics.Tools.Monitor.HostingStartup +namespace Microsoft.Diagnostics.Tools.Monitor.StartupHook { public static class InProcessFeaturesIdentifiers { @@ -26,7 +26,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor.HostingStartup private const string AvailableInfrastructurePrefix = InProcessFeaturesPrefix + "AvailableInfrastructure_"; public const string ManagedMessaging = AvailableInfrastructurePrefix + nameof(ManagedMessaging); public const string StartupHook = AvailableInfrastructurePrefix + nameof(StartupHook); - public const string HostingStartup = AvailableInfrastructurePrefix + nameof(HostingStartup); } } } diff --git a/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesService.cs b/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesService.cs index bd5d37b83..4311f8a5b 100644 --- a/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesService.cs +++ b/src/Tools/dotnet-monitor/InProcessFeatures/InProcessFeaturesService.cs @@ -11,7 +11,7 @@ using System; using System.Threading; using System.Threading.Tasks; -namespace Microsoft.Diagnostics.Tools.Monitor.HostingStartup +namespace Microsoft.Diagnostics.Tools.Monitor.StartupHook { internal sealed class InProcessFeaturesService { diff --git a/src/Tools/dotnet-monitor/LoggingExtensions.cs b/src/Tools/dotnet-monitor/LoggingExtensions.cs index 0a44b6556..5578be3ce 100644 --- a/src/Tools/dotnet-monitor/LoggingExtensions.cs +++ b/src/Tools/dotnet-monitor/LoggingExtensions.cs @@ -512,12 +512,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor logLevel: LogLevel.Debug, formatString: Strings.LogFormatString_EndpointRemovalFailed); - private static readonly Action _unableToApplyHostingStartup = - LoggerMessage.Define( - eventId: LoggingEventIds.UnableToApplyHostingStartup.EventId(), - logLevel: LogLevel.Error, - formatString: Strings.LogFormatString_UnableToApplyHostingStartup); - private static readonly Action _unableToApplyInProcessFeatureFlags = LoggerMessage.Define( eventId: LoggingEventIds.UnableToApplyInProcessFeatureFlags.EventId(), @@ -954,11 +948,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor _endpointRemovalFailed(logger, processId, ex); } - public static void UnableToApplyHostingStartup(this ILogger logger, Exception ex) - { - _unableToApplyHostingStartup(logger, ex); - } - public static void UnableToApplyInProcessFeatureFlags(this ILogger logger, Exception ex) { _unableToApplyInProcessFeatureFlags(logger, ex); diff --git a/src/Tools/dotnet-monitor/ParameterCapturing/CaptureParametersOperation.cs b/src/Tools/dotnet-monitor/ParameterCapturing/CaptureParametersOperation.cs index f8c9dcc12..12c32830b 100644 --- a/src/Tools/dotnet-monitor/ParameterCapturing/CaptureParametersOperation.cs +++ b/src/Tools/dotnet-monitor/ParameterCapturing/CaptureParametersOperation.cs @@ -6,8 +6,8 @@ using Microsoft.Diagnostics.Monitoring.Options; using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Monitoring.WebApi.Models; using Microsoft.Diagnostics.NETCore.Client; -using Microsoft.Diagnostics.Tools.Monitor.HostingStartup; using Microsoft.Diagnostics.Tools.Monitor.Profiler; +using Microsoft.Diagnostics.Tools.Monitor.StartupHook; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -94,13 +94,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor.ParameterCapturing IDictionary env = await client.GetProcessEnvironmentAsync(token); - const string PreventHostingStartupEnvName = "ASPNETCORE_PREVENTHOSTINGSTARTUP"; - if (env.TryGetValue(PreventHostingStartupEnvName, out string preventHostingStartupEnvValue) && - ToolIdentifiers.IsEnvVarValueEnabled(preventHostingStartupEnvValue)) - { - throw getNotAvailableException(Strings.ParameterCapturingNotAvailable_Reason_PreventedHostingStartup); - } - if (!env.TryGetValue(InProcessFeaturesIdentifiers.EnvironmentVariables.AvailableInfrastructure.ManagedMessaging, out string isManagedMessagingAvailable) || !ToolIdentifiers.IsEnvVarValueEnabled(isManagedMessagingAvailable)) { diff --git a/src/Tools/dotnet-monitor/Profiler/ProfilerMessagePayloads.cs b/src/Tools/dotnet-monitor/Profiler/ProfilerMessagePayloads.cs index ded6c17f0..ed648f8ad 100644 --- a/src/Tools/dotnet-monitor/Profiler/ProfilerMessagePayloads.cs +++ b/src/Tools/dotnet-monitor/Profiler/ProfilerMessagePayloads.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if STARTUPHOOK || HOSTINGSTARTUP +#if STARTUPHOOK using Microsoft.Diagnostics.Monitoring.StartupHook.MonitorMessageDispatcher.Models; #else using Microsoft.Diagnostics.Monitoring.WebApi.Models; diff --git a/src/Tools/dotnet-monitor/ServiceCollectionExtensions.cs b/src/Tools/dotnet-monitor/ServiceCollectionExtensions.cs index 159ad6037..0844ce7aa 100644 --- a/src/Tools/dotnet-monitor/ServiceCollectionExtensions.cs +++ b/src/Tools/dotnet-monitor/ServiceCollectionExtensions.cs @@ -26,7 +26,6 @@ using Microsoft.Diagnostics.Tools.Monitor.Egress.Extension; using Microsoft.Diagnostics.Tools.Monitor.Egress.FileSystem; using Microsoft.Diagnostics.Tools.Monitor.Exceptions; using Microsoft.Diagnostics.Tools.Monitor.Extensibility; -using Microsoft.Diagnostics.Tools.Monitor.HostingStartup; using Microsoft.Diagnostics.Tools.Monitor.LibrarySharing; using Microsoft.Diagnostics.Tools.Monitor.ParameterCapturing; using Microsoft.Diagnostics.Tools.Monitor.Profiler; @@ -358,13 +357,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor return services; } - public static IServiceCollection ConfigureHostingStartup(this IServiceCollection services) - { - services.AddScoped(); - services.AddScopedForwarder(); - return services; - } - public static IServiceCollection ConfigureStartupHook(this IServiceCollection services) { services.AddScoped(); diff --git a/src/Tools/dotnet-monitor/StartupHook/StartupHookIdentifiers.cs b/src/Tools/dotnet-monitor/StartupHook/StartupHookIdentifiers.cs deleted file mode 100644 index 5c5818920..000000000 --- a/src/Tools/dotnet-monitor/StartupHook/StartupHookIdentifiers.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.Diagnostics.Tools.Monitor.StartupHook -{ - public static class StartupHookIdentifiers - { - public static class EnvironmentVariables - { - private const string StartupHookPrefix = ToolIdentifiers.StandardPrefix + "StartupHook_"; - - // The full path of a HostingStartup assembly to load into a target process. - public const string HostingStartupPath = StartupHookPrefix + nameof(HostingStartupPath); - } - } -} diff --git a/src/Tools/dotnet-monitor/Strings.Designer.cs b/src/Tools/dotnet-monitor/Strings.Designer.cs index af49d4f19..bf9c5d8a9 100644 --- a/src/Tools/dotnet-monitor/Strings.Designer.cs +++ b/src/Tools/dotnet-monitor/Strings.Designer.cs @@ -538,15 +538,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor { } } - /// - /// Looks up a localized string similar to Unable to find hosting startup assembly at determined path.. - /// - internal static string ErrorMessage_UnableToFindHostingStartupAssembly { - get { - return ResourceManager.GetString("ErrorMessage_UnableToFindHostingStartupAssembly", resourceCulture); - } - } - /// /// Looks up a localized string similar to Unable to find profiler assembly at determined path.. /// @@ -1519,15 +1510,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor { } } - /// - /// Looks up a localized string similar to Unable to apply hosting startup.. - /// - internal static string LogFormatString_UnableToApplyHostingStartup { - get { - return ResourceManager.GetString("LogFormatString_UnableToApplyHostingStartup", resourceCulture); - } - } - /// /// Looks up a localized string similar to Unable to apply in process feature flags.. /// @@ -1672,15 +1654,6 @@ namespace Microsoft.Diagnostics.Tools.Monitor { } } - /// - /// Looks up a localized string similar to The process has prevented hosting startup assemblies from loading using the ASPNETCORE_PREVENTHOSTINGSTARTUP environment variable.. - /// - internal static string ParameterCapturingNotAvailable_Reason_PreventedHostingStartup { - get { - return ResourceManager.GetString("ParameterCapturingNotAvailable_Reason_PreventedHostingStartup", resourceCulture); - } - } - /// /// Looks up a localized string similar to This feature requires the startup hook to be loaded in the target process.. /// diff --git a/src/Tools/dotnet-monitor/Strings.resx b/src/Tools/dotnet-monitor/Strings.resx index a63ac31d4..149fd3abe 100644 --- a/src/Tools/dotnet-monitor/Strings.resx +++ b/src/Tools/dotnet-monitor/Strings.resx @@ -1,17 +1,17 @@  - @@ -897,12 +897,6 @@ 0. providerName: The name of the provider that failed validation. 1. errorMessage: The validation failure message - - Unable to find hosting startup assembly at determined path. - - - Unable to apply hosting startup. - Unable to apply in process feature flags. @@ -927,9 +921,6 @@ 1 Format Parameters: 0. reason: The reason why the feature is unavailable. - - The process has prevented hosting startup assemblies from loading using the ASPNETCORE_PREVENTHOSTINGSTARTUP environment variable. - This feature requires the startup hook to be loaded in the target process. diff --git a/src/Tools/dotnet-monitor/dotnet-monitor.csproj b/src/Tools/dotnet-monitor/dotnet-monitor.csproj index de82ee8ef..241ee3975 100644 --- a/src/Tools/dotnet-monitor/dotnet-monitor.csproj +++ b/src/Tools/dotnet-monitor/dotnet-monitor.csproj @@ -73,7 +73,6 @@ - @@ -118,13 +117,6 @@ tools/$(TargetFramework)/any/shared/any/$(StartupHookTargetFramework) - - - tools/$(TargetFramework)/any/shared/any/$(HostingStartupTargetFramework) - - - tools/$(TargetFramework)/any/shared/any/$(HostingStartupTargetFramework) - diff --git a/src/archives/dotnet-monitor-base/Package.props b/src/archives/dotnet-monitor-base/Package.props index 6a317e717..b82800d81 100644 --- a/src/archives/dotnet-monitor-base/Package.props +++ b/src/archives/dotnet-monitor-base/Package.props @@ -1,7 +1,6 @@ - dotnet-monitor