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:

    XML
    <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:

Environment variable Description Default Type
OTEL_DOTNET_AUTO_EXCLUDE_PROCESSES Names of the executable files that you don't want the profiler to instrument. Supports multiple semicolon-separated values, for example: ReservedProcess.exe;powershell.exe. Notice that applications launched using dotnet MyApp.dll have process name dotnet or dotnet.exe. Can't be set using the web.config or app.config files. string
OTEL_DOTNET_AUTO_TRACES_ENABLED Traces are collected by default. To deactivate trace collection, set the environment variable to false. Data from custom or manual instrumentation is not affected. true boolean
OTEL_DOTNET_AUTO_METRICS_ENABLED Metrics are collected by default. To deactivate metric collection, set the environment variable to false. Data from custom or manual instrumentation is not affected. true boolean
OTEL_DOTNET_AUTO_LOGS_ENABLED Logs are collected by default. To deactivate log collection, set the environment variable to false. Data from custom or manual instrumentation is not affected. true boolean
OTEL_DOTNET_AUTO_OPENTRACING_ENABLED This feature is deprecated. Avoid usage. Convert your OpenTracing dependency to OpenTelemetry. It activates the OpenTracing tracer. false boolean
OTEL_DOTNET_AUTO_NETFX_REDIRECT_ENABLED Activates immediate redirection of the assemblies used by the automatic instrumentation on the .NET Framework. Can't be set using the web.config or app.config files. This setting is deprecated; use OTEL_DOTNET_AUTO_REDIRECT_ENABLED instead. true boolean
OTEL_DOTNET_AUTO_REDIRECT_ENABLED Activates immediate redirection of the assemblies used by the automatic instrumentation on the .NET Framework. Can't be set using the web.config or app.config files. true boolean
OTEL_DOTNET_AUTO_FLUSH_ON_UNHANDLEDEXCEPTION Controls whether the telemetry data is flushed when an AppDomain.UnhandledException event is raised. Set to true when experiencing missing telemetry at the same time of unhandled exceptions. false boolean
OTEL_DOTNET_AUTO_RULE_ENGINE_ENABLED Activates RuleEngine. RuleEngine increases the stability of the instrumentation by validating assemblies for unsupported scenarios. true boolean
OTEL_DOTNET_AUTO_FAIL_FAST_ENABLED Activate to let the process fail when automatic instrumentation can't be run. This setting is for debugging purposes; don't use it in production environments. Can't be set using the web.config or app.config files. false boolean

Exporter settings

The following settings control trace exporters and their endpoints:

Environment variable Description Default Type
OTEL_LOGS_EXPORTER Comma-separated list of exporters. Supported options: otlp, console, none. otlp string
OTEL_METRICS_EXPORTER Comma-separated list of exporters. Supported options: otlp, console, none. otlp string
OTEL_TRACES_EXPORTER Comma-separated list of exporters. Supported options: otlp, console, none. otlp string
OTEL_EXPORTER_OTLP_ENDPOINT The URL to where traces, metrics, and logs are sent. Setting a value overrides the SPLUNK_REALM environment variable. http://localhost:4318 string
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT Equivalent to OTEL_EXPORTER_OTLP_ENDPOINT, but applies only to logs. string
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT Equivalent to OTEL_EXPORTER_OTLP_ENDPOINT, but applies only to metrics. string
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT Equivalent to OTEL_EXPORTER_OTLP_ENDPOINT, but applies only to traces. string
OTEL_EXPORTER_OTLP_PROTOCOL OTLP exporter transport protocol. Supported values: grpc, http/protobuf. http/protobuf string
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL Equivalent to OTEL_EXPORTER_OTLP_PROTOCOL, but applies only to traces. http/protobuf string
OTEL_EXPORTER_OTLP_METRICS_PROTOCOL Equivalent to OTEL_EXPORTER_OTLP_PROTOCOL, but applies only to metrics. http/protobuf string
OTEL_EXPORTER_OTLP_LOGS_PROTOCOL Equivalent to OTEL_EXPORTER_OTLP_PROTOCOL, but applies only to logs. http/protobuf string
OTEL_EXPORTER_OTLP_TIMEOUT The max waiting time (in milliseconds) for the backend to process each batch. 10000 int
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT Equivalent to OTEL_EXPORTER_OTLP_TIMEOUT, but applies only to traces. 10000 int
OTEL_EXPORTER_OTLP_METRICS_TIMEOUT Equivalent to OTEL_EXPORTER_OTLP_TIMEOUT, but applies only to metrics. 10000 int
OTEL_EXPORTER_OTLP_LOGS_TIMEOUT Equivalent to OTEL_EXPORTER_OTLP_TIMEOUT, but applies only to logs. 10000 int
OTEL_EXPORTER_OTLP_HEADERS Comma-separated list of additional HTTP headers sent with each export, for example: Authorization=secret,X-Key=Value. string
OTEL_EXPORTER_OTLP_TRACES_HEADERS Equivalent to OTEL_EXPORTER_OTLP_HEADERS, but applies only to traces. string
OTEL_EXPORTER_OTLP_METRICS_HEADERS Equivalent to OTEL_EXPORTER_OTLP_HEADERS, but applies only to metrics. string
OTEL_EXPORTER_OTLP_LOGS_HEADERS Equivalent to OTEL_EXPORTER_OTLP_HEADERS, but applies only to logs. string
OTEL_EXPORTER_OTLP_CERTIFICATE Path to the CA certificate file (PEM format) used to verify the server's TLS certificate. Supported only on .NET. string
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE Path to the client certificate file (PEM format) for mTLS authentication. Supported only on .NET. string
OTEL_EXPORTER_OTLP_CLIENT_KEY Path to the client private key file (PEM format) for mTLS authentication. Supported only on .NET. string
SPLUNK_REALM The name of your organization's realm, for example, us0. When SPLUNK_REALM is set, telemetry is sent directly to the Splunk Observability Cloud ingest endpoint, bypassing the Splunk Distribution of the OpenTelemetry Collector.
Important: Direct ingest using SPLUNK_REALM supports only traces and metrics. Logs and profiling data are not sent in this mode.
To send logs and profiling data, you must configure and use the OpenTelemetry Collector, which enables proper routing and delivery to the required endpoints.
string
SPLUNK_ACCESS_TOKEN A Splunk authentication token that lets exporters send data directly to Splunk Observability Cloud. Required when sending data directly to the ingest endpoint. string
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE The aggregation temporality to use on the basis of instrument kind. Supported options: Cumulative, Delta. Cumulative string

.NET OTel settings for AlwaysOn Profiling

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

Environment variable Description Default Type
SPLUNK_PROFILER_ENABLED Activates AlwaysOn Profiling. false boolean
SPLUNK_PROFILER_MEMORY_ENABLED Activates memory profiling. false boolean
SPLUNK_PROFILER_LOGS_ENDPOINT The collector endpoint for profiler logs. http://localhost:4318/v1/logs string
SPLUNK_PROFILER_CALL_STACK_INTERVAL Frequency with which call stacks are sampled, in milliseconds. 10000 int
SPLUNK_PROFILER_EXPORT_TIMEOUT Export timeout, in milliseconds. 3000 int
SPLUNK_PROFILER_MAX_MEMORY_SAMPLES Maximum memory samples collected per minute. Maximum value is 200. 200 int
SPLUNK_PROFILER_EXPORT_INTERVAL Export interval timeout, in milliseconds. Minimum value is 500. 500 int
SPLUNK_SNAPSHOT_PROFILER_ENABLED Activates snapshots collection. false boolean
SPLUNK_SNAPSHOT_SAMPLING_INTERVAL Sampling interval for snapshot collections, in milliseconds. 40 int
SPLUNK_SNAPSHOT_SELECTION_PROBABILITY Sets probability of selecting trace for snapshots. 0.01 double
SPLUNK_SNAPSHOT_HIGH_RES_TIMER_ENABLED Sets default timer precision on Windows to 1ms. false bool

Trace propagation settings

The following settings control trace propagation:

Description Environment variable Default value Type
Comma-separated list of propagators for the tracer. The default value is `tracecontext,baggage`. Supported values are `b3multi`, `b3`, `tracecontext`, and `baggage`. OTEL_PROPAGATORS tracecontext,baggage string

Samplers configuration

The following settings control trace sampling:

Description Environment variable Default value Type
Sampler to use. The default value is `parentbased_always_on`. Supported values are `always_on`, `always_off`, `traceidratio`, `parentbased_always_on`, `parentbased_always_off`, and `parentbased_traceidratio`. OTEL_TRACES_SAMPLER parentbased_always_on string
Semicolon-separated list of rules for the `rules` sampler. The default value is `1.0` for `traceidratio`. OTEL_TRACES_SAMPLER_ARG 1.0 string

Resource detectors configuration

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

Description Environment variable Default value Type
Activates or deactivates all resource detectors. The default values is `true`. OTEL_DOTNET_AUTO_RESOURCE_DETECTOR_ENABLED true boolean
Activates or deactivates a specific resource detector, where `{DETECTOR}` is the uppercase identifier of the resource detector you want to activate. Overrides `OTEL_DOTNET_AUTO_RESOURCE_DETECTOR_ENABLED`. OTEL_DOTNET_AUTO_{DECTECTOR}_RESOURCE_DETECTOR_ENABLED depends on `OTEL_DOTNET_AUTO_RESOURCE_DETECTOR_ENABLED` boolean

Resource attributes

Resource attributes let you attach custom metadata to every span reported by your application.

Environment variable Description Default Type
OTEL_DOTNET_AUTO_RESOURCE_DETECTOR_ENABLED Activates or deactivates all resource detectors. true boolean
OTEL_DOTNET_AUTO_{DETECTOR}_RESOURCE_DETECTOR_ENABLED Activates or deactivates a specific resource detector, where {DETECTOR} is the uppercase identifier of the resource detector you want to activate. Overrides OTEL_DOTNET_AUTO_RESOURCE_DETECTOR_ENABLED. depends on OTEL_DOTNET_AUTO_RESOURCE_DETECTOR_ENABLED boolean
OTEL_SERVICE_NAME Name of the service or application you're instrumenting. Takes precedence over the service name defined in the OTEL_RESOURCE_ATTRIBUTES variable. string
OTEL_RESOURCE_ATTRIBUTES Comma-separated list of resource attributes added to every reported span. For example, key1=val1,key2=val2. string

Instrumentation settings

The following settings control instrumentations and tracing behavior:

Description Environment variable Default value Type
Activated by default. Adds server trace information to HTTP response headers. The default value is `true`. SPLUNK_TRACE_RESPONSE_HEADER_ENABLED true boolean
Comma-separated list of additional `System.Diagnostics.ActivitySource` names to be added to the tracer at startup. Use it to capture spans from manual instrumentation. OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES (empty) string
Comma-separated list of additional `System.Diagnostics.Metrics.Meter` names to be added to the meter at the startup. Use it to capture custom metrics. OTEL_DOTNET_AUTO_METRICS_ADDITIONAL_SOURCES (empty) string
Comma-separated list of additional legacy source names to be added to the tracer at the startup. Use it to capture `System.Diagnostics.Activity` objects created without using the `System.Diagnostics.ActivitySource` API. OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_LEGACY_SOURCES (empty) string
Activates or deactivates all instrumentations. Can’t be set using the web.config or app.config files. OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED true boolean
Activates or deactivates all trace instrumentations. Overrides `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED`. Inherits the value of the `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED` environment variable. Can’t be set using the web.config or app.config files. OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED (empty) boolean
Activates or deactivates a specific trace instrumentation, where `{INSTRUMENTATION}` is the case-sensitive name of the instrumentation. Overrides `OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED`. Inherits the value of the `OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED` environment variable. Can’t be set using the web.config or app.config files. See Supported libraries for a complete list of supported instrumentations and their names. OTEL_DOTNET_AUTO_TRACES_{INSTRUMENTATION}_INSTRUMENTATION_ENABLED (empty) boolean
Activates or deactivates all metric instrumentations. Overrides `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED`. Inherits the value of the `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED` environment variable. Can’t be set using the web.config or app.config files. OTEL_DOTNET_AUTO_METRICS_INSTRUMENTATION_ENABLED (empty) boolean
Activates or deactivates a specific metric instrumentation, where `{INSTRUMENTATION}` is the case-sensitive name of the instrumentation. Overrides `OTEL_DOTNET_AUTO_METRICS_INSTRUMENTATION_ENABLED`. Inherits the value of the `OTEL_DOTNET_AUTO_METRICS_INSTRUMENTATION_ENABLED` environment variable. Can’t be set using the web.config or app.config files. See Supported libraries for a complete list of supported instrumentations and their names. OTEL_DOTNET_AUTO_METRICS_{INSTRUMENTATION}_INSTRUMENTATION_ENABLED (empty) boolean
Activates or deactivates all log instrumentations. Overrides `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED`. Inherits the value of the `OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED` environment variable. Can’t be set using the web.config or app.config files. OTEL_DOTNET_AUTO_LOGS_INSTRUMENTATION_ENABLED (empty) boolean
Activates or deactivates a specific log instrumentation, where `{INSTRUMENTATION}` is the case-sensitive name of the instrumentation. Overrides `OTEL_DOTNET_AUTO_LOGS_INSTRUMENTATION_ENABLED`. Inherits the value of the `OTEL_DOTNET_AUTO_LOGS_INSTRUMENTATION_ENABLED` environment variable. Can’t be set using the web.config or app.config files. See Supported libraries for a complete list of supported instrumentations and their names. OTEL_DOTNET_AUTO_LOGS_{INSTRUMENTATION}_INSTRUMENTATION_ENABLED (empty) boolean

Diagnostic logging settings

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

Description Environment variable Default value Type
AutoInstrumentation diagnostic logs sink. (supported values: `none`,`file`,`console`. OTEL_DOTNET_AUTO_LOGGER file string
Sets the logging level for instrumentation log messages. Possible values are `none`, `error`, `warn`, `info`, and `debug`. Can't be set using the web.config or app.config files. OTEL_LOG_LEVEL info string
Directory of the .NET tracer logs. The default value is `/var/log/opentelemetry/dotnet` for Linux, and `%ProgramData%\OpenTelemetry .NET AutoInstrumentation\logs` for Windows. Can't be set using the web.config or app.config files. OTEL_DOTNET_AUTO_LOG_DIRECTORY (empty) string
Deprecated. Whether the traces console exporter is activated. It can be configured by `OTEL_TRACES_EXPORTER`. OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED false boolean

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.