private void OnCommandStop(Exception exception) { if (exception != null) { SqlRequestUtil.ProcessException(exception); } SqlRequestUtil.EndSubsegment(); }
private void OnEventException(object value) { var exc = ((CommandErrorEventData)value).Exception; if (exc is Exception exception) { SqlRequestUtil.ProcessException(exception); SqlRequestUtil.EndSubsegment(); } }
private void OnEventException(object value) { // This class serves for tracing Sql command from both System.Data.SqlClient and Microsoft.Data.SqlClient and using fetch property works // fot both of these two cases var command = AgentUtil.FetchPropertyUsingReflection(value, "Command"); var exc = AgentUtil.FetchPropertyUsingReflection(value, "Exception"); if (command is DbCommand dbcommand && exc is Exception exception) { if (CurrentDbCommands.TryRemove(dbcommand, out _)) { SqlRequestUtil.ProcessException(exception); SqlRequestUtil.EndSubsegment(); } } }