SQL Bulk copy operation not captured by Apm Agent

We are using SQLBulkCopy.Write ToServerAsync method to write data to tables but these operations are not captured by APM agent.
Agent is subscribed to SqlClientDiagnosticSubscriber

Tried with adding package Elastic.Apm.EntitiyFrameworkcore but didn’t work

Hi, @vinaykoul4.

This will need a little investigation. The agent listens to events from SqlClient and reports based on those. It's possible that those events are not triggered by the SqlBulkCopy, and we need to listen to other ones.

Which library are you using - System.Data.SqlClient or Microsoft.Data.SqlClient and which version of .NET and the Agent are you running?

We are using Microsoft.Data.SqlClient

.Net Core - 6
Elastic.APM Package - 1.25.2
Agent Version - 1.25

We are using Microsoft.Data.SqlClient

.Net Core - 6
Elastic.APM Package - 1.25.2
Agent Version - 1.25

Any updates on this ?

Sorry for the delay @vinaykoul4.

I've taken a brief look with a repro app; indeed, calling WriteToServerAsync isn't captured with the current tracing. I've opened a new issue to track this. It's possible that the SqlBulkCopy methods are simply not instrumented. If they are, then we may need to enhance the agent to listen to some new events. That will need some investigation on our end.

A workaround, for now, would be to look at using our public API to manually instrument your own code around calls to the SqlBulkCopy methods.

Thanks @stevejgordon for the investigation.
Since there are lot of SQLBulkCopy operation calls in our application, hence it won't be suitable to manually instrument this piece. We will be looking forward for this fix to happen soon.

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