()
| 65 | } |
| 66 | |
| 67 | function diagnostics_channel() { |
| 68 | const als = new AsyncLocalStorage(); |
| 69 | const times = []; |
| 70 | |
| 71 | const start = dc.channel('http.server.request.start'); |
| 72 | const finish = dc.channel('http.server.response.finish'); |
| 73 | |
| 74 | function onStart(req) { |
| 75 | als.enterWith({ |
| 76 | url: req.url, |
| 77 | start: process.hrtime.bigint(), |
| 78 | }); |
| 79 | } |
| 80 | |
| 81 | function onFinish(res) { |
| 82 | times.push({ |
| 83 | ...als.getStore(), |
| 84 | statusCode: res.statusCode, |
| 85 | end: process.hrtime.bigint(), |
| 86 | }); |
| 87 | } |
| 88 | |
| 89 | start.subscribe(onStart); |
| 90 | finish.subscribe(onFinish); |
| 91 | |
| 92 | return () => { |
| 93 | start.unsubscribe(onStart); |
| 94 | finish.unsubscribe(onFinish); |
| 95 | }; |
| 96 | } |
nothing calls this directly
no test coverage detected