Setting up .NET tracing on Windows

You can set up .NET tracing on Windows by using Instana AutoTrace or by manually configuring the environment variables. The .NET Tracer supports host auto tracing on Windows systems except containers.

For details about the working of .NET monitoring, see How .NET monitoring works.

Before you begin

To set up .NET Core tracing on Windows, complete the following steps:

  • Ensure that the Instana agent is running on the host machine. See Installing agent on Windows
  • Verify that Instana PCP is running on the host machine. Instana PCP enables the Instana agent to communicate with your .NET application. To check whether Instana PCP is running, open Task Manager on Windows and look for Instana PCP.
  • Install .NET Core sensor 1.0.56 or later.
  • Check support information.

Enabling .NET tracing

Enable .NET tracing on Windows by using one of the following methods:

Method 1: Enabling auto-tracing

With Instana AutoTrace, Instana automatically detects and instruments your application. You don't need to change any code.

To enable Instana AutoTrace, complete the following steps:

  1. Modify the .NET Core section in the agent configuration.yaml file (*instanaAgentDir*/etc/instana/configuration.yaml) as follows:

    # netcore Tracing
    com.instana.plugin.netcore:
      tracing:
        enabled: true
  2. Start your application.

During the discovery startup, the Instana agent automatically detects your application and begins tracing. No code changes are needed.

To verify whether tracing is working, log in to your Instana dashboard. You can see traces appearing.

Method 2: Enabling tracing manually

Use this method if you need more control or if AutoTrace doesn't work for your setup. This approach involves adding NuGet packages to your application.

To enable tracing manually for a .NET Core application, complete the following steps:

  1. Install the following NuGet packages:

    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. Set the following environment variables at the system level or application level:

    CORECLR_ENABLE_PROFILING=1
    CORECLR_PROFILER={FA8F1DFF-0B62-4F84-887F-ECAC69A65DD3}
    CORECLR_PROFILER_PATH_64=[Path_to_your_app]/instana_tracing/CoreRewriter_x64.dll
    CORECLR_PROFILER_PATH_32=[Path_to_your_app]/instana_tracing/CoreRewriter_x86.dll
    DOTNET_STARTUP_HOOKS=[Path_to_your_app]/Instana.Tracing.Core.dll

    Replace [Path_to_your_app] with the actual path to your application directory.

    1. If your application runs as a Windows service, you can configure tracing through the Windows Registry:

      1. Open Registry Editor and go to:

        HKLM\System\CurrentControlSet\Services\
         
      2. Add a MULTI_SZ as the value for Environment. If the Environment value does not exist, copy the following variables into the file:

        • CORECLR_ENABLE_PROFILING=1
        • CORECLR_PROFILER={FA8F1DFF-0B62-4F84-887F-ECAC69A65DD3}
      3. To set the contents of a MULTI_SZ value, enter one key-value-pair per line as shown in the following example:

        CORECLR_ENABLE_PROFILING=1
        CORECLR_PROFILER={FA8F1DFF-0B62-4F84-887F-ECAC69A65DD3}
        CORECLR_PROFILER_PATH_64=[Path_to_your_app]/instana_tracing/CoreRewriter_x64.dll
        CORECLR_PROFILER_PATH_32=[Path_to_your_app]/instana_tracing/CoreRewriter_x86.dll
        DOTNET_STARTUP_HOOKS=[Path_to_your_app]/Instana.Tracing.Core.dll
         
      4. Press Enter after entering the last line to save the value.

  3. Restart your application to apply the environment variables.