question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add instrumentation for Microsoft.Data.SqlClient for .Net Framework target

See original GitHub issue

During implementation auto instrumentation for System.Data.SqlClient it was decided to skip it for Microsoft.Data.SqlClient due to issue which is described in a comment at https://github.com/elastic/apm-agent-dotnet/pull/704#discussion_r381478027.

Shortly, the issue is in the same event source names for System.Data.SqlClient and Microsoft.Data.SqlClient. It was changed in https://github.com/dotnet/SqlClient/pull/399 and the event source name for Microsoft.Data.SqlClient can be found at https://github.com/JRahnama/SqlClient/blob/27f3bba874d55ef3d6670b945cc584e7cd2de69c/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs#L11. The fix is going to be released in v2.0.0-preview2 and as a result will be available in 2.0.0 GA version.

So, it means that we can add support of auto instrumentation for Microsoft.Data.SqlClient package for .Net Framework target.

I open the issue with the following intention:

  1. To not forget that we have such limitation
  2. To understand how users are interested in a feature

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
vhatsuracommented, Apr 18, 2020

Hey, @dominikskiba.

As I understand correctly, you already installed Elastic.Apm.AspNetFullFramework module and configured in a proper way. If so, that means you also need to download Elastic.Apm.SqlClient NuGet package from CI (to be honest, I didn’t do it and it would be nice to ask for more details @gregkalapos ) or wait for public release. After that, you can enable instrumentation for database calls by the following code:

if (Agent.IsConfigured) Agent.Subscribe(new SqlClientDiagnosticSubscriber());

As for place, where you need to put it. Yeap, it can be Init method of Global.asax.cs file, however, I cannot guarantee that will work in your case due to it depends on a codebase. Although in general, it should work and safe to do it. If you still want to do it, you need to look into Global.asax.cs file instead of Global.asax.

I hope, it will help you in your case

0reactions
russcamcommented, Nov 4, 2021

Support for common SqlClient providers has been implemented as part of profiler auto instrumentation in #1534. This includes capturing command text on all target frameworks that the agent supports. Profiler auto instrumentation is scheduled to be released as beta in the next release, 1.12.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SqlClient Instrumentation for OpenTelemetry
This is an Instrumentation Library, which instruments Microsoft.Data.SqlClient and System.Data.SqlClient and collects traces about database operations.
Read more >
Introduction to Microsoft.Data.SqlClient namespace
Learn about the Microsoft.Data.SqlClient namespace and how it's the preferred way to connect to SQL for .NET applications.
Read more >
Microsoft.Data.SqlClient 5.1.1
Provides the data provider for SQL Server. These classes provide access to versions of SQL Server and encapsulate database-specific protocols, ...
Read more >
Microsoft.Data.SqlClient support with Full .NET Framework ...
SqlClient with EF6? Does anyone know that is Microsoft planning to add support for Microsoft.Data.SqlClient in future version of EF7/EF8 (Full .
Read more >
.NET Framework Compatibility Requirements
Note: When deciding which tracer version to use for an automatic instrumentation, use the .NET Framework version installed on the application server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found