public static Guid WriteCommandBefore(this SqlDiagnosticListener @this, SqlCommand sqlCommand, SqlTransaction transaction, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeExecuteCommand)) { Guid operationId = Guid.NewGuid(); @this.Write( SqlBeforeExecuteCommand, new { OperationId = operationId, Operation = operation, ConnectionId = sqlCommand.Connection?.ClientConnectionId, Command = sqlCommand, transaction?.InternalTransaction?.TransactionId, Timestamp = Stopwatch.GetTimestamp() }); return(operationId); } else { return(Guid.Empty); } }
public static Guid WriteTransactionRollbackBefore(this SqlDiagnosticListener @this, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, string transactionName = null, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeRollbackTransaction)) { Guid operationId = Guid.NewGuid(); @this.Write( SqlBeforeRollbackTransaction, new { OperationId = operationId, Operation = operation, IsolationLevel = isolationLevel, Connection = connection, transaction?.TransactionId, TransactionName = transactionName, Timestamp = Stopwatch.GetTimestamp() }); return(operationId); } else { return(Guid.Empty); } }
public static Guid WriteConnectionCloseBefore(this SqlDiagnosticListener @this, SqlConnection sqlConnection, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeCloseConnection)) { Guid operationId = Guid.NewGuid(); @this.Write( SqlBeforeCloseConnection, new { OperationId = operationId, Operation = operation, ConnectionId = sqlConnection.ClientConnectionId, Connection = sqlConnection, Statistics = sqlConnection.Statistics?.GetDictionary(), Timestamp = Stopwatch.GetTimestamp() }); return(operationId); } else { return(Guid.Empty); } }
public static void WriteTransactionCommitAfter(this SqlDiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlAfterCommitTransaction)) { @this.Write( SqlAfterCommitTransaction, new { OperationId = operationId, Operation = operation, IsolationLevel = isolationLevel, Connection = connection, transaction?.TransactionId, Timestamp = Stopwatch.GetTimestamp() }); } }
public static void WriteConnectionCloseAfter(this SqlDiagnosticListener @this, Guid operationId, Guid clientConnectionId, SqlConnection sqlConnection, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlAfterCloseConnection)) { @this.Write( SqlAfterCloseConnection, new { OperationId = operationId, Operation = operation, ConnectionId = clientConnectionId, Connection = sqlConnection, Statistics = sqlConnection.Statistics?.GetDictionary(), Timestamp = Stopwatch.GetTimestamp() }); } }
public static void WriteCommandError(this SqlDiagnosticListener @this, Guid operationId, SqlCommand sqlCommand, SqlTransaction transaction, Exception ex, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlErrorExecuteCommand)) { @this.Write( SqlErrorExecuteCommand, new { OperationId = operationId, Operation = operation, ConnectionId = sqlCommand.Connection?.ClientConnectionId, Command = sqlCommand, transaction?.InternalTransaction?.TransactionId, Exception = ex, Timestamp = Stopwatch.GetTimestamp() }); } }
public static void WriteConnectionOpenError(this SqlDiagnosticListener @this, Guid operationId, SqlConnection sqlConnection, Exception ex, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlErrorOpenConnection)) { @this.Write( SqlErrorOpenConnection, new { OperationId = operationId, Operation = operation, ConnectionId = sqlConnection.ClientConnectionId, Connection = sqlConnection, ClientVersion = ThisAssembly.InformationalVersion, Exception = ex, Timestamp = Stopwatch.GetTimestamp() }); } }
public static void WriteTransactionRollbackError(this SqlDiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, Exception ex, string transactionName = null, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlErrorRollbackTransaction)) { @this.Write( SqlErrorRollbackTransaction, new { OperationId = operationId, Operation = operation, IsolationLevel = isolationLevel, Connection = connection, transaction?.TransactionId, TransactionName = transactionName, Exception = ex, Timestamp = Stopwatch.GetTimestamp() }); } }
public static Guid WriteConnectionOpenBefore(this SqlDiagnosticListener @this, SqlConnection sqlConnection, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeOpenConnection)) { Guid operationId = Guid.NewGuid(); @this.Write( SqlBeforeOpenConnection, new { OperationId = operationId, Operation = operation, Connection = sqlConnection, ClientVersion = ThisAssembly.InformationalVersion, Timestamp = Stopwatch.GetTimestamp() }); return(operationId); } else { return(Guid.Empty); } }