(...args)
| 40 | |
| 41 | const { emit } = http.Server.prototype; |
| 42 | function wrappedEmit(...args) { |
| 43 | const [name, req, res] = args; |
| 44 | if (name === 'request') { |
| 45 | als.enterWith({ |
| 46 | url: req.url, |
| 47 | start: process.hrtime.bigint(), |
| 48 | }); |
| 49 | |
| 50 | res.on('finish', () => { |
| 51 | times.push({ |
| 52 | ...als.getStore(), |
| 53 | statusCode: res.statusCode, |
| 54 | end: process.hrtime.bigint(), |
| 55 | }); |
| 56 | }); |
| 57 | } |
| 58 | return emit.apply(this, args); |
| 59 | } |
| 60 | http.Server.prototype.emit = wrappedEmit; |
| 61 | |
| 62 | return () => { |