Dotnet
<!-- status: ga language: dotnet -->
.NET: zero-code instrumentation
The OpenTelemetry .NET automatic instrumentation attaches to ASP.NET Core, HttpClient, SqlClient and more without a code change. Nothing Watchtower-specific is installed: it reads the standard OTEL_* variables.
Create a project, then an ingestion key (
wti_...) with theingest:tracesscope. The key is shown once.Point the instrumentation at the gateway and pass the key in the
x-watchtower-keyheader:
export OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.example.com
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_HEADERS=x-watchtower-key=wti_YOUR_KEY
export OTEL_SERVICE_NAME=my-serviceInstall the instrumentation from the opentelemetry-dotnet-instrumentation releases and start the service through its launcher script:
curl -sSfL https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/latest/download/otel-dotnet-auto-install.sh -O
sh ./otel-dotnet-auto-install.sh
. $HOME/.otel-dotnet-auto/instrument.sh
dotnet MyApp.dllOn Windows use OpenTelemetry.DotNet.Auto.psm1 (Register-OpenTelemetryForCurrentSession) instead of instrument.sh.
Send one request to the service, then open the project's onboarding screen: it turns green when the first span arrives.