Setting up .NET tracing on Cloud Foundry

You can set up .NET Core tracing on Cloud Foundry by configuring your application to generate trace data and connecting it to the Instana agent running on Diego cells.

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

Before you begin

Before you enable .NET tracing on Cloud Foundry, ensure that the following prerequisites are met:

  • The Instana agent is running on the Diego cells of the Cloud Foundry foundation. For information on setting up Instana agents and the related Cloud Foundry or Pivotal Platform function, see Cloud Foundry and Pivotal Platform documentation.
  • Review support information.
Note: This setup is applicable only for non self-contained .NET applications on Cloud Foundry.

Enabling .NET tracing

To enable tracing in your .NET Core application hosted on Cloud Foundry, complete the following steps:

Step 1: Add the Instana NuGet package

Add the Instana tracing package to your Cloud Foundry application by running the following command:

dotnet add myproject.csproj package Instana.Tracing.Core.Rewriter.Linux

Replace myproject.csproj with your actual project file name.

Step 2: Prepare the application for publication

Prepare your .NET application for publication by running the following command:

dotnet publish -c Release

This command publishes the application in Release configuration. You can use a different configuration if needed.

Step 3: Configure environment variables (if using a non‑Release configuration)

If a configuration other than Release is used, define the required environment variables in the application manifest (manifest.yml).

---
applications:
- name: <application_name>
  path: bin/Release/<TargetFramework>/publish/
  env:
    DOTNET_STARTUP_HOOKS:[path-to-your-app]/Instana.Tracing.Core.dll
    CORECLR_ENABLE_PROFILING: 1
    CORECLR_PROFILER: "{cf0d821e-299b-5307-a3d8-b283c03916dd}"
    CORECLR_PROFILER_PATH: "/home/vcap/app/instana_tracing/CoreProfiler.so"
    LD_LIBRARY_PATH: "/home/vcap/app/instana_tracing"

Replace <application_name> with your actual application name.

Note: Depending on the .NET SDK that is used and the configuration name that is passed to the dotnet publish command through the -c flag (Release in the example), the value for the path variable might change.

Step 4: Deploy the application to Cloud Foundry

Push your application to Cloud Foundry by running the following command:

cf push
Note: This command assumes that the application manifest.yml file is located in the same folder from which you run the cf push command.

For more information on how to use the cf push command together with a manifest file, see Deploying with App Manifests.

Step 5: Verify that the tracing is working

After you deploy the application, verify that traces are being collected:

  1. From the navigation menu in the Instana UI, select Applications > Services.
  2. Select your monitored service to view the collected traces and insights.