Troubleshooting .NET tracing on Windows
If tracing is not working as expected, start with general troubleshooting steps before you move to case-specific scenarios.
General troubleshooting
Complete the following steps:
-
Verify prerequisites:
- Check .NET version compatibility: Ensure that your application runs on .NET Core Runtime 5.0 or later.
-
Verify that the Instana agent is running:
- Open Task Manager on Windows and look for the Instana agent process.
- Check agent status in the Instana UI.
-
Verify that Instana PCP is running:
- Open Task Manager and search for
InstanaPCP.exe. - If not running, restart the Instana agent.
- Open Task Manager and search for
-
Verify environment variables: If tracing is not working, check the environment variables are:
- Set correctly.
- Spelled accurately.
- Set appropriately for the environment where the application is deployed.
- Valid, accessible by the process or application, and correct.
-
Check IL-Rewriter to verify whether it is loaded correctly:
-
Check application logs for IL-Rewriter initialization messages. Expected output when successful:
*Initializing Instana IL-Rewriter for .NET Core* *Logging path is not set* *Loading configuration-file /app/instana_tracing/instrumentation.json*Note: The path might differ depending on your environment. -
If the IL‑Rewriter lines do not appear, ensure that all required
CORECLRenvironment variables are correctly set and available to the application.- CORECLR_ENABLE_PROFILING
- CORECLR_PROFILER_PATH
- CORECLR_PROFILER
-
-
Check Windows Event Viewer: Use Windows Event Viewer to troubleshoot errors:
- Open Event Viewer.
- Go to Windows Logs > Application.
- Look for errors or warnings that are related to your application or IIS.
- Check for Instana-related events.
Events contain detailed information, including timestamps and error codes that can help diagnose problems.
- Verify that diagnostics are enabled for .NET: Make sure that the environment variables COMPlus_EnableDiagnostics and DOTNET_EnableDiagnostics are set to
1. If they are disabled, the IL-Rewriter cannot attach to the process, and therefore calls cannot be rewritten and traces cannot be generated.
Case-specific troubleshooting
If general troubleshooting doesn't resolve your issue, check out the following troubleshooting scenarios:
Scenario 1: Missing traces or spans
Symptoms: Application shows metrics but no traces, some services report, but others don't, or tracing stops after a deployment or update.
Troubleshooting steps:
-
Verify that the .NET version of the application is supported:
- .NET Core Runtime 5.0 or later
- Verify that tracing is enabled in the agent
configuration.yamlfile. - Collect trace logs by using Log Collector or by collecting logs manually.
-
Check the Instana tracing logs:
- If the logs are empty or no traces are visible, the application is not producing spans.
- If traces are present in the logs but are missing information (for example, host), the problem is with the .NET tracing layer.
- If traces are present in the logs and contain information that is missing in the UI, the problem occurred either in the Instana backend or the agent.
Scenario 2: Application fails to start
Symptom: Application fails on startup when the Instana agent is running.
Troubleshooting steps:
-
Verify that the .NET version of the application is supported:
- .NET Core Runtime 5.0 or later
- Gather Event Viewer logs by using Log Collector or by collecting logs manually.
-
Check the Instana Event Viewer logs:
- Determine whether an error or warning appears in the logs. An event contains detailed information, including timestamps and error codes that can help diagnose problems.
- If an error indicating
InstanaPCP.exeexists, it means that InstanaPCP failed. Check the events preceding it and investigate the issue further.
- Collect a crash dump for the application in question.
Scenario 3: Agent not detecting .NET application
Symptom: The .NET application is not being monitored by the Instana agent and is not present in the UI.
Troubleshooting steps:
- Verify that the Instana agent is running as administrator.
- Verify that the Instana agent has permissions to the application.
-
Verify that Instana PCP is running:
- Open Task Manager on Windows and search for
InstanaPCP.
- Open Task Manager on Windows and search for
-
Collect Instana agent logs by using Log Collector or by collecting logs manually.
-
In the Instana agent logs, the following line should be present:
com.instana.agent-process-handling - 1.0.35 | | InstanaPCP.exe passed early window; marked RUNNING
-
-
Verify that sensors are successfully activated in the agent logs:
com.instana.sensor-clr - 1.1.141 | | Activated Sensor - Verify that the .NET process is started after the Instana agent.
Scenario 4: High CPU for InstanaPCP or application after enabling tracing
Symptom: InstanaPCP or the .NET application shows unusually high CPU usage after tracing is enabled.
Troubleshooting steps:
- Determine whether the issue is related to the application or InstanaPCP by checking the Task Manager.
-
If the issue is with InstanaPCP:
- Enable debug logs for InstanaPCP. See Collecting logs.
- Review the logs for recurring messages about missing performance counters or exceptions.
-
If the issue is an application memory spike:
- Collect Event Logs and .NET logs by using Log Collector or by collecting logs manually.
- Check Event Logs and .NET logs for memory-related exceptions.
- Verify whether the issue is caused by Instana instrumentation.
- Collect a .NET dump file for further analysis. Go to Task Manager, right‑click the process, and create a dump file.
Collecting logs
Instana provides two methods to collect logs:
- Log Collector (suggested)
- Manual log collection (fallback when the Log Collector fails)
Collecting logs by using Log Collector
Log Collector is a stand-alone application to collect logs from Instana. You can trigger the Log Collector from the following locations:
The Log Collector collects the following logs:
- Application tracing logs
- Instana PCP logs
- CLR debug logs
- Event viewer logs
- Instana agent debug logs
- Instana agent traces logs
Running the Log Collector from the Instana UI
- From the navigation menu, select Analytics > Infrastructure or search for the agent from the More menu in the Instana UI.
- Click the .NET process to be monitored.
-
On the .NET process dashboard, click Setup .NET Debug Env as shown in the following image:
Figure 1. Log Collector
This step activates the Log Collector application on the host and sets the required environment variables for the .NET log collection.
- Restart your .NET application to ensure that the updated environment variables are loaded.
Note: To include InstanaPCP logs in the collection, restart the Instana agent as well.
- Make some calls or create traffic to the application to generate logs.
-
Click Download .NET Logs.
Note: The Download .NET Logs button appears only after the debug environment is successfully set up.
The Log Collector gathers logs from multiple sources including application tracing logs (if [agent-dir]\etc\instana\com.instana.agent.main.sender.File.cfg was already configured), InstanaPCP logs (if agent was restarted), CLR debug logs, Event Viewer logs, and Instana agent logs. The collected logs are compressed into a .zip file and downloaded to your system.
Running the Log Collector from the Console
In the case that the UI fails, the Log Collector can be triggered from the console:
-
Go to the log collector path in the Instana agent folder:
C:\\instana-agent\data\repo\com\instana\dotnet-logcollector-win-x64\1.302.1\dotnet-logcollector-win-x64-1.302.1 -
Run the following command to prepare the log collection:
logcollector.exe -m prepare -i "C:\Program Files\Instana\instana-agent" - Restart the application and make calls to the application.
-
After some time, run the collect command:
logcollector.exe -m collect -i "C:\Program Files\Instana\instana-agent" -o "C:\output\log.zip"Note: Make sure that commands are run as an administrator.
Collecting logs manually
Alternatively, you can collect logs manually. Complete the following steps:
-
Enable debug logs:
-
Add environment variables by using one of the following options:
Note: Make sure that paths are valid, accessible by the process or application, and correct.-
Set the following environment variables manually in the system level:
INSTANA_NET_LOG_PATH: "C:\dc_net_log" INSTANA_NET_LOG_LEVEL: DEBUG INSTANA_NET_CORE_LOG_LEVEL: DEBUG INSTANA_NET_FF_LOG_LEVEL: DEBUG INSTANA_NET_PCP_LOG_LEVEL: DEBUG INSTANA_TRACER_ENTEREXIT_LOGGING: 1 INSTANA_EXTENDED_DEBUG: 1 -
Open the command prompt as an administrator and run the following command to add the environment variables:
setx INSTANA_NET_LOG_PATH "C:\dc_net_log" /M setx INSTANA_NET_LOG_LEVEL "DEBUG" /M setx INSTANA_NET_CORE_LOG_LEVEL "DEBUG" /M setx INSTANA_NET_FF_LOG_LEVEL "DEBUG" /M setx INSTANA_NET_PCP_LOG_LEVEL "DEBUG" /M setx INSTANA_TRACER_ENTEREXIT_LOGGING "1" /M setx INSTANA_EXTENDED_DEBUG "1" /M
-
-
Configure the following Windows Registry key:
CLRDebugLog: "C:\dc_clr_debug_log\clr_" - Restart the application.
-
-
Collect Instana agent logs:
- Stop the agent
<instana_install_dir>/bin/stop.shor if the agent is started as a service, stop the service. -
Remove the logs: Delete all files in the log directory to start fresh by running the following command:
rm -rf <instana_install_dir>/data/log/* - Set the log level to Debug: Change the log level severity in the agent
configuration.yamlfile. For more information, see Setting up the agent configuration file. - Start the agent
<instana_install_dir>/bin/start.shor start the service. - Reproduce the issue: Allow the issue to occur and run the agent for approximately 15 minutes.
-
Collect the logs: Compress the logs directory for submission by running the following command:
cd <instana_install_dir>/data/logs zip -r instana_agent_debug_logs.zip *
- Stop the agent
-
Collect Instana trace logs:
- Go to
[agent-dir]\etc\instanaand open the filecom.instana.agent.main.sender.File.cfg. -
Add the following lines in the file:
prefix=instanaTraces type=tracesThis configuration provides you with a log file that contains all the traces in
[agent-dir]/data/logwith theinstanaTracesprefix. - Restart the Instana agent.
- Allow the application to run for approximately 15 minutes.
-
Collect logs from the following paths:
- Path specified by the variable
INSTANA_NET_LOG_PATH instana-agent-installation-folder/data/log
- Path specified by the variable
- Go to
-
Collect CLR debug logs:
- Open Registry Editor.
- Navigate to
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Instana\ - Add the registry key
CLRDebugLogas a string with value, for example,C:\temp\clr_. -
Alternatively, open the command prompt as an administrator and run following command:
reg add "HKLM\SOFTWARE\Instana" /v CLRDebugLog /t REG_SZ /d "C:\temp\clr_" /f
Opening a support ticket
If the problem persists after you complete these troubleshooting steps, collect MustGather data before you open a support ticket. MustGather data helps IBM Support diagnose your issue more efficiently.
For information, see MustGather: Instana .NET Tracer - Windows.