Send .NET application data to Observe

This page describes how to install the Observe Agent, then instrument your .NET applications to send data to Observe.

To view the list of instrumented libraries and compatible versions, see Traces instrumentations in the OpenTelemetry documentation.

To manually instrument custom logic, see Instrumentation in the OpenTelemetry documentation.

Compatibility

.NET 4.6.2+ on the following platforms:

  • x86

  • AMD64 (x86-64)

  • ARM64 (Experimental, CentOS images not supported)

Get the Observe Agent

Use the Add Data portal in the product to get the Observe agent installed in your environment.

  1. From the left navigation rail, select Data & integrations > Add data.

  2. In the Observe Agent section, pick your environment, then follow the instructions to create a data ingest token and install the Observe Agent.

Install the OpenTelemetry zero-code instrumentation for .NET

The instrumentation is distributed via an installer script.

# Download the bash script
curl -sSfL https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/latest/download/otel-dotnet-auto-install.sh -O

# Install core files
sh ./otel-dotnet-auto-install.sh

# Enable execution for the instrumentation script
chmod +x $HOME/.otel-dotnet-auto/instrument.sh

# Setup the instrumentation for the current shell session
. $HOME/.otel-dotnet-auto/instrument.sh

coreutils is required. You can install it with:

brew install coreutils

From here the instructions are the same as for Linux.

Run the following as an administrator in Powershell 5.1+:

# Download the module
$module_url = "https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/latest/download/OpenTelemetry.DotNet.Auto.psm1"
$download_path = Join-Path $env:temp "OpenTelemetry.DotNet.Auto.psm1"
Invoke-WebRequest -Uri $module_url -OutFile $download_path -UseBasicParsing

# Import the module to use its functions
Import-Module $download_path

# Install core files (online vs offline method)
Install-OpenTelemetryCore

Instrument an ASP.NET application deployed on IIS

Run the following in Powershell (note, the final command will cause IIS to restart):

Import-Module "OpenTelemetry.DotNet.Auto.psm1"

Install-OpenTelemetryCore

Register-OpenTelemetryForIIS

Configure the instrumentation

Set the following environment variables. Replace the placeholders such as ${YOUR_SERVICE_NAME} with the actual information from your environment.

OTEL_SERVICE_NAME=${YOUR_SERVICE_NAME}
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=${YOUR_APP_ENVIRONMENT}
OTEL_EXPORTER_OTLP_ENDPOINT=http://${YOUR_OBSERVE_AGENT_ENDPOINT}:4318 

Run your instrumented app

./MyNetApp
.\MyNetApp.exe

Next steps

Navigate to Traces in your Observe tenant to view traces from your application.

Troubleshooting

What to do if you encounter the following issues:

  • Your application data is not reaching Observe

  • Your ports are blocked by a firewall

  • You are getting duplicate spans in Observe

My application data is not reaching Observe

If your data is not showing up in Observe, first verify that Observe Agent is receiving data from your application. See Troubleshooting the Observe Agent.

Common reasons why the Observe agent is not receiving traces from your application:

Ports blocked by firewall

Ensure that any firewalls within the same network as your app and collector are configured to allow traffic on ports 4317 and 4318. The application instrumentation uses these ports to communicate with the Observe agent.

I am getting duplicate spans in Observe

If you’re seeing multiple spans with the same span_id in the Trace Explorer, the cause may be the following:

  • Multiple layers of OTel instrumentation for the same spans

  • Multiple exporters configured (either in your Agent, OTel collector, or application code) that point to Observe

  • Some other pathway in your environment is duplicating data (e.g., proxy or load balancer)