opentracing-contrib / csharp-netcore

OpenTracing instrumentation for .NET Core 3.1 & .NET 6+ apps
Apache License 2.0
262 stars 74 forks source link

Support Microsoft.Data.SqlClient & don't use "StartActive" for span storage #80

Closed cwe1ss closed 3 years ago

cwe1ss commented 3 years ago

This is the successor of #77 as supporting Microsoft.Data.SqlClient requires different diagnostic listeners. It would otherwise throw casting exceptions.

This also fixes #64 by no longer making the SqlClient-spans active. This didn't work as the SqlClient-libraries use custom async handling that didn't properly work with the AsyncLocal-storage of OpenTracing. The "WriteCommandAfter" events therefore finished the wrong spans (e.g. the EF Core span instead of the SqlClientSpan).

It also adds SqlServer to the OrdersApi-samples so that the behaviour can be tested.

I'll immediately merge this as there hasn't been any other activity in the last few months and I want to get a new version out today. Feel free to comment/create issues if you see any concerns.