@@ -9,6 +9,13 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics
9
9
internal class EtwEventGenerator : IEventGenerator
10
10
{
11
11
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
+ }
12
19
13
20
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 )
14
21
{
@@ -62,14 +69,14 @@ public void LogAzureMonitorDiagnosticLogEvent(LogLevel level, string resourceId,
62
69
case LogLevel . Trace :
63
70
case LogLevel . Debug :
64
71
case LogLevel . Information :
65
- AzureMonitorDiagnosticLogsEventSource . Instance . RaiseFunctionsDiagnosticEventInformational ( resourceId , operationName , category , regionName , "Informational" , properties ) ;
72
+ _azureMonitorEventSource . RaiseFunctionsDiagnosticEventInformational ( resourceId , operationName , category , regionName , "Informational" , properties ) ;
66
73
break ;
67
74
case LogLevel . Warning :
68
- AzureMonitorDiagnosticLogsEventSource . Instance . RaiseFunctionsDiagnosticEventWarning ( resourceId , operationName , category , regionName , "Warning" , properties ) ;
75
+ _azureMonitorEventSource . RaiseFunctionsDiagnosticEventWarning ( resourceId , operationName , category , regionName , "Warning" , properties ) ;
69
76
break ;
70
77
case LogLevel . Error :
71
78
case LogLevel . Critical :
72
- AzureMonitorDiagnosticLogsEventSource . Instance . RaiseFunctionsDiagnosticEventError ( resourceId , operationName , category , regionName , "Error" , properties ) ;
79
+ _azureMonitorEventSource . RaiseFunctionsDiagnosticEventError ( resourceId , operationName , category , regionName , "Error" , properties ) ;
73
80
break ;
74
81
}
75
82
}
0 commit comments