Windows .NET Application Tracing
Last updated
Last updated
This guide is based on a ASP.NET application deployed on IIS. Please reference Otels documentation for different setups - .NET zero-code instrumentation
At the time of writing, the latest version of the OpenTelemetry Collector is 0.117.0
Find the appropriate binary for your system on the Otel release page
In this example we will be using otelcol_0.117.0_windows_x64.msi
Execute the downloaded executable. This will initiate a Windows service and also create the directory C:\Program Files\OpenTelemetry Collector
Edit C:\Program Files\OpenTelemetry Collector\config.yaml and replace the content with the below
receivers: otlp: protocols: grpc: endpoint: localhost:4317 http: endpoint: localhost:4318 processors: batch: exporters: otlphttp: traces_endpoint: https://<your_domain>/v1/json_batch/otlptraces encoding: json compression: gzip headers: Authorization: "Bearer <your_token>" tls: insecure: false insecure_skip_verify: true service: pipelines: traces: receivers: [otlp] processors: [batch] exporters: [otlphttp]
Replace <your_domain> with the domain of your Ascent environment e.g company.apica.io
Replace <your_token> with your ingest token (How to get your ingest token)
In Services, restart the OpenTelemetry Collector service
Latest version at the time of writing - v1.9.0
Download the PowerShell Module - OpenTelemetry.DotNet.Auto.psm1
Open a PowerShell prompt as Administrator and execute the below commands - NOTE change the file path as needed per your system
Import the module
Import-Module "C:\Users\opc\Downloads\OpenTelemetry.DotNet.Auto.psm1"
Install core files
Install-OpenTelemetryCore
Setup IIS instrumentation
Register-OpenTelemetryForIIS
If your application has TLS enabled (uses HTTPS)
Configure environment variable
[System.Environment]::SetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4317", "Machine")
Restart IIS
iisreset
If your application does not have TLS enabled (uses HTTP)
Configure environment variables
[System.Environment]::SetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4318", "Machine") [System.Environment]::SetEnvironmentVariable("OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf", "Machine")
Restart IIS
iisreset
Register-OpenTelemetryForIIS
and iisreset
performs an IIS restart.
Depending on the amount of traces generated, you can pretty quickly verify that traces is passing through to Ascent by navigating to Explore > Distributed Tracing and in the dropdown Service you will after a short while see your application appear.
If you follow the below optional step, that service name will appear as an identifier in Ascent.
(Optional) Set custom service name - This is how the service would appear in Ascent. Execute in a PowerShell as Admin
[System.Environment]::SetEnvironmentVariable("OTEL_SERVICE_NAME", "My ASPNET Application", "Machine")iisreset