Opentelemetry-dotnet: SqlClient instrumentation doesn't work for Microsoft.Data.SqlClient under .NET Framework

Created on 20 Nov 2020  路  3Comments  路  Source: open-telemetry/opentelemetry-dotnet

Using latest opentelemetry-dotnet, target net461 and use Microsoft.Data.SqlClient nuget package.

SQL activities are not captured.

EDIT: when submitting this issue I first incorrectly assumed the netfx Sql instrumentation relied on DiagnosticSource events, but that is not the case.

Microsoft.Data.SqlClient on netfx uses the WriteBeginExecuteEvent/WriteEndExecuteEvent methods that operate on the EventSource, similar to the System.Data.SqlClient on netfx.

The reason our instrumentation doesn't pick it up is because in Microsoft.Data.SqlClient this event source is named "Microsoft.Data.SqlClient.EventSource", but the instrumentation only listens to the "Microsoft-AdoNet-SystemData".

Note that we have tests for Microsoft.Data.SqlClient and when running against a docker instance of SQL Server on net461 they do actually fail.

cc @CodeBlanch

bug

All 3 comments

Ah, looks like this is because the EventSource was actually renamed in Microsoft.Data.SqlClient, which was done in https://github.com/dotnet/SqlClient/pull/399

So now it makes sense at least, means we need to support both EventSources.

Thanks @mbakalov! I have noticed the net461 tests failing recently but haven't had a chance to look into it. Are you going to submit a PR?

@CodeBlanch - yes, will try to do it tomorrow am!

Was this page helpful?
0 / 5 - 0 ratings