-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App Insights does not collect SQL dependencies out of the box #1613
Comments
I was running into this too, and I think I found the solution. According to the first note in this documentation, SqlClient logging only work with Manually add This documentation note should be in more places, in my opinion, especially Azure Functions docs and not just Azure Monitor. A lot of people don't depend on Edit: Actually, I'm still having trouble even with the latest |
Microsoft.NET.Sdk.Functions 3.0.7 |
Is anyone seeing ServiceBus/EventHub message tracing. That used to work and now seems to have stopped too |
We are facing the same issue. After some testing, a few things became clear. Workaround: Stick with System.Diagnostics.DiagnosticSource 4.7.0. You must use Microsoft.EntityFrameworkCore 3.1.3 or earlier for that.
I hope this helps. |
@gocha thank you. Tested with above workaround. It is working for me as well. But, not sure if there were any major bug fixes between EF Core 3.1.3 and 3.1.7/8 and if it will impact us in later stage. Any idea if this can be fixed in 3.1.8 or later version? |
Not sure why downgrading Microsoft.EntityFrameworkCore.SqlServer to 3.1.3 works. It has dependency on the same version of Microsoft.Data.SqlClient as 3.1.4 |
Could this be related to this issue which is fixed in Application Insights SDK 2.17beta1? But we cannot choose versions of Application Insights SDK used by functions host and have to wait until functions runtime is updated and update is rolled out? |
@gocha thanks! It's not just SQL dependencies, also servicebus dependencies are affected and solved the same way, by downgrading every reference to work with System.Diagnostics.DiagnosticSource 4.7.0. in My case I was also using the latest Microsoft.Graph which depended on a higher version, but downgrading to 3.20.0 worked with System.Diagnostics.DiagnosticSource 4.7.0. |
@erwinkramer - I checked my func app and it appears to be using System.DiaganosticSource <=4.7.0 but still SQL dependency is not surfacing in App Insights Using Microsoft.Data.SqlClient 2.1.1 and Dapper 2.0.78 of database interaction Thoughts? host.json {
"version": "2.0",
"logging": {
"applicationInsights": {
"dependencyTrackingOptions": {
"enableSqlCommandTextInstrumentation": true
},
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Dependency;Request"
}
},
"logLevel": {
"default": "Information"
}
}
}
|
@jeffhollan @anthonychu Can one of you help direct this to the correct repository? This is all fixed in the latest combination of released package versions of App Insights 2.17/SqlClient 2.x and upgrading the functions runtime to to app insights 2.17 should fix the issue for anyone using EF Core >= 3.1.4. This repository doesn't appear to actually host anything other than documentation and samples so it's not clear the right people have visibility on this issue. |
@ssa3512 I tried EF 3.1.13 with Application Insights 2.17 and it didn't work. I had to downgrade to EF 3.1.3 and AI 2.15 |
@pzbyszynski yes - I believe the functions team has to update the host to use 2.17. It's not something someone consuming the Azure Functions runtime/sdk can simply do to make it work. |
@brettsam can you help with this? |
@soninaren added this functionality in PR Azure/azure-webjobs-sdk#2608. At first glance the host.json above looks correct -- Naren can you investigate this? |
@brettsam the issue is that no sql dependencies are logged at all, not that the command text is missing. |
You need to add "EnableDependencyTracking": true to host.json for dependencyTrackingOptions to take effect. Adding sample host.json below
|
@soninaren I pushed the above As others have noted, there seem to be inconsistencies in behaviors between EF Core It seems the ideal fix for all of this is to just update the functions host to ApplicationInsights 2.17.0 which forces a newer version of System.Diagnostic.DiagnosticSource, and provides the fix to support the new event name coming from SqlClient 2.0 or greater (for people already using that in their applications). Simply updating the AppInsights SDK package version in my project to 2.17 and updating does NOT resolve the issue, and dependencies are still not tracked. Updating to AppInsights SDK 2.17 on other non-functions projects that are doing plain ADO.NET results in dependencies being tracked fine. Likewise, using the latest version of the app insights SDK with EF Core >= 3.1.4 results in dependency telemetry being tracked as expected. As an aside, it appears service bus telemetry may also be fixed by the update to a newer version of System.Diagnostic.DiagnosticSource (Azure/azure-functions-host#7081) Some of the traces getting logged in my sample functions app also seem to point to the issue: |
I can confirm that downgrading my dependencies from 3.1.6 to 3.1.3 fixed the issue for me. |
Any idea when the functions host can be updated with Application Insights 2.17.0? |
Any update on this would be really appreciated, we are also suffering with the same issue. |
We are also experiencing the same issue. The rollback to Microsoft.EntityFrameworkCore.SqlServer version 3.1.3 resulted in the dependency tracking for SQL and Service Bus to log as before. It does mean however we are stuck on version 3.1.3 until the bug is fixed and it would be great to be able to upgrade soon. Are there any plans to fix the issue? Thanks |
We are not using EF in our functions and we have the same problem. We are using Microsoft.Data.SqlClient 2.1.2 and still don't see any SQL dependencies logged to AppInsights. Any know workarounds? Timeline for a fix? |
The same problem here, downgrade to 3.1.3 also works for me |
@ankitkumarr I see you provided a (possible?) fix. Can you update us on the status? |
This is soooo frustrating... @erwinkramer asked a question over a month ago, with no answer... I take part in several issues that seem a quick fix, still not fixed after several years. This particular issue was submitted over a year ago. As a user of your services I fell completely ignored. And just to remind you, AI is not some random open source project, based on good will of it's maintainer. You are charging some serious bucks for it!!! And support definitely does not match price tag unfortunately 😣 |
I reported the problem to dotnet/efcore, but they closed it: dotnet/efcore#25613 This is still a problem 3.1.4 to 3.1.18 |
As other have pointed out the problem is So as a workaround i have just made a script that remove System.Diagnostic.DiagnosticSource.dll before I deploy the functoin and it fix the problem. |
Hi @HenrikSommer-eng, is there any chance you could post the script you've used? Thanks |
@ttq-ak sure this is part of pipeline task: (remove the file from the zip file we deploy) - task: PowerShell@2
displayName: 'Fix log bug:'
inputs:
targetType: 'inline'
script: |
# EF core 3.1.4+ include System.Diagnostics.DiagnosticSource.dll and it is breaking all our logging
# https://github.com/Azure/Azure-Functions/issues/1613
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression')
$zipfile = (Get-Item -Path "$(build.artifactstagingdirectory)\\**.zip").FullName
$files = "System.Diagnostics.DiagnosticSource.dll"
Write-Host "Zip: $zipfile"
$stream = New-Object IO.FileStream($zipfile, [IO.FileMode]::Open)
$mode = [IO.Compression.ZipArchiveMode]::Update
$zip = New-Object IO.Compression.ZipArchive($stream, $mode)
($zip.Entries | ? { $files -contains $_.Name }) | % { $_.Delete() }
$zip.Dispose()
$stream.Close()
$stream.Dispose() |
Apologies for the delayed response, the issue was somehow lost in the trace. Were you able find a solution? do let us know if a follow up is required. I shall follow with the right team members to resolve this issue. |
@v-bbalaiagar the code is post is not a solution. It is a workaround until someone solve the real problem. |
Thank you for your feedback! We will check for the possibilities internally and update you with the findings. |
This looks to me like a good justification for the isolated process worker of Azure Functions.
The problem here being that the in-process function host is using System.Diagnostics.DiagnosticSource 4.7.0, and if your app references a later version, it's going to cause problems. An isolated process could use any version of DiagnosticSource without leading to conflicts. |
I was able to work around this by using this workaround. thanks!
Have any idea when this problem will be fixed? |
In my case, after migrating to .NET 6 (i.e. Function Runtime v4) and Entity Framework Core 6, the artifact zip file did not contain System.Diagnostics.DiagnosticSource.dll and this problem did not occur. FYI. |
Created Azure Functions project out of the box in Visual Studio
Microsoft.NET.Sdk.Functions 3.0.7
Microsoft.EntityFrameworkCore.SqlServer 3.1.4
AppInsights does not collect SQL dependencies.
All other like HTTP, Azure BLOB, Azure Table are collected.
The text was updated successfully, but these errors were encountered: