Dotnet

Embed
Preview of the card
<a href="https://forumulate.com/p/watchtower/docs/instrumentation-dotnet"><img src="https://forumulate.com/api/public/orgs/watchtower/spaces/docs/pages/98148c20-acf1-4cb2-a2fc-f5a5aad5a515/social-card.svg?v=3e7ae33eec8b" alt="Dotnet" width="600" height="315"></a>

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

  1. Create a project, then an ingestion key (wti_...) with the ingest:traces scope. The key is shown once.

  2. Point the instrumentation at the gateway and pass the key in the x-watchtower-key header:

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-service
  1. Install 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.dll

On Windows use OpenTelemetry.DotNet.Auto.psm1 (Register-OpenTelemetryForCurrentSession) instead of instrument.sh.

  1. Send one request to the service, then open the project's onboarding screen: it turns green when the first span arrives.

Updated