Skip to content

Missing AppDependencies entry when using Microsoft.Data.SqlClient v2.0.0 #2032

@karinazhou

Description

@karinazhou

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 :
dotnet/SqlClient#678

Detailed investigation can be found here:
dotnet/SqlClient#678 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions