@@ -38,7 +38,7 @@ internal static class SqlClientDiagnosticListenerExtensions
38
38
public const string SqlAfterRollbackTransaction = SqlClientPrefix + nameof ( WriteTransactionRollbackAfter ) ;
39
39
public const string SqlErrorRollbackTransaction = SqlClientPrefix + nameof ( WriteTransactionRollbackError ) ;
40
40
41
- public static Guid WriteCommandBefore ( this DiagnosticListener @this , SqlCommand sqlCommand , [ CallerMemberName ] string operation = "" )
41
+ public static Guid WriteCommandBefore ( this DiagnosticListener @this , SqlCommand sqlCommand , SqlTransaction transaction , [ CallerMemberName ] string operation = "" )
42
42
{
43
43
if ( @this . IsEnabled ( SqlBeforeExecuteCommand ) )
44
44
{
@@ -52,6 +52,7 @@ public static Guid WriteCommandBefore(this DiagnosticListener @this, SqlCommand
52
52
Operation = operation ,
53
53
ConnectionId = sqlCommand . Connection ? . ClientConnectionId ,
54
54
Command = sqlCommand ,
55
+ transaction ? . InternalTransaction ? . TransactionId ,
55
56
Timestamp = Stopwatch . GetTimestamp ( )
56
57
} ) ;
57
58
@@ -61,7 +62,7 @@ public static Guid WriteCommandBefore(this DiagnosticListener @this, SqlCommand
61
62
return Guid . Empty ;
62
63
}
63
64
64
- public static void WriteCommandAfter ( this DiagnosticListener @this , Guid operationId , SqlCommand sqlCommand , [ CallerMemberName ] string operation = "" )
65
+ public static void WriteCommandAfter ( this DiagnosticListener @this , Guid operationId , SqlCommand sqlCommand , SqlTransaction transaction , [ CallerMemberName ] string operation = "" )
65
66
{
66
67
if ( @this . IsEnabled ( SqlAfterExecuteCommand ) )
67
68
{
@@ -73,13 +74,14 @@ public static void WriteCommandAfter(this DiagnosticListener @this, Guid operati
73
74
Operation = operation ,
74
75
ConnectionId = sqlCommand . Connection ? . ClientConnectionId ,
75
76
Command = sqlCommand ,
77
+ transaction ? . InternalTransaction ? . TransactionId ,
76
78
Statistics = sqlCommand . Statistics ? . GetDictionary ( ) ,
77
79
Timestamp = Stopwatch . GetTimestamp ( )
78
80
} ) ;
79
81
}
80
82
}
81
83
82
- public static void WriteCommandError ( this DiagnosticListener @this , Guid operationId , SqlCommand sqlCommand , Exception ex , [ CallerMemberName ] string operation = "" )
84
+ public static void WriteCommandError ( this DiagnosticListener @this , Guid operationId , SqlCommand sqlCommand , SqlTransaction transaction , Exception ex , [ CallerMemberName ] string operation = "" )
83
85
{
84
86
if ( @this . IsEnabled ( SqlErrorExecuteCommand ) )
85
87
{
@@ -91,6 +93,7 @@ public static void WriteCommandError(this DiagnosticListener @this, Guid operati
91
93
Operation = operation ,
92
94
ConnectionId = sqlCommand . Connection ? . ClientConnectionId ,
93
95
Command = sqlCommand ,
96
+ transaction ? . InternalTransaction ? . TransactionId ,
94
97
Exception = ex ,
95
98
Timestamp = Stopwatch . GetTimestamp ( )
96
99
} ) ;
@@ -110,6 +113,7 @@ public static Guid WriteConnectionOpenBefore(this DiagnosticListener @this, SqlC
110
113
OperationId = operationId ,
111
114
Operation = operation ,
112
115
Connection = sqlConnection ,
116
+ ClientVersion = ThisAssembly . InformationalVersion ,
113
117
Timestamp = Stopwatch . GetTimestamp ( )
114
118
} ) ;
115
119
@@ -131,6 +135,7 @@ public static void WriteConnectionOpenAfter(this DiagnosticListener @this, Guid
131
135
Operation = operation ,
132
136
ConnectionId = sqlConnection . ClientConnectionId ,
133
137
Connection = sqlConnection ,
138
+ ClientVersion = ThisAssembly . InformationalVersion ,
134
139
Statistics = sqlConnection . Statistics ? . GetDictionary ( ) ,
135
140
Timestamp = Stopwatch . GetTimestamp ( )
136
141
} ) ;
@@ -149,6 +154,7 @@ public static void WriteConnectionOpenError(this DiagnosticListener @this, Guid
149
154
Operation = operation ,
150
155
ConnectionId = sqlConnection . ClientConnectionId ,
151
156
Connection = sqlConnection ,
157
+ ClientVersion = ThisAssembly . InformationalVersion ,
152
158
Exception = ex ,
153
159
Timestamp = Stopwatch . GetTimestamp ( )
154
160
} ) ;
@@ -216,7 +222,7 @@ public static void WriteConnectionCloseError(this DiagnosticListener @this, Guid
216
222
}
217
223
}
218
224
219
- public static Guid WriteTransactionCommitBefore ( this DiagnosticListener @this , IsolationLevel isolationLevel , SqlConnection connection , [ CallerMemberName ] string operation = "" )
225
+ public static Guid WriteTransactionCommitBefore ( this DiagnosticListener @this , IsolationLevel isolationLevel , SqlConnection connection , SqlInternalTransaction transaction , [ CallerMemberName ] string operation = "" )
220
226
{
221
227
if ( @this . IsEnabled ( SqlBeforeCommitTransaction ) )
222
228
{
@@ -230,6 +236,7 @@ public static Guid WriteTransactionCommitBefore(this DiagnosticListener @this, I
230
236
Operation = operation ,
231
237
IsolationLevel = isolationLevel ,
232
238
Connection = connection ,
239
+ transaction ? . TransactionId ,
233
240
Timestamp = Stopwatch . GetTimestamp ( )
234
241
} ) ;
235
242
@@ -239,7 +246,7 @@ public static Guid WriteTransactionCommitBefore(this DiagnosticListener @this, I
239
246
return Guid . Empty ;
240
247
}
241
248
242
- public static void WriteTransactionCommitAfter ( this DiagnosticListener @this , Guid operationId , IsolationLevel isolationLevel , SqlConnection connection , [ CallerMemberName ] string operation = "" )
249
+ public static void WriteTransactionCommitAfter ( this DiagnosticListener @this , Guid operationId , IsolationLevel isolationLevel , SqlConnection connection , SqlInternalTransaction transaction , [ CallerMemberName ] string operation = "" )
243
250
{
244
251
if ( @this . IsEnabled ( SqlAfterCommitTransaction ) )
245
252
{
@@ -251,12 +258,13 @@ public static void WriteTransactionCommitAfter(this DiagnosticListener @this, Gu
251
258
Operation = operation ,
252
259
IsolationLevel = isolationLevel ,
253
260
Connection = connection ,
261
+ transaction ? . TransactionId ,
254
262
Timestamp = Stopwatch . GetTimestamp ( )
255
263
} ) ;
256
264
}
257
265
}
258
266
259
- public static void WriteTransactionCommitError ( this DiagnosticListener @this , Guid operationId , IsolationLevel isolationLevel , SqlConnection connection , Exception ex , [ CallerMemberName ] string operation = "" )
267
+ public static void WriteTransactionCommitError ( this DiagnosticListener @this , Guid operationId , IsolationLevel isolationLevel , SqlConnection connection , SqlInternalTransaction transaction , Exception ex , [ CallerMemberName ] string operation = "" )
260
268
{
261
269
if ( @this . IsEnabled ( SqlErrorCommitTransaction ) )
262
270
{
@@ -268,13 +276,14 @@ public static void WriteTransactionCommitError(this DiagnosticListener @this, Gu
268
276
Operation = operation ,
269
277
IsolationLevel = isolationLevel ,
270
278
Connection = connection ,
279
+ transaction ? . TransactionId ,
271
280
Exception = ex ,
272
281
Timestamp = Stopwatch . GetTimestamp ( )
273
282
} ) ;
274
283
}
275
284
}
276
285
277
- public static Guid WriteTransactionRollbackBefore ( this DiagnosticListener @this , IsolationLevel isolationLevel , SqlConnection connection , string transactionName , [ CallerMemberName ] string operation = "" )
286
+ public static Guid WriteTransactionRollbackBefore ( this DiagnosticListener @this , IsolationLevel isolationLevel , SqlConnection connection , SqlInternalTransaction transaction , string transactionName = null , [ CallerMemberName ] string operation = "" )
278
287
{
279
288
if ( @this . IsEnabled ( SqlBeforeRollbackTransaction ) )
280
289
{
@@ -288,6 +297,7 @@ public static Guid WriteTransactionRollbackBefore(this DiagnosticListener @this,
288
297
Operation = operation ,
289
298
IsolationLevel = isolationLevel ,
290
299
Connection = connection ,
300
+ transaction ? . TransactionId ,
291
301
TransactionName = transactionName ,
292
302
Timestamp = Stopwatch . GetTimestamp ( )
293
303
} ) ;
@@ -298,7 +308,7 @@ public static Guid WriteTransactionRollbackBefore(this DiagnosticListener @this,
298
308
return Guid . Empty ;
299
309
}
300
310
301
- public static void WriteTransactionRollbackAfter ( this DiagnosticListener @this , Guid operationId , IsolationLevel isolationLevel , SqlConnection connection , string transactionName , [ CallerMemberName ] string operation = "" )
311
+ public static void WriteTransactionRollbackAfter ( this DiagnosticListener @this , Guid operationId , IsolationLevel isolationLevel , SqlConnection connection , SqlInternalTransaction transaction , string transactionName = null , [ CallerMemberName ] string operation = "" )
302
312
{
303
313
if ( @this . IsEnabled ( SqlAfterRollbackTransaction ) )
304
314
{
@@ -310,13 +320,14 @@ public static void WriteTransactionRollbackAfter(this DiagnosticListener @this,
310
320
Operation = operation ,
311
321
IsolationLevel = isolationLevel ,
312
322
Connection = connection ,
323
+ transaction ? . TransactionId ,
313
324
TransactionName = transactionName ,
314
325
Timestamp = Stopwatch . GetTimestamp ( )
315
326
} ) ;
316
327
}
317
328
}
318
329
319
- public static void WriteTransactionRollbackError ( this DiagnosticListener @this , Guid operationId , IsolationLevel isolationLevel , SqlConnection connection , string transactionName , Exception ex , [ CallerMemberName ] string operation = "" )
330
+ public static void WriteTransactionRollbackError ( this DiagnosticListener @this , Guid operationId , IsolationLevel isolationLevel , SqlConnection connection , SqlInternalTransaction transaction , Exception ex , string transactionName = null , [ CallerMemberName ] string operation = "" )
320
331
{
321
332
if ( @this . IsEnabled ( SqlErrorRollbackTransaction ) )
322
333
{
@@ -328,6 +339,7 @@ public static void WriteTransactionRollbackError(this DiagnosticListener @this,
328
339
Operation = operation ,
329
340
IsolationLevel = isolationLevel ,
330
341
Connection = connection ,
342
+ transaction ? . TransactionId ,
331
343
TransactionName = transactionName ,
332
344
Exception = ex ,
333
345
Timestamp = Stopwatch . GetTimestamp ( )
0 commit comments