Setting up .NET tracing on IIS
You can set up tracing for .NET applications that are hosted on Internet Information Services (IIS) by using Instana AutoTrace or by manually configuring the environment variables.
For details about the working of .NET monitoring, see How .NET monitoring works.
Before you begin
To set up .NET Core tracing on IIS, complete the following steps:
- Ensure that the Instana agent is running on the host machine. See prerequisites for .NET Core monitoring.
- Verify that Instana PCP is running on the host machine. To check whether Instana PCP is running, use Task Manager on Windows.
- Install .NET Core sensor 1.0.56 or later.
- Check support information.
Enabling tracing
Enable .NET tracing on Windows by using one of the following methods:
Method 1: Enabling auto-tracing
To enable Instana AutoTrace, complete the following steps:
-
Modify the agent
configuration.yamlfile as shown in the following example:# netcore Tracing com.instana.plugin.netcore: tracing: enabled: true -
Run IIS reset to ensure the IIS worker processes load the instrumentation:
iisresetNote: If IIS is not reset, the IIS workers aren't instrumented, and you cannot trace IIS-hosted applications. You must reset IIS even if the application was previously instrumented. -
Start your application. During the discovery startup, the sensor automatically enables the tracing.
Method 2: Enabling tracing manually
For IIS-hosted .NET Core applications, you can manually configure tracing by adding environment variables to the Web.config file.
Complete the following steps to enable tracing manually:
-
Install the following packages in your application:
When the packages are distributed through NuGet.org, you can install them without recompiling the application. Use one of the following methods:
nuget.exeavailable: Restore the packages by usingnuget.exewithout compiling the project that is to be instrumented.nuget.exeunavailable: Download the packages directly, extract them, and then set the environment variables to point to the extracted files as described in the following step.
Note: You can add theInstana.Tracing.Core.Rewriter.Windowspackage to your project or add it before publishing. -
Add the following environment variables in the
Web.configfile of the application:<aspNetCore> <environmentVariables> <environmentVariable name="CORECLR_ENABLE_PROFILING" value="1" /> <environmentVariable name="CORECLR_PROFILER" value="{FA8F1DFF-0B62-4F84-887F-ECAC69A65DD3}" /> <environmentVariable name="CORECLR_PROFILER_PATH_64" value="[Path_to_your_app]/instana_tracing/CoreRewriter_x64.dll" /> <environmentVariable name="CORECLR_PROFILER_PATH_32" value="[Path_to_your_app]/instana_tracing/CoreRewriter_x86.dll" /> <environmentVariable name="DOTNET_STARTUP_HOOKS" value="[Path_to_your_app]/Instana.Tracing.Core.dll" /> </environmentVariables> </aspNetCore>Replace
[Path_to_your_app]with the actual path to your application directory. -
After the variables are added, run the
iisresetcommand to reload the IIS worker processes:iisresetNote: If IIS is not reset, the IIS workers aren't instrumented, and you cannot trace IIS-hosted applications. You must reset IIS even if the application was previously instrumented.