Skip to content

.NET

Instrumenting your existing .NET application with the OpenTelemetry SDK gives you the flexibility to capture custom metrics, manual spans, and tailored application context.

Install the core OpenTelemetry .NET packages and the OTLP exporter via NuGet:

dotnet add package OpenTelemetry
dotnet add package OpenTelemetry.Exporter.OpenTelemetryProtocol
dotnet add package OpenTelemetry.Extensions.Hosting

Configure the OpenTelemetry exporter to send data to the KloudMate Agent’s OTLP endpoint. By default, the KloudMate agent listens on port 4318 for HTTP OTLP traffic (or 4317 for gRPC).

You can configure the endpoint via environment variables before running your instrumented code:

export OTEL_EXPORTER_OTLP_ENDPOINT="http://KM_AGENT_HOST:4318"
export OTEL_SERVICE_NAME="your-dotnet-service"

(Replace KM_AGENT_HOST with the IP address or hostname of your KloudMate Agent).

OpenTelemetry is continuously evolving. For the most up-to-date SDK instructions, advanced configurations, and custom instrumentation details, refer to the official OpenTelemetry documentation:


Looking for a step-by-step tutorial?
Check out our Instrument a .NET App guide to see how to manually instrument a simple .NET API application.