Docs » Supported integrations in Splunk Observability Cloud » Instrument back-end applications to send spans to Splunk APM » Instrument .NET applications for Splunk Observability Cloud (OpenTelemetry) » Configure the Splunk Distribution of OpenTelemetry .NET

Configure the Splunk Distribution of OpenTelemetry .NET ๐Ÿ”—

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:

Exporter settings ๐Ÿ”—

The following settings control trace exporters and their endpoints:

.NET OTel settings for AlwaysOn Profiling ๐Ÿ”—

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

Environment variable

Description

SPLUNK_PROFILER_ENABLED

Activates AlwaysOn Profiling. The default value is false.

SPLUNK_PROFILER_MEMORY_ENABLED

Activates memory profiling. The default value is false.

SPLUNK_PROFILER_LOGS_ENDPOINT

The collector endpoint for profiler logs. The default value is http://localhost:4318/v1/logs.

SPLUNK_PROFILER_CALL_STACK_INTERVAL

Frequency with which call stacks are sampled, in milliseconds. The default value is 10000 milliseconds.

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:

Samplers configuration ๐Ÿ”—

The following settings control trace sampling:

Resource detectors configuration ๐Ÿ”—

You can use resource detectors to retrieve additional attributes for your applicationโ€™s spans.

The following settings control resource detectors:

The following resource detectors are available:

Instrumentation settings ๐Ÿ”—

The following settings control instrumentations and tracing behavior:

The following settings control which instrumentations are activated. See Deactivate specific instrumentations for more information.

Setting

Description

OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED

Activates or deactivates all instrumentations. The default value is true. Canโ€™t be set using the web.config or app.config files.

OTEL_DOTNET_AUTO_TRACES_INSTRUMENTATION_ENABLED

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}_INSTRUMENTATION_ENABLED

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_METRICS_INSTRUMENTATION_ENABLED

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}_INSTRUMENTATION_ENABLED

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_LOGS_INSTRUMENTATION_ENABLED

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}_INSTRUMENTATION_ENABLED

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.

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:

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:

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