@@ -15,6 +15,7 @@ internal sealed class RequestActivityEventSource
15
15
private const int _beginTransferEventId = 5 ;
16
16
private const int _endTransferEventId = 6 ;
17
17
private const int _outerActivityWarningEventId = 7 ;
18
+ private const int _internalServerErrorEventId = 8 ;
18
19
19
20
public static RequestActivityEventSource Log { get ; } = new RequestActivityEventSource ( ) ;
20
21
@@ -143,7 +144,8 @@ private void Stop(int applicationId, Guid activityId, Guid userId, int statusCod
143
144
#region Outer Activity Warning
144
145
145
146
/// <summary>
146
- /// A warning regarding outer activities which were not allowed when opening a new server-side message activity.
147
+ /// A warning regarding outer activities which are not allowed when opening a new
148
+ /// server-side message activity.
147
149
/// </summary>
148
150
[ NonEvent ]
149
151
public void OuterActivityNotAllowed ( Guid activityId )
@@ -201,6 +203,58 @@ private void EndTransfer(Guid relatedActivityId, int applicationId, Guid activit
201
203
202
204
#endregion
203
205
206
+ #region Internal Server Error
207
+
208
+ /// <summary>
209
+ /// A internal server error occurred during request/response processing.
210
+ /// </summary>
211
+ [ NonEvent ]
212
+ public void InternalServerErrorOccurred ( Exception exception )
213
+ {
214
+ if ( IsEnabled ( ) )
215
+ {
216
+ AttachmentId attachmentId = AttachmentId . NewId ( ) ;
217
+ ExceptionAttachment attachment = AttachmentFactory . Create ( attachmentId ,
218
+ nameof ( exception ) , exception ) ;
219
+
220
+ AttachmentDispatcher . Instance . Dispatch ( attachment ) ;
221
+ InternalServerErrorOccurred ( Application . Id , ActivityStack . Id , attachmentId ) ;
222
+ }
223
+ }
224
+
225
+ [ Event ( _internalServerErrorEventId , Level = EventLevel . Error ,
226
+ Message = "Internal server error occurred." , Version = 1 ) ]
227
+ private void InternalServerErrorOccurred ( int applicationId , Guid activityId ,
228
+ string attachmentId )
229
+ {
230
+ InternalServerErrorOccurredCore ( _internalServerErrorEventId , applicationId , activityId ,
231
+ attachmentId ) ;
232
+ }
233
+
234
+ [ NonEvent ]
235
+ private unsafe void InternalServerErrorOccurredCore ( int eventId , int applicationId ,
236
+ Guid activityId , string attachmentId )
237
+ {
238
+ StringExtensions . SetToEmptyIfNull ( ref attachmentId ) ;
239
+
240
+ fixed ( char * attachmentIdBytes = attachmentId )
241
+ {
242
+ const short dataCount = 3 ;
243
+ EventData * data = stackalloc EventData [ dataCount ] ;
244
+
245
+ data [ 0 ] . DataPointer = ( IntPtr ) ( & applicationId ) ;
246
+ data [ 0 ] . Size = 4 ;
247
+ data [ 1 ] . DataPointer = ( IntPtr ) ( & activityId ) ;
248
+ data [ 1 ] . Size = 16 ;
249
+ data [ 2 ] . DataPointer = ( IntPtr ) attachmentIdBytes ;
250
+ data [ 2 ] . Size = ( ( attachmentId . Length + 1 ) * 2 ) ;
251
+
252
+ WriteEventCore ( eventId , dataCount , data ) ;
253
+ }
254
+ }
255
+
256
+ #endregion
257
+
204
258
#region Tasks and Opcodes
205
259
206
260
public static class Tasks
0 commit comments