-
Notifications
You must be signed in to change notification settings - Fork 209
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
Elastic.Apm.AspNetFullFramework not showing database calls #700
Comments
Hi, by default db monitoring is not turned on in the Full Framework setup. If you use Entity Framework 6, then here is the doc on how to turn it on: https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup.html#setup-ef6 If you use EF Core, then simply execute this code once when your app starts up:
|
Is it possible to use this if EF6/EFCore is not used in the project? |
Currently we only have EF6 and EFCore official support. We also have something for So these are the 2 (+1) database libraries we support at the moment by auto instrumentation. Alternatively, you can also manually track the db calls by the public agent API - although I admit this is less convenient. What database do you use? |
Great! Then this is something that we almost already support. So, there is no official NuGet package, but we have this project in the repo: https://github.com/elastic/apm-agent-dotnet/tree/master/src/Elastic.Apm.SqlClient That is the auto instrumentation for If you clone the repo and build that project you can create an assembly from that. That will give you a After that, all you need to do is to execute this once, preferably during the startup of the application:
This way you can give it a try. But please keep in mind this is not an officially released component yet. The main reason it's not yet released is because we don't have a solution for scenarios when EF or EF Core is used with MSSql - in that case EF (Core) uses Once we have a solution for this problem, the plan is to have an official release of this package. |
Oh, yeah. We use You can just install it additionally to your existing one. - alternatively I guess it'd also work if you change the version to yours in the |
Is there a chance I can get this prebuilt somehow? Downgraded mine to 3.1.100, but still get the same version errors. I'm probably missing a lot of the references, not sure why, though - tried on two separate build environments all with the SDKs installed, same errors on both. |
You can download it from our CI: https://apm-ci.elastic.co/job/apm-agent-dotnet/job/apm-agent-dotnet-mbp/job/master/ On the top of the page you'll see "Last Successful Artifacts". The You can either setup a local nuget feed and put it there, or just unzip it and add the |
@sawo1337 |
Thanks for the tip @SergeyKleyman! I've just read that 3.1 is only for VS 2019 as well, we only use 2017 at the moment. @gregkalapos thanks for the workaround, I've got all packages to install locally - Elastic.Apm.1.2.0, Elastic.Apm.AspNetFullFramework.1.2.0 and Elastic.Apm.SqlClient.1.2.0 from Master, but after running the web code, still just HTTP calls are shown. I've tried this on an empty MVC project and on one of our test solutions, but both aren't showing any DB calls in the trace sample in Kibana. edit: here is the sample code that I'm using to test this: (basically a asp.net page that displays the current time as taken from the database)
|
@sawo1337, I'm afraid of
@gregkalapos, FYI, I created an issue #702 to add documentation for |
Hmm, I'm afraid what @vhatsura says is true here. You could turn the loglevel to debug to maybe see more, but probably the outcome would be that no span creation is started for the db call. I'm not sure if this is true for all versions... I thought that some code flows back to full framework from .NET Core - it'd be useful to test newer .NET Framework versions too. |
@gregkalapos that is unfortunate indeed. Do you have plans for implementing this in the future? I can speak to some of our software developers and see if we can help implementing it as well. Just to see where we stand, I've enabled debugging, just not sure where the logs would go for the .NET agent? I've looked over the documentation, but the information is mostly for the java agent from what I can see. When viewing the host logs from Kibana, it doesn't look like there is any debug data: @vhatsura thanks for these details, do you mean that the DiagnosticSource implemented in Microsoft.Data.SqlClient is incompatible, or that it is not there at all? From what I can see Application Insights are using it, so it looks like it is there even in the SqlClient for the full .NET framework? |
@sawo1337 It seems it's only dotnet core :( https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.diagnosticsource?view=netcore-3.1 No traces of it in full framework https://github.com/microsoft/referencesource/search?q=DiagnosticSource&unscoped_q=DiagnosticSource Would also love to see this working on full framework, following! |
@anderssonjohan strange, wondering how application insights work then? I've seen people refer to EventSource as well, which is deeper trace than DiagnosticSource edit: |
@sawo1337, first of all, to be clear. I'm not working for Elastic, I'm just an external contributor. What I see from ApplicationInsights code. For the .Net 4.5 there is the usage of |
If course, happy to take any input!
|
@vhatsura appreciate all your help here! Even if it's mostly brainstorming and ideas, the Elastic team could still benefit from all the research we've done so far.
If I understand it correctly, one needs to reference the Http assembly from the dotnet core in order to use diagnostic source listener in .NET 4.5? @gregkalapos from what I've seen, Stackify is reading the db calls in our environment, most likely they are using EventListener, the performance is pretty good overall, I believe it will be comparable to DiagnosticSource. If SqlClientDiagnosticSourceListener is a feasible option on the other hand, most likely that will require less work on changing the existing code. |
I totally agree with you. My mention was related to not retranslate my words on behalf of the owners.
So, this mention is related to the case, when you reference .net core |
Small update:
|
Great work @vhatsura ! I've been experimenting with different versions of the packages, tried the latest SqlClient 2.0.20021.1 released just days ago, but there isn't any change as expected. Tried .NET Framework 4.8 as a target for my test project just for the test, it behaves the same as 4.6.1. |
@sawo1337, unfortunately, to use
edit: |
@vhatsura is it possible that the events are fired, just not from Microsoft-AdoNet-SystemData? I've read blog posts from Microsoft that EventSource should be possible to use for both .NET and Core? |
#704 merged - so in theory this could be tested again. One unfortunate finding is that there isn't a way to capture the sql command itself on Full Framework if you use |
I'll give it a try on my test project - definitely still better than nothing! |
Hi, I would like to try to use the Elastic.Apm.SqlClient package, but it is not available in nugget yet. So, how can I use this package in my .net core app? |
@diegodfsd there is no official release yet, but you can try already. Here is a comment on how to do so. You can find the nuget package here in our CI. Some docs are here. I think all we planned to do in this issue is done - closing now. If something is missing here feel free to reopen. Again, huge thanks to @vhatsur 👏 . |
Only the HTTP calls are shown in Kibana in the Trace sample, there is nothing on database calls
There is nothing in the documentation specific to database queries interception for the full .net framework - https://www.elastic.co/guide/en/apm/agent/dotnet/current/setup.html#setup-asp-net
Steps to reproduce the behavior:
Execute any type of query using System.Data.SqlClient, for example
See the output in Kibana - only HTTP call is shown
Expected behavior
Trace sample to include SQL calls as well.
The text was updated successfully, but these errors were encountered: