ApplicationInsights-dotnet: Missing AppDependencies entry when using Microsoft.Data.SqlClient v2.0.0

Environment

  • NuGet packages: “Microsoft.ApplicationInsights.Wcf” 0.28.0-build06820 “Microsoft.ApplicationInsights.WindowsServer” 2.14.0 “Microsoft.Data.SqlClient” 2.0.0

  • Runtime version

    net48

  • Hosting environment: Windows

Describe the bug

This issue is originally reported here : https://github.com/dotnet/SqlClient/issues/678

Detailed investigation can be found here: https://github.com/dotnet/SqlClient/issues/678#issuecomment-687331875

Since the EventSource name in Microsoft.Data.SqlClient v2.0.0 has been changed from Microsoft-AdoNet-SystemData to Microsoft.Data.SqlClient.EventSource, the DependencyCollector is not able to capture the EventSource from Microsoft.Data.SqlClient.

https://github.com/microsoft/ApplicationInsights-dotnet/blob/develop/WEB/Src/DependencyCollector/DependencyCollector/Implementation/FrameworkSqlEventListener.cs#L24

To Reproduce

The repo WCF Service application is attached. Before you compile it, modify the SQL Server connection string with any server you have access to. It’s by default using the localhost server.

You can use the following queries to create the database and table:

CREATE DATABASE [DB1] 
GO 

USE [DB1]
CREATE TABLE [dbo].[Users]( [Id] [int] NOT NULL, [Name] [nvarchar](50) NOT NULL, CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] )
GO

USE [DB1]
GO
INSERT INTO [Users] VALUES(1, 'one')
GO

Run the WCF Service application from Visual Studio 2019 and attach the service to WCF Test Client. When invoking the GetData(), there are only AppRequests entry being captured in output window.

image

Application Insights Telemetry (unconfigured): {"name":"AppRequests","time":"2020-09-04T21:51:51.5458149Z","tags":

Expected

The following AppDependencies entry with type SQL is captured by Application Insights when using Microsoft.Data.SqlClient v1.1.3:

Application Insights Telemetry (unconfigured): {"name":"AppDependencies","time":"2020-08-31T18:25:00.4838283Z","tags"... ,"success":true,"type":"SQL","target":"localhost | DB1","properties":{"DeveloperMode":"true","_MS.ProcessedByMetricExtractors":"(Name:'Dependencies', Ver:'1.1')"}}}}

WcfService2.zip

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Hello all, this issue has been fixed and will be available in 2.17-beta1. We’re starting our release process and hoping to have this available by Friday (12/18) or Monday (12/21).

@karinazhou Sorry for the delay. The team has been occupied with other products, and we didn’t have the bandwidth to include this bug fix in the coming release (2.16). Tagging this for 2.17. Don’t have an ETA on when 2.17 GA will release, but we’ll release a 2.17-beta1 in next 1-2 weeks.

Hi, I am using version 2.17-beta1 and still not getting any dependency data. Was this change committed to the beta patch?

https://stackoverflow.com/questions/65528423/application-insights-in-console-wpf-application-with-dependencytracking

This change was never about getting SQL query text in the dependency logging but rather about getting any SQL dependency loggning when using (strictly) Microsoft.Data.SqlClient v2+.

If I read the SO question correctly you are not using Microsoft.Data.SqlClient v2+ ?

@karinazhou there is no update that I know of (I’m not the author of PR #2034) and to be honest I have no idea how this project is being managed or how things get triaged/included! This feels like a very big bug but it’s not getting any attention.

PR #2034 is a working fix but the author doesn’t have the time to fufill all of the submission criteria. I sympathise; I think the barrier to entry is too high given most of us don’t work full time for Microsoft.

Another vote to fix this from us. We’ve upgraded our SqlClient to the latest version and have lost our SQL telemetry. This is a bug.