Elastic APM .NET agent

Kibana version: 6.7.1

Elasticsearch version: 6.7.1

APM Server version: 6.7.1

APM Agent language and version: .net 0.0.2

Browser version: Google chrome Version 73.0.3683.103

Original install method (e.g. download page, yum, deb, from source, etc.) and version: yum

Fresh install or upgraded from other version? fresh installation

Is there anything special in your setup? For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

No, setup is at very initial state, passing APM output to elasticsearch, using default index pattern

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

i did APM setup for .net with the help of belo link:
https://www.elastic.co/guide/en/apm/agent/dotnet/current/index.html

getting service traces on KIBANA APM UI, but the issue is i am not able to get sql query's inside traces like i am getting for java and nodejs and also not getting full trace view,
e.g if one API internally calling another API then in java and nodejs i when i click on "view full trace" then i am able to see internal multiple API call but not in .net.
can you help?

Hi @Pradnya,

currently the agent only captures SQL statements for Entity Framework Core.

Therefore, the first question is: do you use Entity Framework Core in your application?

Of course non Entity Framework Core scenarios are also on our radar, but that is not implemented yet. There is an issue for that, you can track the progress there: https://github.com/elastic/apm-agent-dotnet/issues/114

yes. i am using Entity Framework Core. can you provide what any snippet i need to add in my code or any other changes, and i am using 0.0.2 version for elastic apm agent for .net.

is it the latest version?

Perfect! Then in this case we should be able to make it work.

Yes, version 0.0.2 is the latest package.

What type of application do you have? If it’s an ASP.NET Core app and you added the Elastic.Apm.All package then it should work with this snippet:


using Elastic.Apm.All; //this namespace comes from the `Elastic.Apm.All` package
//more usings that the app needs

namespace SampleAspNetCoreApp
{
	public class Startup
	{
		public Startup(IConfiguration configuration) => Configuration = configuration;
		public IConfiguration Configuration { get; }
		public void ConfigureServices(IServiceCollection services)
		{
			//nothing agent related here
		}
		public void Configure(IApplicationBuilder app, IHostingEnvironment env)
		{
 			//here you register the agent, and this also starts tracing EF Core calls and capture SQL statements
			app.UseElasticApm(Configuration);
		}

	}
}

If it’s not an ASP.NET Core app then you can use this line to activate EF Core tracking (typically somewhere early in the life cycle of the app):

Agent.Subscribe(new EfCoreDiagnosticsSubscriber());

The EfCoreDiagnosticsSubscriber type lives in the Elastic.Apm.EfCore NuGet package (which is referenced by the Elastic.Apm.All package), so make sure that this package is added to your app.

Let me know how it went, if it still does not work the next step will be to switch the LogLevel to Debug and see the agent output.

I have already added app.UseElasticApm(Configuration); in code.
able to get traces but not DB traces and also full traces.

In this case we should debug this and figure out what's going on.

Could you please turn on debug logs and paste the logs here? Here is a sample on how to do it... instead of "Error", simply use "Debug" and you will see more logs from the agent on the console output.

And one other question: what do you mean by "full trace"?

Hello,
now i am able to get DB traces, having some small issues but that i will fix.

but still not able to view full trace, when i open APM window from kibana, in that inside of my dotnet service i click on transaction (GET,POST) in that on right side there is option for "view full trace" for java and nodejs which i configured i get full trace details in timeline like exact flow of my services, as the one service called my multiple services do in full trace m able to view which are the other services are being called, this function i am not able to see in dotnet services.

I see. Sorry, I could have figured out what you mean :slight_smile:

Unfortunately that feature is not included in the latest alpha release (0.0.2), but it's already implemented and we have it on the master branch on GitHub.

We are in the preparation of moving the agent from alpha into beta, so we haven't really planned another alpha release.

I think we have 2 options here:

  • you can build the agent yourself from GitHub. I know this is not ideal.
  • or you wait until the next release. Unfortunately I can't really tell when this happens... we have a couple of TODOs in order to make the agent "beta".

Btw. could you share the solution for the missing DB statements? This is maybe something that we can also improve in the agent to make sure that this doesn't happen to other users. Thanks!

Thanks,
Actually in my setup i am deploying .NET services in docker swarm with Dockerfile, previously i have mentioned elasticapm details only in the code later on i declared APM related environment variables in Dockerfile also and it worked.

Thanks for the update about .NET elasticapm agent, as per options provided by you.
Can you provide any guidance to build the agent myself from Github?
Kindly correct Github repository: https://github.com/elastic/apm-agent-dotnet

I want to try this.. otherwise second option is ok..:frowning:

The easiest way to build the agent from the repo is to just go into the /src/Elastic.Apm.All folder and then execute dotnet build -c Release from there or simply build the Elastic.Apm.All package from Visual Studio. All you need is a .NET Core 2.0+ SDK on your machine.

Then in the /bin folder you'll have all the dlls that you need to reference. Another option is to create a nuget package, publish it to a feed on your local host and reference it from there. In this case also the easiest is to do it with the Elastic.Apm.All package, since that references everything you need.

Thanks.. I am trying to implement the above solution.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.