Troubleshooting .NET tracing on Linux or Alpine Linux

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:

      • Check agent status by using systemctl status instana-agent.service.
      • Check agent status in the Instana UI.
  2. Verify environment variables: If tracing is not working, check that 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, but these lines must appear at the very beginning of the output of your application.
    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. 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: The application fails on startup when the Instana agent is running.

Troubleshooting steps:

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

    • .NET Core Runtime 5.0 or later
  2. Collect logs by using Log Collector or by collecting logs manually.
  3. Collect crash dump for the application.

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. Collect Instana agent logs by using Log Collector or by collecting logs manually.
  2. Verify that the Instana agent is run as administrator.
  3. Verify that the Instana agent has permissions to monitor the application.
  4. Verify that sensors are successfully activated in the agent logs.

    com.instana.sensor-clr - <version> |  | Activated Sensor
  5. Verify that the .NET process is started after the Instana agent.

Scenario 4: High CPU for application after enabling tracing

Symptom: The .NET application shows unusually high CPU usage after tracing is enabled.

Troubleshooting steps:

  1. Identify the source: Determine whether the issue is related to the application by checking the system monitor.
  2. If an application memory spike is present:

    • Check /var/log and .NET logs for memory-related exceptions.
    • Verify whether the issue is caused by Instana instrumentation.
    • Request a .NET dump file for further analysis.

Collecting logs

Instana provides two methods to collect logs:

Collecting logs by using Log Collector

Note: Log Collector works for .NET Core applications in ARM64 and AARCH64 architecture.

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
  • CLR debug 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.

If the host architecture is AARCH 64 or ARM 64, collect logs by using Log Collector from Instana UI:

  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.

    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.
  5. Make some calls or create traffic to the application to generate logs.
  6. Click Download .NET Logs to collect 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), CLR debug 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

If the Log Collector UI is not working (for host architecture AARCH64 or ARM64), trigger the Log Collector from the console:

  1. Go to the directory location of Log Collector in the Agent folder. Select the latest version:

    • For AARCH 64:

      cd <path_to_instana>/data/repo/com/instana/clr-logcollector-libs/latest-release#/clr-logcollector-libs-<latest-release#>/linux-x64
    • For ARM64:

      cd <path_to_instana>/data/repo/com/instana/clr-logcollector-libs/latest-release#/clr-logcollector-libs-<latest-release#>/linux-arm64
  2. Prepare mode: Set up the environment variables before you run the application:

    sudo chmod +x ./LogCollector
    sudo ./LogCollector -m prepare -i "/opt/instana"
  3. Run the client application: Start the client application that needs to be monitored after preparation.
  4. Collect mode: After stopping the client application, collect logs:

    ./LogCollector -m collect -i "<path_to_instana>" -o "<path_to_log>/log.zip"

Collecting logs manually

Alternatively, you can collect logs manually without using the log collector. Complete the following steps:

  1. Enable debug logs: Set the following environment variables manually at the system level and restart the application:

    export INSTANA_NET_LOG_PATH="<Log_path>"
    export INSTANA_NET_LOG_LEVEL=DEBUG
    export INSTANA_NET_CORE_LOG_LEVEL=DEBUG
    export INSTANA_TRACER_ENTEREXIT_LOGGING=1
    export INSTANA_EXTENDED_DEBUG=1
    export INSTANA_CLRLOG_PATH=/var/tmp/clr_
  2. Collect Instana agent logs:

    1. Stop the agent:

      sudo systemctl stop instana-agent.service
    2. Wipe the logs: Delete all files in the logs directory to start fresh:

      sudo rm -rf <instana_install_dir>/data/logs/*
    3. Set the log level to debug: Change the log level severity in the configuration file:

      Update log level in <instanaAgentDir>/etc/org.ops4j.pax.logging.cfg configuration file from log4j2.logger.instana.level=INFO to log4j2.logger.instana.level=DEBUG.

      Important: Ensure that the line has no trailing white space.
    4. Start the agent:

      sudo systemctl start instana-agent.service
    5. Check logs in the log folder and collect the logs: Compress the logs directory for submission:

      cd <instana_install_dir>/data/logs/
      zip -r instana_agent_debug_logs.zip *

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 - Linux.