.NET

The Dash0 distribution of the OpenTelemetry .NET automatic instrumentation, as a DEB and RPM package.

The Dash0 distribution of the OpenTelemetry .NET automatic instrumentation, packaged so the OpenTelemetry injector can attach it to .NET processes on a host.

Compatibility

RequirementSupported
.NET6 or later; tested on 6 to 10
Architecturesamd64 and arm64
Distribution requirementsRequirements

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-opentelemetry

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-opentelemetry

With 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-autoinstrumentation

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-injector dash0-dotnet-autoinstrumentation

In 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-autoinstrumentation

On Fedora, RHEL or Amazon Linux 2023:

sudo dnf install dash0-dotnet-autoinstrumentation

On 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.dll

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

VariableSets
OTEL_EXPORTER_OTLP_ENDPOINTThe Dash0 OTLP endpoint to send telemetry to
OTEL_EXPORTER_OTLP_HEADERSThe auth token and the dataset
OTEL_SERVICE_NAMEOptional: 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=default

Without 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=default

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

VariableDefault in the file
OTEL_EXPORTER_OTLP_ENDPOINThttp://localhost:4318
OTEL_EXPORTER_OTLP_HEADERSempty
OTEL_EXPORTER_OTLP_COMPRESSIONnone
OTEL_RESOURCE_ATTRIBUTESempty
OTEL_METRIC_EXPORT_INTERVAL60000 ms
OTEL_METRIC_EXPORT_TIMEOUT30000 ms
OTEL_DOTNET_AUTO_FAIL_FAST_ENABLEDfalse
OTEL_DOTNET_AUTO_FLUSH_ON_UNHANDLEDEXCEPTIONfalse

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's instrumentation/development and detectors lists decide instead. Every instrumentation is enabled until the file lists some: listing any under instrumentation/development.dotnet.traces, metrics or logs enables only the listed ones for that signal, and the other signals keep all of theirs. The shipped file lists none.
  • OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG. The file declares no sampler, so every process samples parentbased_always_on, the SDK default. Add a tracer_provider.sampler to change it.
  • OTEL_PROPAGATORS. Edit the file's propagator list instead.
  • OTEL_EXPORTER_OTLP_PROTOCOL, the per-signal endpoint variables and OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER and OTEL_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_* and OTEL_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:

AttributeValue
dash0.package.namedash0-dotnet-autoinstrumentation
dash0.package.versionThe 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.d drop-in lowers it to 6, the oldest version the distribution supports, with dotnet_auto_instrumentation_minimum_dotnet_major_version=6. To instrument fewer runtimes, raise the value in a later-sorting conf.d file, 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_STORE or DOTNET_STARTUP_HOOKS set.
  • The application already references OpenTelemetry: the injector skips a process whose deps.json references 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_FILE naming a missing one: the agent log says "Error in StartupHook initialization". With OTEL_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

PathPurpose
/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.shThe distribution's activation script, for use without the injector
/usr/lib/opentelemetry/dotnet/glibc/dash0-resource-attributes.txtThe dash0.package.* resource attributes, replaced on upgrade
/usr/lib/opentelemetry/dotnet/glibc/LICENSE, /usr/lib/opentelemetry/dotnet/glibc/VERSIONThe distribution's license and version
/etc/opentelemetry/injector/conf.d/dotnet.confTells the injector where the tree is and which .NET versions to instrument
/etc/opentelemetry/dotnet/otel-config.yamlThe 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.gzThe manual page, for man opentelemetry-dotnet
/usr/share/doc/dash0-dotnet-autoinstrumentation/README.mdThe installed copy of this page
/usr/share/doc/dash0-dotnet-autoinstrumentation/copyrightThe license statement and the notice, DEB only
/usr/share/licenses/dash0-dotnet-autoinstrumentation/LICENSEThe license, RPM only
/usr/share/licenses/dash0-dotnet-autoinstrumentation/NOTICEThe 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

PackageRelationWhy
dash0-keyringDependsEvery Dash0 package depends on it, so the signing certificate is owned by a package that upgrades it
dash0-injectorSuggestsInstruments 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-autoinstrumentationConflicts, and Replaces on DEB or Obsoletes on RPMTakes 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-autoinstrumentation

On 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-autoinstrumentation

The 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 unless default_env.conf sets OTEL_EXPORTER_OTLP_ENDPOINT, .NET processes send their telemetry to http://localhost:4318 instead.
  • The configuration file: upstream reads none by default, and OTEL_CONFIG_FILE only together with OTEL_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.composite and detection/development.detectors only 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 xray propagator and no dash0_service_name detector, so OTEL_SERVICE_NAME does 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: