Automatically instruments the incoming requests to ASP.NET.
dotnet add package OpenTelemetry.Instrumentation.AspNet
Configuration with ASP.NET (Full .NET Framework) running in IIS or IIS Express (if supported) to collect incoming request information.
-
Add a reference to the
OpenTelemetry.Instrumentation.AspNet
package. Add any other instrumentations & exporters you will need. -
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>
-
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() .AddHttpInstrumentation(); }); } protected void Application_End() { this.tracerFactory?.Dispose(); } }