@@ -24,9 +24,7 @@ describe("agent/AppServicesLoader", () => {
2424 afterEach ( ( ) => {
2525 process . env = originalEnv ;
2626 sandbox . restore ( ) ;
27- } ) ;
28-
29- it ( "constructor" , ( ) => {
27+ } ) ; it ( "constructor" , ( ) => {
3028 const env = {
3129 [ "APPLICATIONINSIGHTS_CONNECTION_STRING" ] : "InstrumentationKey=1aa11111-bbbb-1ccc-8ddd-eeeeffff3333" ,
3230 [ "HOME" ] : "c:" ,
@@ -37,23 +35,34 @@ describe("agent/AppServicesLoader", () => {
3735 assert . equal ( diagnosticLogger [ "_instrumentationKey" ] , "1aa11111-bbbb-1ccc-8ddd-eeeeffff3333" ) ;
3836
3937 const isWindows = process . platform === 'win32' ;
40- assert . ok ( diagnosticLogger instanceof DiagnosticLogger , "Wrong diagnosticLogger type" ) ;
41- assert . ok ( diagnosticLogger [ "_agentLogger" ] instanceof FileWriter , "Wrong diagnosticLogger agentLogger" ) ;
42- assert . equal ( diagnosticLogger [ "_agentLogger" ] [ "_filename" ] , "applicationinsights-extension.log" ) ;
38+
39+ // In Windows, the diagnostic logger should be EtwDiagnosticLogger
40+ // In non-Windows, it should be DiagnosticLogger with FileWriter
41+ if ( isWindows ) {
42+ // Import EtwDiagnosticLogger for Windows testing
43+ const { EtwDiagnosticLogger } = require ( "../../../src/agent/diagnostics/etwDiagnosticLogger" ) ;
44+ const { EtwWriter } = require ( "../../../src/agent/diagnostics/writers/etwWriter" ) ;
45+
46+ assert . ok ( diagnosticLogger instanceof EtwDiagnosticLogger , "Wrong diagnosticLogger type for Windows" ) ;
47+ assert . ok ( diagnosticLogger [ "_agentLogger" ] instanceof EtwWriter , "Wrong diagnosticLogger agentLogger for Windows" ) ;
48+ } else {
49+ assert . ok ( diagnosticLogger instanceof DiagnosticLogger , "Wrong diagnosticLogger type" ) ;
50+ assert . ok ( diagnosticLogger [ "_agentLogger" ] instanceof FileWriter , "Wrong diagnosticLogger agentLogger" ) ;
51+ assert . equal ( diagnosticLogger [ "_agentLogger" ] [ "_filename" ] , "applicationinsights-extension.log" ) ;
52+ assert . equal ( diagnosticLogger [ "_agentLogger" ] [ "_filepath" ] , "/var/log/applicationinsights/" ) ;
53+ }
4354
4455 let statusLogger : any = agent [ "_statusLogger" ] ;
4556 assert . equal ( statusLogger [ "_instrumentationKey" ] , "1aa11111-bbbb-1ccc-8ddd-eeeeffff3333" ) ;
4657 assert . ok ( statusLogger [ "_agentLogger" ] instanceof FileWriter , "Wrong statusLogger agentLogger" ) ;
4758 assert . equal ( statusLogger [ "_agentLogger" ] [ "_filename" ] , "status_nodejs.json" ) ;
4859
4960 if ( isWindows ) {
50- assert . equal ( diagnosticLogger [ "_agentLogger" ] [ "_filepath" ] , "c:\\LogFiles\\ApplicationInsights\\status" ) ;
5161 assert . equal ( statusLogger [ "_agentLogger" ] [ "_filepath" ] , "c:\\LogFiles\\ApplicationInsights\\status" ) ;
52- }
53- else {
54- assert . equal ( diagnosticLogger [ "_agentLogger" ] [ "_filepath" ] , "/var/log/applicationinsights/" ) ;
62+ } else {
5563 assert . equal ( statusLogger [ "_agentLogger" ] [ "_filepath" ] , "/var/log/applicationinsights/" ) ;
5664 }
65+
5766 // Loader is using correct diagnostics
5867 assert . equal ( agent [ "_diagnosticLogger" ] , diagnosticLogger , "Wrong diagnosticLogger" ) ;
5968 assert . equal ( agent [ "_statusLogger" ] , statusLogger , "Wrong statusLogger" ) ;
0 commit comments