Elastic APM not working with .net WCF service.
Please help me how to configure elastic .net apm agent with wcf service.
Its working fine with mvc web application, but not with wcf service.
My application fetching data from sql database by using wcf service.
So i just want to know the db call trace that how much time it took to execute the store proc command.
Could you please help me the steps and configurations.
I am new in APM part.
Thanks in advance!!
for WCF you can try setting up the IIS module as described here in the docs. This may not capture all bindings - if it's a HTTP based WCF setup, then likely it'll capture your transactions, if it's more low level maybe it won't.
If the automatic capturing of the transaction doesn't work, you could try manual instrumentation by starting the transaction manually as described here - this will require some change on your code.
Thanks @GregKalapos ,
For quick reply.
The document part I have alredy tried, that is not working.But I'll verify both the approach again .our application hosted on seprate port. I mean web application on seperate port and wcf service on seperate port. So in which application we need to use that manual transaction code?
Using a different port in itself should not really make a different from the agent's point of view, so that's fine.
So in which application we need to use that manual transaction code?
This basically depends on what the agent captures out of the box - worst case the agent won't capture anything, in that case you'd need to manually instrument the code both in the client and in the server side. If you see part of the request showing up in Kibana out of the box - i.e. you see the server side and you don't see the client side which calls into the WCF service (this is a likely scenario) then you'd need to instrument the caller code.
Hi @GregKalapos ,
Thanks for the update, I tried but still not working. In my case, my web application was deployed on the XXXX server & the service deployed on the YYYY server. I have configured the .net agent configuration in my web application only. And for web applications, it's working fine. but not able to get database related information which is a part of our service code. so just wanted to know that do we need to configure.net agent configuration on the service side also? If yes then how to implement that on the service side because we don't have any global & startup files in our service.
I am using below code in my global file in webapplication:
var agentComponents = ElasticApmModule.CreateAgentComponents();
// subscribe to capture database spans to SQL server
// add transaction filter
Agent.AddFilter((Elastic.Apm.Api.ITransaction t) =>
I am still waiting for the above response.
@Sharma3007 your code snippet is fine, only thing to keep in mind if you go with the
Agent.Setup() way of initialization is that you'll also need to enable auto instrumentation for any component you need - I see you do that for
SqlClientDiagnosticSubscriber - so that should work, that'll capture DB calls to MS SQL Server through the
To you question:
so just wanted to know that do we need to configure.net agent configuration on the service side also?
Yes - you'll need to enable the agent in every process in order to get out APM data from a given process.
If yes then how to implement that on the service side because we don't have any global & startup files in our service.
You can use the exact same code-snippet you pasted - If I understand you correctly, then the DB call happens in the service, if so, then that's where you'd need the `Agent.Subscribe(new SqlClientDiagnosticSubscriber());`` - but if you have it on both side that's fine as well, it won't cause any trouble.
You can put the agent initializtion code basically anywhere - just make sure it runs only once - so typically it'd be in the
Main method or in any other part of the startup code.
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.