.NET
The Dash0 distribution of the OpenTelemetry .NET automatic instrumentation, packaged so the OpenTelemetry injector can attach it to .NET processes on a host.
Compatibility
| Requirement | Supported |
|---|---|
| .NET | 6 or later; tested on 6 to 10 |
| Architectures | amd64 and arm64 |
| Distribution requirements | Requirements |
Setup with the injector
This is the recommended setup: the injector instruments every .NET process on the host when it starts, without changes to how you start your applications. There are two ways to install it.
With dash0-opentelemetry, install the metapackage.
It brings the injector, the keyring and, as recommended packages, the language packages for all runtimes, .NET included.
On Debian or Ubuntu:
sudo apt-get install dash0-opentelemetryOn Fedora, RHEL or Amazon Linux 2023:
sudo dnf install dash0-opentelemetryWith only the packages you need, install this package and the injector by name.
On Debian or Ubuntu:
sudo apt-get install dash0-injector dash0-dotnet-autoinstrumentationOn Fedora, RHEL or Amazon Linux 2023:
sudo dnf install dash0-injector dash0-dotnet-autoinstrumentationIn both cases, the package's drop-in at /etc/opentelemetry/injector/conf.d/dotnet.conf tells the injector where the tree is and which .NET versions to instrument.
The injector then sets the CoreCLR profiler variables (CORECLR_ENABLE_PROFILING, CORECLR_PROFILER, CORECLR_PROFILER_PATH, DOTNET_STARTUP_HOOKS and OTEL_DOTNET_AUTO_HOME) for every .NET process that starts, and applies default_env.conf to it.
.NET processes that are already running are instrumented only after they restart.
Then set the endpoint and the auth token in default_env.conf, as described under Configuration.
Setup without the injector
Install only this package.
On Debian or Ubuntu:
sudo apt-get install dash0-dotnet-autoinstrumentationOn Fedora, RHEL or Amazon Linux 2023:
sudo dnf install dash0-dotnet-autoinstrumentationOn its own, the package instruments nothing. It only suggests the injector, and apt and dnf do not install suggested packages. Load the instrumentation yourself when you start the process:
export OTEL_DOTNET_AUTO_HOME=/usr/lib/opentelemetry/dotnet/glibc
. "${OTEL_DOTNET_AUTO_HOME}/instrument.sh"
dotnet /path/to/myapp.dllDone this way there is no minimum-version check: instrument.sh attaches the profiler to whatever starts in that shell.
Without the injector, default_env.conf is not applied: set the endpoint and the auth token in the environment of the process instead, as described under Configuration.
Configuration
All setups need the same settings, as environment variables:
| Variable | Sets |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | The Dash0 OTLP endpoint to send telemetry to |
OTEL_EXPORTER_OTLP_HEADERS | The auth token and the dataset |
OTEL_SERVICE_NAME | Optional: the service name, which otherwise is the name of the entry assembly; see How the service name is chosen |
With the injector, set them in /etc/opentelemetry/injector/default_env.conf, which the injector applies to every process it instruments:
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.eu-west-1.aws.dash0.com
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20auth_...,Dash0-Dataset=defaultWithout the injector, set them in the environment of the process, for example in the [Service] section of its systemd unit:
Environment=OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.eu-west-1.aws.dash0.com
Environment=OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20auth_...,Dash0-Dataset=defaultIn both setups, the declarative configuration file this package ships reads these variables, so they are the only settings most hosts need.
Note that white spaces in OTEL_EXPORTER_OTLP_HEADERS, like in Bearer <token>, must be written %20.
Set the endpoint without a trailing slash, since the signal paths such as /v1/traces are appended to it.
A variable in default_env.conf replaces the value a process sets itself, so set OTEL_SERVICE_NAME and other per-application settings in the environment of the application, not in default_env.conf.
DASH0_OTEL_COLLECTOR_BASE_URL is the endpoint when OTEL_EXPORTER_OTLP_ENDPOINT is unset or empty, as in the other Dash0 distributions.
DASH0_DISABLE=true leaves processes uninstrumented without uninstalling the package: the profiler cancels its own activation and the startup hook returns before loading anything.
With the injector, the DASH0_ variables reach the process only through dash0-injector, because upstream's opentelemetry-injector forwards only OTEL_-prefixed names.
Declarative configuration
Like the upstream .NET package, this package ships /etc/opentelemetry/dotnet/otel-config.yaml, an OpenTelemetry declarative configuration file.
Unlike the upstream package, the distribution reads it whenever OTEL_CONFIG_FILE is unset or empty, so it configures every instrumented .NET process by default.
Configuration on the overview describes how to use a file of your own, the propagators every shipped file declares, and what happens to an edited file on upgrade, on removal and when replacing the upstream package.
The file uses OpenTelemetry declarative configuration , the standard YAML configuration format of the OpenTelemetry project, whose schema is defined in open-telemetry/opentelemetry-configuration .
${VARIABLE:-default} takes the value of an environment variable, with a default for when it is unset.
This excerpt of the shipped file shows the propagators, the resource detectors and the export of traces; metrics and logs are exported in the same way:
file_format: "1.0"
propagator:
composite:
- tracecontext: {}
- baggage: {}
- xray: {}
resource:
detection/development:
detectors:
- azureappservice: {}
- container: {}
- host: {}
- operatingsystem: {}
- process: {}
- processruntime: {}
- dash0_service_name: {}
attributes_list: ${OTEL_RESOURCE_ATTRIBUTES:-}
tracer_provider:
processors:
- batch:
exporter:
otlp_http:
endpoint: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}/v1/traces
headers_list: ${OTEL_EXPORTER_OTLP_HEADERS:-}
compression: ${OTEL_EXPORTER_OTLP_COMPRESSION:-none}Supported environment variables
With a configuration file in effect, the SDK reads no OTEL_ variable of its own.
The shipped file interpolates these, so default_env.conf stays the one place to set them:
| Variable | Default in the file |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT | http://localhost:4318 |
OTEL_EXPORTER_OTLP_HEADERS | empty |
OTEL_EXPORTER_OTLP_COMPRESSION | none |
OTEL_RESOURCE_ATTRIBUTES | empty |
OTEL_METRIC_EXPORT_INTERVAL | 60000 ms |
OTEL_METRIC_EXPORT_TIMEOUT | 30000 ms |
OTEL_DOTNET_AUTO_FAIL_FAST_ENABLED | false |
OTEL_DOTNET_AUTO_FLUSH_ON_UNHANDLEDEXCEPTION | false |
A configuration file of your own has to carry the same interpolations to keep them.
OTEL_SERVICE_NAME and DASH0_AUTOMATIC_SERVICE_NAME keep working through the dash0_service_name detector the file lists.
DASH0_OTEL_COLLECTOR_BASE_URL keeps working too: the distribution copies it into OTEL_EXPORTER_OTLP_ENDPOINT before the file is read.
The variables the native profiler reads itself apply in either mode: DASH0_DISABLE, OTEL_DOTNET_AUTO_LOG_DIRECTORY and OTEL_DOTNET_AUTO_EXCLUDE_PROCESSES.
Upstream .NET reads a configuration file only with OTEL_EXPERIMENTAL_FILE_BASED_CONFIGURATION_ENABLED=true; this distribution does not need it.
If that variable is set, it still decides: true keeps the file in effect, and any other value, such as false, turns it off.
Unsupported environment variables
- The
OTEL_DOTNET_AUTO_*switches that turn signals, instrumentations or resource detectors on and off. The file'sinstrumentation/developmentanddetectorslists decide instead. Every instrumentation is enabled until the file lists some: listing any underinstrumentation/development.dotnet.traces,metricsorlogsenables only the listed ones for that signal, and the other signals keep all of theirs. The shipped file lists none. OTEL_TRACES_SAMPLERandOTEL_TRACES_SAMPLER_ARG. The file declares no sampler, so every process samplesparentbased_always_on, the SDK default. Add atracer_provider.samplerto change it.OTEL_PROPAGATORS. Edit the file'spropagatorlist instead.OTEL_EXPORTER_OTLP_PROTOCOL, the per-signal endpoint variables andOTEL_TRACES_EXPORTER,OTEL_METRICS_EXPORTERandOTEL_LOGS_EXPORTER. The file exports all three signals over OTLP/HTTP to the base endpoint; edit its exporters to change that.OTEL_BSP_*,OTEL_BLRP_*andOTEL_EXPORTER_OTLP_TIMEOUT. The batch processors and exporters use the SDK's own defaults.
Resource detectors
The shipped file lists every upstream resource detector of .NET, azureappservice, container, host, operatingsystem, process and processruntime, and the distribution's dash0_service_name.
With a configuration file, .NET runs only the detectors the file lists, so a file of your own that omits them loses the attributes they add, and without dash0_service_name it stops reading OTEL_SERVICE_NAME.
Resource detection describes what each one adds.
Resource attributes
Every instrumented process reports the package it came from:
| Attribute | Value |
|---|---|
dash0.package.name | dash0-dotnet-autoinstrumentation |
dash0.package.version | The installed package version, packaging revision included |
The dash0.package.* attributes come from a file this package installs, which the agent reads at startup, with or without a configuration file.
They take precedence over the same keys in OTEL_RESOURCE_ATTRIBUTES.
The distribution adds the other resource attributes, such as service.name and telemetry.distro.*.
Resource detection in the distribution docs describes them, and how the service name is chosen, with and without a configuration file.
Conditional instrumentation
The application keeps running in every case below, without telemetry.
The agent writes its diagnostics to log files in /var/log/opentelemetry/dotnet/, or the directory OTEL_DOTNET_AUTO_LOG_DIRECTORY names, not to stdout or stderr.
DASH0_DISABLE=true: the agent log says "Profiler disabled: DASH0_DISABLE is true."- A target framework older than the configured minimum: the injector skips the process.
The injector's own minimum is .NET 8, so this package's
conf.ddrop-in lowers it to 6, the oldest version the distribution supports, withdotnet_auto_instrumentation_minimum_dotnet_major_version=6. To instrument fewer runtimes, raise the value in a later-sortingconf.dfile, as described under Installed files. - The application already uses a profiler or startup hook: the injector skips any process that already has
CORECLR_ENABLE_PROFILING,CORECLR_PROFILER,CORECLR_PROFILER_PATH,DOTNET_ADDITIONAL_DEPS,DOTNET_SHARED_STOREorDOTNET_STARTUP_HOOKSset. - The application already references OpenTelemetry: the injector skips a process whose
deps.jsonreferences OpenTelemetry packages, to avoid double instrumentation. An application that bundles assemblies older than the ones the agent needs is refused by the agent, with the reason in the agent log. - A configuration file that is not valid, or an
OTEL_CONFIG_FILEnaming a missing one: the agent log says "Error in StartupHook initialization". WithOTEL_DOTNET_AUTO_FAIL_FAST_ENABLED=true, the application stops instead.
With the injector, the injector itself logs why it skipped a process on stderr with OTEL_INJECTOR_LOG_LEVEL=info.
See the Injector page.
Installed files
| Path | Purpose |
|---|---|
/usr/lib/opentelemetry/dotnet/glibc/net/ | The managed assemblies, one directory per target framework, and the startup hook |
/usr/lib/opentelemetry/dotnet/glibc/linux-x64/ or /usr/lib/opentelemetry/dotnet/glibc/linux-arm64/ | The native CoreCLR profiler |
/usr/lib/opentelemetry/dotnet/glibc/instrument.sh | The distribution's activation script, for use without the injector |
/usr/lib/opentelemetry/dotnet/glibc/dash0-resource-attributes.txt | The dash0.package.* resource attributes, replaced on upgrade |
/usr/lib/opentelemetry/dotnet/glibc/LICENSE, /usr/lib/opentelemetry/dotnet/glibc/VERSION | The distribution's license and version |
/etc/opentelemetry/injector/conf.d/dotnet.conf | Tells the injector where the tree is and which .NET versions to instrument |
/etc/opentelemetry/dotnet/otel-config.yaml | The declarative configuration file, read whenever OTEL_CONFIG_FILE is unset or empty; a conffile, so an edited copy is kept on upgrade |
/usr/share/man/man8/opentelemetry-dotnet.8.gz | The manual page, for man opentelemetry-dotnet |
/usr/share/doc/dash0-dotnet-autoinstrumentation/README.md | The installed copy of this page |
/usr/share/doc/dash0-dotnet-autoinstrumentation/copyright | The license statement and the notice, DEB only |
/usr/share/licenses/dash0-dotnet-autoinstrumentation/LICENSE | The license, RPM only |
/usr/share/licenses/dash0-dotnet-autoinstrumentation/NOTICE | The notice, RPM only |
Local overrides belong in a conf.d file that sorts after the package-managed one.
The injector reads conf.d in byte order and the last setting wins, so a digit prefix such as 99- sorts before dotnet.conf; use a name such as zz-local-dotnet.conf.
Edits to dotnet.conf itself are replaced on upgrade.
Dependencies
| Package | Relation | Why |
|---|---|---|
dash0-keyring | Depends | Every Dash0 package depends on it, so the signing certificate is owned by a package that upgrades it |
dash0-injector | Suggests | Instruments processes with this package; apt and dnf do not install suggested packages, so install the injector by name, as described under Setup with the injector |
opentelemetry-dotnet-autoinstrumentation | Conflicts, and Replaces on DEB or Obsoletes on RPM | Takes the place of the upstream package; see Reverting to the upstream package |
Versioning
The package version is the version of the bundled distribution, followed by a packaging revision: 1.1.3-1 is the first package built from distribution 1.1.3, 1.1.3-2 a later package built from the same distribution.
On RPM distributions the revision is the Release field, so rpm -q shows 1.1.3-1 as version 1.1.3, release 1.
Reverting to the upstream package
On Debian and Ubuntu:
sudo apt-get install opentelemetry-dotnet-autoinstrumentationOn RPM distributions, this package declares Obsoletes on the upstream name, so a plain dnf install of it redirects back here.
Ask for the swap explicitly:
sudo dnf swap --setopt=obsoletes=0 dash0-dotnet-autoinstrumentation opentelemetry-dotnet-autoinstrumentationThe switch also changes:
- The minimum .NET version: upstream's drop-in does not set one, so the injector falls back to its default of 8, and .NET 6 and 7 processes stop being instrumented.
- The endpoint: upstream does not read
DASH0_OTEL_COLLECTOR_BASE_URL, so unlessdefault_env.confsetsOTEL_EXPORTER_OTLP_ENDPOINT, .NET processes send their telemetry tohttp://localhost:4318instead. - The configuration file: upstream reads none by default, and
OTEL_CONFIG_FILEonly together withOTEL_EXPERIMENTAL_FILE_BASED_CONFIGURATION_ENABLED=true.
A configuration file written for this package does not work unchanged with the upstream package, which:
- enables no instrumentation the file does not list;
- accepts
propagator.compositeanddetection/development.detectorsonly as mappings (tracecontext:rather than- tracecontext: {}). Given the list form this package's file uses, its parser fails and the SDK does not start; - has no
xraypropagator and nodash0_service_namedetector, soOTEL_SERVICE_NAMEdoes not apply under a file.
If you edited the shipped file and rely on it, or point OTEL_CONFIG_FILE at a copy of your own, adapt it before switching.
Source
https://github.com/dash0hq/opentelemetry-dotnet-distribution
Last updated: