You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We don't currently capture any spans when using the SqlBulkCopy API from Microsoft.Data.SqlClient or System.Data.SqlClient. I haven't yet dug into the source code for these libraries to confirm if they emit any diagnostic events we should listen to. It's possible they do not. If the latter is true, we may be able to instrument with the profiler-based approach instead.
I attempted to reproduce this in a console app with both the NuGet-based and profiler-based agent set ups.
Code to use in reproductions:
varconnectionString="<SOMECONNECTIONSTRING>";DoSqlClientCall(connectionString);DoBulk(connectionString);Console.WriteLine("Done!");staticvoidDoBulk(stringconnectionString){usingvarsourceConnection=newSqlConnection(connectionString);sourceConnection.Open();usingvardestinationConnection=newSqlConnection(connectionString);destinationConnection.Open();varcommandSourceData=newSqlCommand("SELECT * FROM Emails;",sourceConnection);varreader=commandSourceData.ExecuteReader();usingvarbulkCopy=newSqlBulkCopy(destinationConnection);bulkCopy.DestinationTableName="EmailsCopy";try{vartransaction=Agent.Tracer.StartTransaction("bulkcopy","app");bulkCopy.WriteToServer(reader);transaction.End();// results in a transaction with no child spans.}catch(Exceptionex){Console.WriteLine(ex.Message);}finally{reader.Close();}}staticvoidDoSqlClientCall(stringconnectionString){usingvarconnection=newSqlConnection(connectionString);connection.Open();varcreate=newSqlCommand("CREATE TABLE Emails(Id INTEGER,Email TEXT)",connection);create.ExecuteNonQuery();varcreate2=newSqlCommand("CREATE TABLE EmailsCopy(Id INTEGER,Email TEXT)",connection);create2.ExecuteNonQuery();InsertEmail("test1@example.example",connection);InsertEmail("test2@example.example",connection);varcommand=newSqlCommand("SELECT Email FROM Emails",connection);varreader=command.ExecuteReader();try{while(reader.Read()){varread=reader["Email"];Console.WriteLine($"{read}");}}finally{reader.Close();}}staticvoidInsertEmail(stringemail,SqlConnectionconnection){usingvarcommand=connection.CreateCommand();command.CommandText="INSERT into Emails(id ,email) values(@id,@email)";command.Prepare();command.Parameters.AddWithValue("@id",0);command.Parameters.AddWithValue("@email",email);command.ExecuteNonQuery();}
NOTE: The Otel SDK also doesn't collect any spans when using SqlBulkCopy.
The text was updated successfully, but these errors were encountered:
We don't currently capture any spans when using the
SqlBulkCopy
API fromMicrosoft.Data.SqlClient
orSystem.Data.SqlClient
. I haven't yet dug into the source code for these libraries to confirm if they emit any diagnostic events we should listen to. It's possible they do not. If the latter is true, we may be able to instrument with the profiler-based approach instead.I attempted to reproduce this in a console app with both the NuGet-based and profiler-based agent set ups.
Code to use in reproductions:
NOTE: The Otel SDK also doesn't collect any spans when using
SqlBulkCopy
.The text was updated successfully, but these errors were encountered: