open-telemetry / opentelemetry-dotnet-contrib

This repository contains set of components extending functionality of the OpenTelemetry .NET SDK. Instrumentation libraries, exporters, and other components can find their home here.
https://opentelemetry.io
Apache License 2.0
471 stars 279 forks source link

OWIN Instrumentation #56

Closed fjegear closed 3 years ago

fjegear commented 3 years ago

Is there any plan to support OWIN? Looks like it is supported Asp.Net and Asp.Net Core but I have a WebAPI with Asp.Net self hosted using OWIN and I'd like to start using OpenTelemetry.

cijothomas commented 3 years ago

https://github.com/open-telemetry/opentelemetry-dotnet/pull/1472 There was an attempt, but its not finished.

hotpothot commented 3 years ago

@cijothomas, is there any rough ETA when OWIN will be supported?

cijothomas commented 3 years ago

No ETA. I am not aware of anyone who has committed to work on it.

hotpothot commented 3 years ago

Thanks @cijothomas. Does HttpClientInstrumentation depends on HttpModule? Can we add our owin server activity (use ActivitySource and by starting/stopping an Activity from our middleware using an ActivitySource allows the OpenTelemetry SDK to directly listen to the ActivitySource as Alex suggested) and use HttpClientInstrumentation together?

I guess my question is the only missing part in owin is auto instrument with incoming request?

eg. builder .SetResourceBuilder(ResourceBuilder .CreateDefault() .AddService("service name") .AddHttpClientInstrumentation().AddSource("Microsoft.Payment.Web.Server")

CodeBlanch commented 3 years ago

@hotpothot

Does HttpClientInstrumentation depends on HttpModule?

It does not. On .NET Framework we hook into HttpWebRequest/HttpClient using reflection. On .NET Core we listen to the diagnostic events emitted by the runtime.

Can we add our owin server activity (use ActivitySource and by starting/stopping an Activity from our middleware using an ActivitySource allows the OpenTelemetry SDK to directly listen to the ActivitySource as Alex suggested) and use HttpClientInstrumentation together?

Totally! If we built an official OWIN middleware that is exactly what we would do. Create an ActivitySource, start activity at the begging of the middleware, call the inner pipeline, stop activity at the end. Register your source using AddSource on the TraverProvider.