Windows .NET Application Tracing

This guide is based on a ASP.NET application deployed on IIS. Please reference Otels documentation for different setups - .NET zero-code instrumentation

Install Collector

At the time of writing, the latest version of the OpenTelemetry Collector is 0.117.0

  1. Find the appropriate binary for your system on the Otel release page

    1. In this example we will be using otelcol_0.117.0_windows_x64.msi

  2. Execute the downloaded executable. This will initiate a Windows service and also create the directory C:\Program Files\OpenTelemetry Collector

  3. 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]

    1. Replace <your_domain> with the domain of your Ascent environment e.g company.apica.io

    2. Replace <your_token> with your ingest token (How to get your ingest token)

  4. In Services, restart the OpenTelemetry Collector service

Install and configure the .NET Agent

Latest version at the time of writing - v1.9.0

  1. Download the PowerShell Module - OpenTelemetry.DotNet.Auto.psm1

  2. Open a PowerShell prompt as Administrator and execute the below commands - NOTE change the file path as needed per your system

    1. Import the module

      Import-Module "C:\Users\opc\Downloads\OpenTelemetry.DotNet.Auto.psm1"

    2. Install core files

      Install-OpenTelemetryCore

    3. Setup IIS instrumentation

      Register-OpenTelemetryForIIS

    4. If your application has TLS enabled (uses HTTPS)

      1. Configure environment variable

        [System.Environment]::SetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4317", "Machine")

      2. Restart IIS

        iisreset

    5. If your application does not have TLS enabled (uses HTTP)

      1. Configure environment variables

        [System.Environment]::SetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4318", "Machine") [System.Environment]::SetEnvironmentVariable("OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf", "Machine")

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

  1. (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

Last updated

Was this helpful?