@@ -69,6 +69,8 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
6969 string stateFunctionName = null ;
7070 string stateEventName = null ;
7171 string stateActivityId = null ;
72+ string diagnosticEventErrorCode = null ;
73+ bool isDiagnosticEvent = false ;
7274 if ( state is IEnumerable < KeyValuePair < string , object > > stateProps )
7375 {
7476 foreach ( var kvp in stateProps )
@@ -77,6 +79,14 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
7779 {
7880 stateSourceValue = kvp . Value ? . ToString ( ) ;
7981 }
82+ else if ( string . Equals ( kvp . Key , ScriptConstants . DiagnosticEventKey , StringComparison . OrdinalIgnoreCase ) )
83+ {
84+ isDiagnosticEvent = true ;
85+ }
86+ else if ( string . Equals ( kvp . Key , ScriptConstants . ErrorCodeKey , StringComparison . OrdinalIgnoreCase ) )
87+ {
88+ diagnosticEventErrorCode = kvp . Value ? . ToString ( ) ;
89+ }
8090 else if ( string . Equals ( kvp . Key , ScriptConstants . LogPropertyIsUserLogKey , StringComparison . OrdinalIgnoreCase ) )
8191 {
8292 if ( ( bool ) kvp . Value )
@@ -147,6 +157,8 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
147157 // otherwise the ETW event will fail to be persisted (silently)
148158 string summary = formattedMessage ?? string . Empty ;
149159 string eventName = ! string . IsNullOrEmpty ( eventId . Name ) ? eventId . Name : stateEventName ?? string . Empty ;
160+ eventName = isDiagnosticEvent ? $ "DiagnosticEvent-{ diagnosticEventErrorCode } " : eventName ;
161+
150162 string activityId = stateActivityId ?? scopeActivityId ?? string . Empty ;
151163 var options = _appServiceOptions ;
152164 string subscriptionId = options . SubscriptionId ?? string . Empty ;
0 commit comments