![]() |
VOOZH | about |
dotnet add package OpenTelemetry.Instrumentation.Owin --version 1.15.1-beta.1
NuGet\Install-Package OpenTelemetry.Instrumentation.Owin -Version 1.15.1-beta.1
<PackageReference Include="OpenTelemetry.Instrumentation.Owin" Version="1.15.1-beta.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Owin" Version="1.15.1-beta.1" />Directory.Packages.props
<PackageReference Include="OpenTelemetry.Instrumentation.Owin" />Project file
paket add OpenTelemetry.Instrumentation.Owin --version 1.15.1-beta.1
#r "nuget: OpenTelemetry.Instrumentation.Owin, 1.15.1-beta.1"
#:package OpenTelemetry.Instrumentation.Owin@1.15.1-beta.1
#addin nuget:?package=OpenTelemetry.Instrumentation.Owin&version=1.15.1-beta.1&prereleaseInstall as a Cake Addin
#tool nuget:?package=OpenTelemetry.Instrumentation.Owin&version=1.15.1-beta.1&prereleaseInstall as a Cake Tool
| Status | |
|---|---|
| Stability | Beta |
| Code Owners | @open-telemetry/dotnet-contrib-maintainers |
👁 NuGet version badge
👁 NuGet download count badge
👁 codecov.io
This is an Instrumentation Library, which instruments OWIN/Katana and collects telemetry about incoming requests.
An example project is available in the examples/owin folder.
Add a reference to the
OpenTelemetry.Instrumentation.Owin
package. Also, add any other instrumentations & exporters you will need.
dotnet add package OpenTelemetry.Instrumentation.Owin
Call the UseOpenTelemetry IAppBuilder extension to register OpenTelemetry
middleware which emits diagnostic events from th OWIN pipeline. This should be
done before any other middleware registrations.
using var host = WebApp.Start(
"http://localhost:9000",
appBuilder =>
{
appBuilder.UseOpenTelemetry();
});
Call the AddOwinInstrumentation TracerProviderBuilder extension to register
OpenTelemetry instrumentation which listens to the OWIN diagnostic events.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Owin-Example"))
.AddOwinInstrumentation()
.AddConsoleExporter()
.Build();
Following list of attributes are added by default on activity. See http-spans for more details about each individual attribute:
http.request.methodhttp.request.method_originalhttp.response.status_codenetwork.protocol.versionuser_agent.originalserver.addressserver.porturl.pathurl.query - By default, the values in the query component are replaced with
the text Redacted. For example, ?key1=value1&key2=value2 becomes
?key1=Redacted&key2=Redacted. You can disable this redaction by setting the
environment variable
OTEL_DOTNET_EXPERIMENTAL_OWIN_DISABLE_URL_QUERY_REDACTION to true.url.schemeCall the AddOwinInstrumentation MeterProviderBuilder extension to register
OpenTelemetry instrumentation which generates request duration metrics for OWIN
requests.
The metric implementation does not rely on tracing, and will generate metrics even if tracing is disabled.
using var openTelemetry = Sdk.CreateMeterProviderBuilder()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Owin-Example"))
.AddOwinInstrumentation()
.AddConsoleExporter()
.Build();
The instrumentation is implemented based on metrics semantic conventions. Currently, the instrumentation supports the following metric.
| Name | Instrument Type | Unit | Description |
|---|---|---|---|
http.server.request.duration |
Histogram | s |
Duration of HTTP server requests. |
The OpenTelemetry OWIN instrumentation will create spans with very generic names
based on the http method of the request. For example: HTTP GET or HTTP POST.
The reason for this is the OpenTelemetry Specification http semantic
conventions
call specifically for low cardinality values and OWIN does not expose any kind
of route template.
To change the span name set Activity.Current.DisplayName to the value you want
to display once a route has been resolved. Here is how this can be done using WebAPI:
using var host = WebApp.Start(
"http://localhost:9000",
appBuilder =>
{
appBuilder.UseOpenTelemetry();
HttpConfiguration config = new HttpConfiguration();
config.MessageHandlers.Add(new ActivityDisplayNameRouteEnrichingHandler());
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
appBuilder.UseWebApi(config);
});
private class ActivityDisplayNameRouteEnrichingHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
try
{
return await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
}
finally
{
var activity = Activity.Current;
if (activity != null)
{
var routeData = request.GetRouteData();
if (routeData != null)
{
activity.DisplayName = routeData.Route.RouteTemplate;
}
}
}
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
Showing the top 3 NuGet packages that depend on OpenTelemetry.Instrumentation.Owin:
| Package | Downloads |
|---|---|
|
Grafana.OpenTelemetry
Full Grafana distribution of OpenTelemetry .NET |
|
|
Honeycomb.OpenTelemetry.CommonInstrumentations
Honeycomb's OpenTelemetry common instrumentations package. Adds support for many common instrumentation libraries for you. |
|
|
Honeycomb.OpenTelemetry.AutoInstrumentations
Honeycomb's OpenTelemetry autoinstrumentations package. Adds support for many common instrumentation libraries for you. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.15.1-beta.1 | 10,029 | 4/21/2026 | |
| 1.15.0-beta.1 | 9,152 | 1/21/2026 | |
| 1.14.0-beta.1 | 5,667 | 11/13/2025 | |
| 1.13.0-beta.1 | 2,389 | 10/23/2025 | |
| 1.12.0-beta.1 | 51,148 | 5/5/2025 | |
| 1.11.0-beta.1 | 7,834 | 3/5/2025 | |
| 1.10.0-beta.1 | 5,438 | 12/20/2024 | |
| 1.0.0-rc.6 | 133,290 | 4/19/2024 | |
| 1.0.0-rc.5 | 1,086 | 4/17/2024 | |
| 1.0.0-rc.4 | 5,851 | 3/20/2024 | 1.0.0-rc.4 is deprecated. |
| 1.0.0-rc.3 | 113,772 | 9/20/2022 | 1.0.0-rc.3 is deprecated. |
| 1.0.0-rc.2 | 1,857 | 3/18/2022 | 1.0.0-rc.2 is deprecated. |