Configure the Splunk Distribution of OpenTelemetry .NET

Configure the Splunk Distribution of OpenTelemetry .NET to suit your instrumentation needs, such as correlating traces with logs and activating custom sampling.

You can configure the Splunk Distribution of OpenTelemetry .NET to suit your instrumentation needs. In most cases, modifying the basic configuration is enough to get started. More advanced settings are also available.

Configuration methods

You can change the settings of the Splunk Distribution of OpenTelemetry .NET in the following ways:

  • For .NET applications, set environment variables. On Windows, set them in the process scope unless you want to activate automatic instrumentation globally for all .NET applications.

  • For .NET Framework applications running as Windows services, you can add settings in the appSettings block of the app.config file when supported or set environment variables using the Windows Registry.

  • For ASP.NET applications, add settings in the appSettings block of the web.config file. For example:

    <configuration>
       <appSettings>
          <add key="OTEL_SERVICE_NAME" value="my-service-name" />
       </appSettings>
    </configuration>

    Alternatively, you can set environment variables using any of the following methods:

    • Add the <environmentVariables> element in applicationHost.config for your application pools.

    • Set the environment variables for W3SVC and WAS.

  • For ASP.NET Core applications, add <environmentVariable> elements inside the <aspNetCore> block of your web.config file.

General settings

The following settings are common to most instrumentation scenarios:

{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type"}

general

category

settings

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

Exporter settings

The following settings control trace exporters and their endpoints:

{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type"}

exporter

category

settings

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

.NET OTel settings for AlwaysOn Profiling

The following settings control the AlwaysOn Profiling feature for the .NET instrumentation:

{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type"}

profiling

category

settings

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

Note: AlwaysOn Profiling for .NET is compatible with .NET 6.0 and higher. For more information on AlwaysOn Profiling, see Introduction to AlwaysOn Profiling for Splunk APM.

Trace propagation settings

The following settings control trace propagation:

{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type"}

trace propagation

category

settings

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

Samplers configuration

The following settings control trace sampling:

{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type"}

sampler

category

settings

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

Resource detectors configuration

You can use resource detectors to retrieve additional attributes for your application’s spans.

The following settings control resource detectors:

{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type"}

resource detector

category

settings

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

The following resource detectors are available:

{"key": "Identifier", "description": "Description", "attributes": "Attributes", "id": "ID", "stability": "Stability", "support": "Support", "dependencies": "Dependencies", "name": "Name", "source_href": "Source", "package_href": "Package URL", "version": "Version", "stability": "Stability"}

resource_detectors

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

Instrumentation settings

The following settings control instrumentations and tracing behavior:

{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type"}

instrumentation

category

settings

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

Server trace information

To connect Real User Monitoring (RUM) requests from mobile and web applications with server trace data, trace response headers are activated by default. The instrumentation adds the following response headers to HTTP responses:

Access-Control-Expose-Headers: Server-Timing
Server-Timing: traceparent;desc="00-<serverTraceId>-<serverSpanId>-01"

The Server-Timing header contains the traceId and spanId parameters in traceparent format. For more information, see the Server-Timing and traceparent documentation on the W3C website.

Note: If you need to deactivate trace response headers, set SPLUNK_TRACE_RESPONSE_HEADER_ENABLED to false.

Diagnostic logging settings

The following settings control the internal logging of the Splunk Distribution of OpenTelemetry .NET:

{"keys": "Identifier", "description": "Description", "instrumented_components": "Components", "signals": "Signals", "env": "Environment variable", "default": "Default", "type": "Type"}

diagnostic logging

category

settings

https://raw.githubusercontent.com/splunk/o11y-gdi-metadata/main/apm/splunk-otel-dotnet/metadata.yaml

Changing the default service name

By default, the Splunk Distribution of OpenTelemetry .NET retrieves the service name by trying the following steps until it succeeds:

  1. The default service name is the name of the entry assembly. For example, the name of your .NET project file. For ASP.NET applications, the default service name is SiteName[/VirtualPath].

  2. If the entry assembly is not available, the instrumentation tries to use the current process name. The process name can be dotnet if launched directly using an assembly. For example, dotnet InstrumentedApp.dll.

If all the steps fail, the service name defaults to unknown_service.

Note: To override the default service name, set the OTEL_SERVICE_NAME environment variable.

Environment variables for manual installation

When deploying the instrumentation manually, you need to make sure to set the following environment variables:

Windows (.NET)

Environment variable

Value

CORECLR_ENABLE_PROFILING

1

CORECLR_PROFILER

{918728DD-259F-4A6A-AC2B-B85E1B658318}

CORECLR_PROFILER_PATH_64

$installationLocation\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll

CORECLR_PROFILER_PATH_32

$installationLocation\win-x86\OpenTelemetry.AutoInstrumentation.Native.dll

DOTNET_ADDITIONAL_DEPS

$installationLocation\AdditionalDeps

DOTNET_SHARED_STORE

$installationLocation\store

DOTNET_STARTUP_HOOKS

$installationLocation\net\OpenTelemetry.AutoInstrumentation.StartupHook.dll

OTEL_DOTNET_AUTO_HOME

$installationLocation

OTEL_DOTNET_AUTO_PLUGINS

Splunk.OpenTelemetry.AutoInstrumentation.Plugin, Splunk.OpenTelemetry.AutoInstrumentation

Windows (.NET Framework)

Environment variable

Value

COR_ENABLE_PROFILING

1

COR_PROFILER

{918728DD-259F-4A6A-AC2B-B85E1B658318}

COR_PROFILER_PATH_64

$installationLocation\win-x64\OpenTelemetry.AutoInstrumentation.Native.dll

COR_PROFILER_PATH_32

$installationLocation\win-x86\OpenTelemetry.AutoInstrumentation.Native.dll

OTEL_DOTNET_AUTO_HOME

$installationLocation

OTEL_DOTNET_AUTO_PLUGINS

Splunk.OpenTelemetry.AutoInstrumentation.Plugin, Splunk.OpenTelemetry.AutoInstrumentation

Linux (.NET)

Environment variable

Value

CORECLR_ENABLE_PROFILING

1

CORECLR_PROFILER

{918728DD-259F-4A6A-AC2B-B85E1B658318}

CORECLR_PROFILER_PATH

$INSTALL_DIR/linux-x64/OpenTelemetry.AutoInstrumentation.Native.so (glibc) $INSTALL_DIR/linux-musl-x64/OpenTelemetry.AutoInstrumentation.Native.so (musl)

DOTNET_ADDITIONAL_DEPS

$INSTALL_DIR\AdditionalDeps

DOTNET_SHARED_STORE

$INSTALL_DIR\store

DOTNET_STARTUP_HOOKS

$INSTALL_DIR\net\OpenTelemetry.AutoInstrumentation.StartupHook.dll

OTEL_DOTNET_AUTO_HOME

$INSTALL_DIR

OTEL_DOTNET_AUTO_PLUGINS

Splunk.OpenTelemetry.AutoInstrumentation.Plugin, Splunk.OpenTelemetry.AutoInstrumentation

Note: The default installation path on Linux is $HOME/.otel-dotnet-auto.