Skip to content

Latest commit

 

History

History
66 lines (53 loc) · 2.07 KB

File metadata and controls

66 lines (53 loc) · 2.07 KB

ASP.NET Instrumentation for OpenTelemetry .NET

NuGet NuGet

Automatically instruments the incoming requests to ASP.NET.

Installation

dotnet add package OpenTelemetry.Instrumentation.AspNet

Configuration

Configuration with ASP.NET (Full .NET Framework) running in IIS or IIS Express (if supported) to collect incoming request information.

  1. Add a reference to the OpenTelemetry.Instrumentation.AspNet package. Add any other instrumentations & exporters you will need.

  2. Add the Microsoft telemetry module in your Web.config:

    <system.webServer>
      <modules>
        <add name="TelemetryCorrelationHttpModule"
        type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule,
        Microsoft.AspNet.TelemetryCorrelation"
        preCondition="integratedMode,managedHandler" />
      </modules>
    </system.webServer>
  3. Configure OpenTelemetry in your application startup:

    public class WebApiApplication : HttpApplication
    {
        private TracerFactory tracerFactory;
        protected void Application_Start()
        {
            this.tracerFactory = TracerFactory.Create(builder =>
            {
                builder
                    .UseJaeger(c =>
                    {
                        c.AgentHost = "localhost";
                        c.AgentPort = 6831;
                    })
                    .AddAspNetCoreInstrumentation()
                    .AddHttpClientInstrumentation();
            });
        }
        protected void Application_End()
        {
            this.tracerFactory?.Dispose();
        }
    }

References