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:

  1. Modify the agent configuration.yaml file as shown in the following example:

    # netcore Tracing
    com.instana.plugin.netcore:
      tracing:
        enabled: true
  2. Run IIS reset to ensure the IIS worker processes load the instrumentation:

    iisreset
    Note: 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.
  3. 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:

  1. 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.exe available: Restore the packages by using nuget.exe without compiling the project that is to be instrumented.
    • nuget.exe unavailable: 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 the Instana.Tracing.Core.Rewriter.Windows package to your project or add it before publishing.
  2. Add the following environment variables in the Web.config file 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.

  3. After the variables are added, run the iisreset command to reload the IIS worker processes:

    iisreset
    Note: 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.