@@ -9,6 +9,13 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics
99 internal class EtwEventGenerator : IEventGenerator
1010 {
1111 private const string EventTimestamp = "MM/dd/yyyy hh:mm:ss.fff tt" ;
12+ private readonly AzureMonitorDiagnosticLogsEventSource _azureMonitorEventSource ;
13+
14+ public EtwEventGenerator ( )
15+ {
16+ // Make sure this instance is accessed, even in placeholder mode (where no logs may use it).
17+ _azureMonitorEventSource = AzureMonitorDiagnosticLogsEventSource . Instance ;
18+ }
1219
1320 public void LogFunctionTraceEvent ( LogLevel level , string subscriptionId , string appName , string functionName , string eventName , string source , string details , string summary , string exceptionType , string exceptionMessage , string functionInvocationId , string hostInstanceId , string activityId )
1421 {
@@ -62,14 +69,14 @@ public void LogAzureMonitorDiagnosticLogEvent(LogLevel level, string resourceId,
6269 case LogLevel . Trace :
6370 case LogLevel . Debug :
6471 case LogLevel . Information :
65- AzureMonitorDiagnosticLogsEventSource . Instance . RaiseFunctionsDiagnosticEventInformational ( resourceId , operationName , category , regionName , "Informational" , properties ) ;
72+ _azureMonitorEventSource . RaiseFunctionsDiagnosticEventInformational ( resourceId , operationName , category , regionName , "Informational" , properties ) ;
6673 break ;
6774 case LogLevel . Warning :
68- AzureMonitorDiagnosticLogsEventSource . Instance . RaiseFunctionsDiagnosticEventWarning ( resourceId , operationName , category , regionName , "Warning" , properties ) ;
75+ _azureMonitorEventSource . RaiseFunctionsDiagnosticEventWarning ( resourceId , operationName , category , regionName , "Warning" , properties ) ;
6976 break ;
7077 case LogLevel . Error :
7178 case LogLevel . Critical :
72- AzureMonitorDiagnosticLogsEventSource . Instance . RaiseFunctionsDiagnosticEventError ( resourceId , operationName , category , regionName , "Error" , properties ) ;
79+ _azureMonitorEventSource . RaiseFunctionsDiagnosticEventError ( resourceId , operationName , category , regionName , "Error" , properties ) ;
7380 break ;
7481 }
7582 }
0 commit comments