http2: add diagnostics channel 'http2.server.stream.created' · nodejs/node@dec6c9a · GitHub
Skip to content

Commit dec6c9a

Browse files
RaisinTenaduh95
authored andcommitted
http2: add diagnostics channel 'http2.server.stream.created'
Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #58390 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 5cc97df commit dec6c9a

3 files changed

Lines changed: 81 additions & 0 deletions

File tree

doc/api/diagnostics_channel.md

Lines changed: 7 additions & 0 deletions

lib/internal/http2/core.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ const onClientStreamStartChannel = dc.channel('http2.client.stream.start');
195195
const onClientStreamErrorChannel = dc.channel('http2.client.stream.error');
196196
const onClientStreamFinishChannel = dc.channel('http2.client.stream.finish');
197197
const onClientStreamCloseChannel = dc.channel('http2.client.stream.close');
198+
const onServerStreamCreatedChannel = dc.channel('http2.server.stream.created');
198199

199200
let debug = require('internal/util/debuglog').debuglog('http2', (fn) => {
200201
debug = fn;
@@ -375,6 +376,12 @@ function onSessionHeaders(handle, id, cat, flags, headers, sensitiveHeaders) {
375376
if (type === NGHTTP2_SESSION_SERVER) {
376377
// eslint-disable-next-line no-use-before-define
377378
stream = new ServerHttp2Stream(session, handle, id, {}, obj);
379+
if (onServerStreamCreatedChannel.hasSubscribers) {
380+
onServerStreamCreatedChannel.publish({
381+
stream,
382+
headers: obj,
383+
});
384+
}
378385
if (endOfStream) {
379386
stream.push(null);
380387
}
@@ -2837,6 +2844,13 @@ class ServerHttp2Stream extends Http2Stream {
28372844
stream[kState].flags |= STREAM_FLAGS_HEAD_REQUEST;
28382845

28392846
process.nextTick(callback, null, stream, headers, 0);
2847+
2848+
if (onServerStreamCreatedChannel.hasSubscribers) {
2849+
onServerStreamCreatedChannel.publish({
2850+
stream,
2851+
headers,
2852+
});
2853+
}
28402854
}
28412855

28422856
// Initiate a response on this Http2Stream
Lines changed: 60 additions & 0 deletions

0 commit comments

Comments
 (0)