@@ -57,6 +57,8 @@ async function run() {
5757 // Stop the server
5858 withoutFirewallProc . kill ( ) ;
5959
60+ console . log ( "Starting server with OpenTelemetry..." ) ;
61+
6062 const withOpenTelemetryProc = spawn ( "node" , [ "app.js" ] , {
6163 env : {
6264 ...process . env ,
@@ -81,14 +83,39 @@ async function run() {
8183 withOpenTelemetryProc . unref ( ) ;
8284 withOpenTelemetryProc . kill ( ) ;
8385
86+ console . log ( "Starting server with Elastic APM..." ) ;
87+
88+ const withElasticAPMProc = spawn ( "node" , [ "app.js" ] , {
89+ env : {
90+ ...process . env ,
91+ PORT : 5004 ,
92+ NODE_OPTIONS : "--require elastic-apm-node/start" ,
93+ ELASTIC_APM_DISABLE_SEND : "true" ,
94+ } ,
95+ stdio : "inherit" ,
96+ } ) ;
97+
98+ // Wait 2 seconds for the server to start and settle
99+ await setTimeout ( 2000 ) ;
100+
101+ const resultWithElasticAPM = await exec (
102+ generateWrkCommandForUrl ( "http://localhost:5004/empty" )
103+ ) ;
104+
105+ // Stop the server
106+ withElasticAPMProc . unref ( ) ;
107+ withElasticAPMProc . kill ( ) ;
108+
84109 const withFirewall = parseFloat ( resultWithFirewall . stdout . trim ( ) ) ;
85110 const withoutFirewall = parseFloat ( resultWithoutFirewall . stdout . trim ( ) ) ;
86111 const withOpenTelemetry = parseFloat ( resultWithOpenTelemetry . stdout . trim ( ) ) ;
112+ const withElasticAPM = parseFloat ( resultWithElasticAPM . stdout . trim ( ) ) ;
87113
88114 console . log ( "--- Results ---" ) ;
89115 console . log ( `Without Zen: ${ withoutFirewall } Requests/sec` ) ;
90116 console . log ( `With Zen: ${ withFirewall } Requests/sec` ) ;
91117 console . log ( `With OpenTelemetry: ${ withOpenTelemetry } Requests/sec` ) ;
118+ console . log ( `With Elastic APM: ${ withElasticAPM } Requests/sec` ) ;
92119
93120 const increase = ( ( withoutFirewall - withFirewall ) / withoutFirewall ) * 100 ;
94121 console . log ( `Decrease with Zen for an empty route: ${ increase . toFixed ( 2 ) } %` ) ;
0 commit comments