Skip to content

OpenTelemetry .NET instrumentation

OpenTelemetry is the supported way to send traces, metrics, and logs from a .NET application to Osuite. There are two paths, and you pick one per service.

  • SDK in code — add the OpenTelemetry packages and configure them in Program.cs. You control which instrumentations load, and you can create custom spans and metrics. This is the recommended path for services you build and deploy yourself.
  • Zero-code automatic instrumentation — the OpenTelemetry.AutoInstrumentation distribution attaches to your process through the CLR profiler and instruments supported libraries without any code change. Use it when you cannot modify the application or want a fast path across many services.

Both paths export over OTLP to the same Osuite ingest endpoint and are configured with the same environment variables.

SDK in codeZero-code automatic
Code changesRequired (Program.cs)None
Custom spans and metricsYesNo (add the SDK to extend)
Attaches viaPackage referencesCLR profiler
Best forServices you ownExisting or third-party apps

Follow these steps to instrument a .NET service without changing its code. The installer downloads the automatic instrumentation, and the environment variables point it at Osuite.

  1. Download and install the automatic instrumentation.

    Terminal window
    curl -L -O https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/latest/download/otel-dotnet-auto-install.sh
    sh ./otel-dotnet-auto-install.sh
  2. Set the Osuite environment variables. The automatic instrumentation exports over OTLP by default, so only the endpoint, token, and resource attributes are required.

    Terminal window
    export OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<region>.osuite.io:443
    export OTEL_EXPORTER_OTLP_HEADERS=x-osuite-ingest-token=<your-ingest-token>
    export OTEL_SERVICE_NAME=my-service
    export OTEL_RESOURCE_ATTRIBUTES=service.environment=production
  3. Load the instrumentation into the current shell and run the application. On a bare host, source instrument.sh before starting the process; the Docker and Kubernetes tabs do this in the container entrypoint.

    Terminal window
    . $HOME/.otel-dotnet-auto/instrument.sh
    dotnet run

The service appears in APM within a minute of receiving traffic. If nothing arrives, see Troubleshooting.