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); } }
private DiagnosticScope(SqlDiagnosticListener diagnostics, int operation, Guid operationsId, string operationName, object context1, object context2) { _diagnostics = diagnostics; _operation = operation; _operationId = operationsId; _operationName = operationName; _context1 = context1; _context2 = context2; _exception = null; }
public DiagnosticTransactionScope(SqlDiagnosticListener diagnostics, int operation, Guid operationId, string operationName, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, string transactionName) { _diagnostics = diagnostics; _operation = operation; _operationId = operationId; _operationName = operationName; _isolationLevel = isolationLevel; _connection = connection; _transaction = transaction; _transactionName = transactionName; _exception = null; }
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); } }
public static DiagnosticTransactionScope CreateTransactionRollbackScope(SqlDiagnosticListener diagnostics, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, string transactionName, [CallerMemberName] string operationName = "") { Guid operationId = diagnostics.WriteTransactionRollbackBefore(isolationLevel, connection, transaction, transactionName, operationName); return(new DiagnosticTransactionScope(diagnostics, TransactionCommit, operationId, operationName, isolationLevel, connection, transaction, transactionName)); }
public static DiagnosticScope CreateCommandScope(SqlDiagnosticListener diagnostics, SqlCommand command, SqlTransaction transaction, [CallerMemberName] string operationName = "") { Guid operationId = diagnostics.WriteCommandBefore(command, transaction, operationName); return(new DiagnosticScope(diagnostics, CommandOperation, operationId, operationName, command, transaction)); }
public static DiagnosticTransactionScope CreateTransactionRollbackScope(this SqlDiagnosticListener @this, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, string transactionName, [CallerMemberName] string operationName = "") { return(DiagnosticTransactionScope.CreateTransactionRollbackScope(@this, isolationLevel, connection, transaction, transactionName, operationName)); }
public static DiagnosticScope CreateCommandScope(this SqlDiagnosticListener @this, SqlCommand command, SqlTransaction transaction, [CallerMemberName] string operationName = "") { return(DiagnosticScope.CreateCommandScope(@this, command, transaction, operationName)); }