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:

  1. 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:

  2. 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.
  3. Check IL-Rewriter to verify whether it is loaded correctly:

    1. 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.
    2. If the IL‑Rewriter lines do not appear, ensure that all required CORECLR environment variables are correctly set and available to the application.

      • CORECLR_ENABLE_PROFILING
      • CORECLR_PROFILER_PATH
      • CORECLR_PROFILER
  4. Check Windows Event Viewer: Use Windows Event Viewer to troubleshoot errors:

    1. Open Event Viewer.
    2. Go to Windows Logs > Application.
    3. Look for errors or warnings that are related to your application or IIS.
    4. Check for Instana-related events.

    Events contain detailed information, including timestamps and error codes that can help diagnose problems.

  5. 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:

  1. Verify that the .NET version of the application is supported:

    • .NET Core Runtime 5.0 or later
  2. Verify that tracing is enabled in the agent configuration.yaml file.
  3. Collect trace logs by using Log Collector or by collecting logs manually.
  4. 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:

  1. Verify that the .NET version of the application is supported:

    • .NET Core Runtime 5.0 or later
  2. Gather Event Viewer logs by using Log Collector or by collecting logs manually.
  3. 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.exe exists, it means that InstanaPCP failed. Check the events preceding it and investigate the issue further.
  4. 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:

  1. Verify that the Instana agent is running as administrator.
  2. Verify that the Instana agent has permissions to the application.
  3. Verify that Instana PCP is running:

    • Open Task Manager on Windows and search for InstanaPCP.
  4. 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
  5. Verify that sensors are successfully activated in the agent logs:

    com.instana.sensor-clr - 1.1.141 |  | Activated Sensor
  6. 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:

  1. Determine whether the issue is related to the application or InstanaPCP by checking the Task Manager.
  2. 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.
  3. 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:

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

Important: .NET Core sensor 1.0.89 or later does not support running the Log Collector tool from the Instana UI. If you are using these versions, run the Log Collector manually from the console to collect logs.
  1. From the navigation menu, select Analytics > Infrastructure or search for the agent from the More menu in the Instana UI.
  2. Click the .NET process to be monitored.
  3. On the .NET process dashboard, click Setup .NET Debug Env as shown in the following image:

    Figure 1. Log Collector
    Log Collector

    This step activates the Log Collector application on the host and sets the required environment variables for the .NET log collection.

  4. 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.
  5. Make some calls or create traffic to the application to generate logs.
  6. 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:

  1. 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
  2. Run the following command to prepare the log collection:

    logcollector.exe -m prepare -i "C:\Program Files\Instana\instana-agent"
  3. Restart the application and make calls to the application.
  4. 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:

  1. Enable debug logs:

    1. 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
    2. Configure the following Windows Registry key:

      CLRDebugLog: "C:\dc_clr_debug_log\clr_"
    3. Restart the application.
  2. Collect Instana agent logs:

    1. Stop the agent <instana_install_dir>/bin/stop.sh or if the agent is started as a service, stop the service.
    2. 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/*
    3. Set the log level to Debug: Change the log level severity in the agent configuration.yaml file. For more information, see Setting up the agent configuration file.
    4. Start the agent <instana_install_dir>/bin/start.sh or start the service.
    5. Reproduce the issue: Allow the issue to occur and run the agent for approximately 15 minutes.
    6. 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 *
  3. Collect Instana trace logs:

    1. Go to [agent-dir]\etc\instana and open the file com.instana.agent.main.sender.File.cfg.
    2. Add the following lines in the file:

      prefix=instanaTraces
      type=traces

      This configuration provides you with a log file that contains all the traces in [agent-dir]/data/log with the instanaTraces prefix.

    3. Restart the Instana agent.
    4. Allow the application to run for approximately 15 minutes.
    5. Collect logs from the following paths:

      • Path specified by the variable INSTANA_NET_LOG_PATH
      • instana-agent-installation-folder/data/log
  4. Collect CLR debug logs:

    1. Open Registry Editor.
    2. Navigate to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Instana\
    3. Add the registry key CLRDebugLog as a string with value, for example, C:\temp\clr_.
    4. 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.