11const logger = require ( './logger' ) . logger ;
22
3- const { NodeTracerProvider } = require ( '@opentelemetry/sdk-trace-node' ) ;
4- const { registerInstrumentations } = require ( '@opentelemetry/instrumentation' ) ;
5- const { HttpInstrumentation } = require ( '@opentelemetry/instrumentation-http' ) ;
6- const { ExpressInstrumentation } = require ( '@opentelemetry/instrumentation-express' ) ;
7-
8- const provider = new NodeTracerProvider ( ) ;
9- // const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
10- // const { ConsoleSpanExporter } = require('@opentelemetry/tracing');
11- // provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
12- provider . register ( ) ;
13-
14- let expressInstrumentation = new ExpressInstrumentation ( ) ;
15- expressInstrumentation . setTracerProvider ( provider ) ;
16-
17- registerInstrumentations ( {
18- instrumentations : [
19- // Express instrumentation expects HTTP layer to be instrumented
20- new HttpInstrumentation ( {
21- ignoreIncomingRequestHook : ( req ) => {
22- return req . connection . localPort === 6060 ; // ignore incoming requests to prometheus
23- } ,
24- ignoreOutgoingRequestHook : ( req ) => {
25- return ! [ // we care about performance of outgoing requests to those hosts only
26- 'www.webpagetest.org' ,
27- 'api.cloudinary.com'
28- ] . includes ( req . hostname ) ;
29- } ,
30- } ) ,
31- expressInstrumentation ,
32- ] ,
33- } ) ;
34-
353const express = require ( 'express' ) ;
364const app = express ( ) ;
375
@@ -55,7 +23,7 @@ const wpt = require('./routes/wpt');
5523wpt ( app ) ;
5624
5725// catch 404 and forward to error handler
58- app . all ( '*any ' , function ( req , res ) {
26+ app . all ( '*' , function ( req , res ) {
5927 res . status ( 404 ) . send ( 'what???' ) ;
6028} ) ;
6129
0 commit comments