Instrument your .NET application for Splunk Observability Cloud (OpenTelemetry) π
The Splunk Distribution of OpenTelemetry .NET automatically instruments .NET applications, Windows services running .NET applications, and ASP.NET applications deployed on IIS.
To get started, use the guided setup, follow the instructions manually, or auto-instrument your application. See Splunk OpenTelemetry Zero Configuration Auto Instrumentation for .NET for more information.
Generate customized instructions using the guided setup π
To generate all the basic installation commands for your environment and application, use the .NET OpenTelemetry guided setup. To access the .NET OpenTelemetry guided setup, follow these steps:
Log in to Splunk Observability Cloud.
Open the .NET OpenTelemetry guided setup . Optionally, you can navigate to the guided setup on your own:
In the navigation menu, select
.Select Add Integration to open the Integrate Your Data page.
In the integration filter menu, select By Product.
Select the APM product.
Select the .NET (OpenTelemetry) tile to open the .NET OpenTelemetry guided setup.
Install the Splunk Distribution of OpenTelemetry .NET manually π
Follow these instructions to install the Splunk Distribution of OpenTelemetry .NET:
To install the distribution using the official NuGet packages, see Install the OpenTelemetry .NET instrumentation using the NuGet packages.
Instrument your .NET application π
Follow these steps to automatically instrument your application:
Windows π
Check that you meet the requirements. See OpenTelemetry .NET instrumentation compatibility and requirements.
(Optional) If needed, uninstall the SignalFx Instrumentation for .NET. See Uninstall the SignalFx Instrumentation for .NET.
Download and install the Splunk Distribution of OpenTelemetry .NET from the Releases page on GitHub . For example:
# Download and import the PowerShell module $module_url = "https://github.com/signalfx/splunk-otel-dotnet/releases/latest/download/Splunk.OTel.DotNet.psm1" $download_path = Join-Path $env:temp "Splunk.OTel.DotNet.psm1" Invoke-WebRequest -Uri $module_url -OutFile $download_path Import-Module $download_path # Install the Splunk distribution using the PowerShell module Install-OpenTelemetryCore
Register the distribution:
# Set up environment to start instrumentation from the current PowerShell session Register-OpenTelemetryForCurrentSession -OTelServiceName "<your-service-name>"
# Set up IIS instrumentation # IIS is restarted as a result Register-OpenTelemetryForIIS
# Set up your Windows Service instrumentation Register-OpenTelemetryForWindowsService -WindowsServiceName "<your-windows-service-name>"
Set the environment and service version resource attributes:
# You can also set this in web.config or app.config $env:OTEL_RESOURCE_ATTRIBUTES='deployment.environment=<envtype>,service.version=<version>'
Run your application.
If no data appears in APM, see Troubleshoot .NET instrumentation for Splunk Observability Cloud.
Note
If you need to add custom attributes to spans or want to manually generate spans and metrics, instrument your .NET application or service manually. See Manually instrument .NET applications for Splunk Observability Cloud.
Linux π
Check that you meet the requirements. See OpenTelemetry .NET instrumentation compatibility and requirements.
(Optional) If needed, uninstall the SignalFx Instrumentation for .NET. See Uninstall the SignalFx Instrumentation for .NET.
Download and install the installation script of the Splunk Distribution of OpenTelemetry .NET from the Releases page on GitHub . For example:
curl -sSfL https://github.com/signalfx/splunk-otel-dotnet/releases/latest/download/splunk-otel-dotnet-install.sh -O # Install the distribution sh ./splunk-otel-dotnet-install.sh
Activate the automatic instrumentation:
# Activate the automatic instrumentation . $HOME/.splunk-otel-dotnet/instrument.sh
Set the environment and service version resource attributes:
export OTEL_RESOURCE_ATTRIBUTES='deployment.environment=<envtype>,service.version=<version>'
Run your application.
If no data appears in APM, see Troubleshoot .NET instrumentation for Splunk Observability Cloud.
Note
If you need to add custom attributes to spans or want to manually generate spans, instrument your .NET application or service manually. See Manually instrument .NET applications for Splunk Observability Cloud.
Configure the instrumentation π
For advanced configuration of the .NET automatic instrumentation, like changing trace propagation formats or changing the endpoint URLs, see Configure the Splunk Distribution of OpenTelemetry .NET.
Install the OpenTelemetry .NET instrumentation using the NuGet packages π
You can deploy the Splunk Distribution of OpenTelemetry .NET instrumentation automatically through the official NuGet packages. The project of your instrumented application must support NuGet packages.
Use the NuGet package in the following scenarios:
You control the application build but not the machine or container where the application is running.
Youβre instrumenting a self-contained application. See Publish self-contained in the .NET documentation.
You want to facilitate developer experimentation with automatic instrumentation through NuGet packages.
You need to solve version conflicts between the dependencies used by the application and the automatic instrumentation.
Instrument your application using the NuGet packages π
To automatically instrument your application using the NuGet packages, add the Splunk.OpenTelemetry.AutoInstrumentation
package to your project. For example:
dotnet add [<PROJECT>] package Splunk.OpenTelemetry.AutoInstrumentation --prerelease
If the build fails and prompts you to add missing instrumentation packages, add the instrumentation package or skip the instrumentation of the listed package by adding it to the SkippedInstrumentation
property. For example:
<PropertyGroup>
<SkippedInstrumentations>MongoDB.Driver.Core;StackExchange.Redis</SkippedInstrumentations>
</PropertyGroup>
You can also set the SkippedInstrumentation
property from the terminal. Rewrite the ;
separator as %3B
. For example:
dotnet build -p:SkippedInstrumentations=StackExchange.Redis%3BMongoDB.Driver.Core
To distribute the appropriate native runtime components with your .NET application, specify a Runtime Identifier (RID) to build the application using dotnet build
or dotnet publish
.
Both self-contained and framework-dependent applications are compatible with automatic instrumentation. See .NET application publishing overview in the .NET documentation for more information.
Run the instrumented application π
Use the script in the output folder of the build to run the application with automatic instrumentation activated.
On Windows, use
splunk-launch.cmd <application_executable>
.On Linux, use
splunk-launch.sh <application_executable>
.
If you run the application using the dotnet
CLI, add dotnet
after the script.
On Windows, use
splunk-launch.cmd dotnet <application>
.On Linux, use
splunk-launch.sh dotnet <application>
.
The script passes all the command-line parameters you provide to the application.
Offline installation for Windows π
To install the .NET automatic instrumentation on Windows hosts that are offline, follow these steps:
Download the following files from the Releases page on GitHub and copy them to the offline server:
Splunk.OTel.DotNet.psm1
splunk-opentelemetry-dotnet-windows.zip
Import the PowerShell script manually by running the following command:
# Make sure the Download path is correct Import-Module C:\Users\Administrator\Downloads\Splunk.OTel.DotNet.psm1
When prompted, enter
R
forRun Once
.Run the install command:
# Make sure the Download path is correct Install-OpenTelemetryCore -LocalPath "C:\Users\Administrator\Downloads\splunk-opentelemetry-dotnet-windows.zip"
Send data directly to Splunk Observability Cloud π
By default, all telemetry is sent to the local instance of the Splunk Distribution of OpenTelemetry Collector.
To bypass the OTel Collector and send data directly to Splunk Observability Cloud, set the following environment variables:
$env:SPLUNK_ACCESS_TOKEN=<access_token>
$env:SPLUNK_REALM=<realm>
export SPLUNK_ACCESS_TOKEN=<access_token>
export SPLUNK_REALM=<realm>
To obtain an access token, see Retrieve and manage user API access tokens using Splunk Observability Cloud.
In the ingest endpoint URL, realm
is the Splunk Observability Cloud realm, for example, us0
. To find the realm name of your account, follow these steps:
Open the navigation menu in Splunk Observability Cloud.
Select
.Select your username.
The realm name appears in the Organizations section.
Uninstall the .NET instrumentation π
To deactivate and uninstall the .NET instrumentation, run the following commands:
# Run the unregister command for your situation
Unregister-OpenTelemetryForIIS
Unregister-OpenTelemetryForWindowsService
Unregister-OpenTelemetryForCurrentSession
# Uninstall OpenTelemetry for .NET
Uninstall-OpenTelemetryCore
rm -rf <path_of_otel_dotnet_install>