Kubesense

.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

PlatformGuide
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.

VariablePurpose
CORECLR_ENABLE_PROFILING=1Enables the CLR profiler
CORECLR_PROFILER={918728DD-259F-4A6A-AC2B-B85E1B658318}ID of the OpenTelemetry profiler (always this value)
CORECLR_PROFILER_PATHPath to the native profiler library for your OS, libc and CPU
DOTNET_STARTUP_HOOKSLoads the managed part of the instrumentation
OTEL_DOTNET_AUTO_HOMEInstallation directory of the instrumentation

The exporter is configured with the standard OpenTelemetry variables:

VariableValue
OTEL_SERVICE_NAMEYour service name
OTEL_EXPORTER_OTLP_ENDPOINTA local collector (http://localhost:4318), or KubeSense directly (http://<KUBESENSE_INGEST_HOST>:33443)
OTEL_EXPORTER_OTLP_PROTOCOLhttp/protobuf
OTEL_RESOURCE_ATTRIBUTESkubesense.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.