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:
-
Modify the
.NET Coresection in the agentconfiguration.yamlfile (*instanaAgentDir*/etc/instana/configuration.yaml) as follows:# netcore Tracing com.instana.plugin.netcore: tracing: enabled: true - 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:
-
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.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. -
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.dllReplace
[Path_to_your_app]with the actual path to your application directory. -
-
If your application runs as a Windows service, you can configure tracing through the Windows Registry:
-
Open Registry Editor and go to:
HKLM\System\CurrentControlSet\Services\ -
Add a
MULTI_SZas the value for Environment. If the Environment value does not exist, copy the following variables into the file:CORECLR_ENABLE_PROFILING=1CORECLR_PROFILER={FA8F1DFF-0B62-4F84-887F-ECAC69A65DD3}
-
To set the contents of a
MULTI_SZvalue, 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 -
Press Enter after entering the last line to save the value.
-
-
- Restart your application to apply the environment variables.