profiler auto-instrumention not working in IIS10

I would like to use Elastic APM's profiler auto-instrumentation to monitor our .NET application. I first tested it on Windows 10, but the profiling was unsuccessful. I followed the steps described on the official website:

  1. I downloaded the Elastic APM Profiler version 1.30.0 and extracted it to a directory on Windows 10.
  2. I created a basic application using .NET 5.0.408 (which provides a page with a button that, when clicked, uses HttpClient to access Baidu) (the test was functional).
  3. I packaged it into a specific directory.
  4. I enabled IIS features on Windows 10:
  • .NET Extensibility 4.6
  • ASP
  • ASP.NET 4.6
  1. I created an application pool (selected "No Managed Code" for the .NET CLR version and "Integrated" for the managed pipeline mode).
  2. I created a website (assigned port 8081).
  3. I published the application to the specified path of the website, and the application was functional.
  4. I modified the web.config file to add environment variables with the following configuration:
xml<?xml version="1.0" encoding="utf-8"?><configuration>  <location path="." inheritInChildApplications="false">    <system.webServer>      <handlers>        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />      </handlers>      <aspNetCore processPath="dotnet" arguments=".\WebApplication3.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">        <environmentVariables>          <environmentVariable name="ELASTIC_APM_SERVICE_NAME" value="dotnettest" />          <environmentVariable name="COR_ENABLE_PROFILING" value="1" />          <environmentVariable name="COR_PROFILER_PATH" value="D:\agent\elastic_apm_profiler.dll" />          <environmentVariable name="ELASTIC_APM_PROFILER_HOME" value="D:\agent\" />          <environmentVariable name="ELASTIC_APM_PROFILER_INTEGRATIONS" value="D:\agent\integrations.yml" />          <environmentVariable name="ELASTIC_APM_SERVER_URL" value="http://localhost:8200" />          <environmentVariable name="ELASTIC_OTEL_LOG_LEVEL" value="trace" />          <environmentVariable name="ELASTIC_OTEL_LOG_DIRECTORY" value="D:\agent\logs" />          <environmentVariable name="ELASTIC_APM_APPLICATION_PACKAGES" value="D:\IIS\" />          <environmentVariable name="ELASTIC_APM_PROFILER_LOG_DIR" value="D:\agent\log" />          <environmentVariable name="COR_PROFILER" value="{FA65FE15-F085-4681-9B20-95E04F6C03CC}" />        </environmentVariables>      </aspNetCore>    </system.webServer>  </location></configuration>
  1. I restarted the application, and the application was accessible normally, but I did not see any trace data (I had APM Server 7.10 running and configured to output data to Kafka), nor did I see any profiler loading logs.
  2. I restored the web.config and directly configured the variables as system variables, then restarted the application, but still did not see the profiler being loaded.

What could be the possible reasons? Are there any issues with my operations?

As per my response in the GitHub issue:

@ysj2018, Have you viewed the profiler documentation? We provide a script to configure the environment variables against the app pool. Using web.config is untested for ASP.NET Core.

You have used the incorrect environment variables for your app. For ASP.NET Core (.NET 5+) you should be using:

CORECLR_ENABLE_PROFILING = "1"
CORECLR_PROFILER = "{FA65FE15-F085-4681-9B20-95E04F6C03CC}"
CORECLR_PROFILER_PATH = "$profilerHomeDir\elastic_apm_profiler.dll"

COR_PROFILER etc. is for .NET Framework.

Please try using the documented scripting approach to enable profiling, and let us know if you have any issues after that.