.NET
Zero-code OpenTelemetry instrumentation for .NET applications.
.NET applications are instrumented with OpenTelemetry .NET Automatic Instrumentation. It loads into the .NET runtime at startup as a CLR profiler and startup hook, and creates spans for ASP.NET Core, HttpClient, gRPC, SQL Server, Entity Framework Core and other libraries. You don't change application code or rebuild the application.
Choose your platform
| Platform | Guide |
|---|---|
| Kubernetes | .NET on Kubernetes: one pod annotation with the OpenTelemetry Operator |
| Windows VM / IIS | .NET on IIS: PowerShell installation for IIS-hosted ASP.NET Core |
| Linux VM | .NET on a Linux VM: install script and a systemd service |
| Kubernetes or VM, set up in code | .NET manual instrumentation (SDK): SDK packages and trace setup code |
How it works
The runtime loads the instrumentation through these environment variables. The Kubernetes operator, the IIS installer and the Linux instrument.sh script set them for you.
| Variable | Purpose |
|---|---|
CORECLR_ENABLE_PROFILING=1 | Enables the CLR profiler |
CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318} | ID of the OpenTelemetry profiler (always this value) |
CORECLR_PROFILER_PATH | Path to the native profiler library for your OS, libc and CPU |
DOTNET_STARTUP_HOOKS | Loads the managed part of the instrumentation |
OTEL_DOTNET_AUTO_HOME | Installation directory of the instrumentation |
The exporter is configured with the standard OpenTelemetry variables:
| Variable | Value |
|---|---|
OTEL_SERVICE_NAME | Your service name |
OTEL_EXPORTER_OTLP_ENDPOINT | A local collector (http://localhost:4318), or KubeSense directly (http://<KUBESENSE_INGEST_HOST>:33443) |
OTEL_EXPORTER_OTLP_PROTOCOL | http/protobuf |
OTEL_RESOURCE_ATTRIBUTES | kubesense.cluster=<CLUSTER_NAME>,kubesense.env_type=<k8s or legacy> |
Match the native profiler to the image: The native profiler must match the container's C library and CPU architecture. Alpine images use musl (linux-musl-x64). Debian and Ubuntu images use glibc (linux-x64). If they don't match, the profiler fails to load without any error, and the application runs with no traces.