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

Commit b99d131

Browse files
RaisinTenaduh95
authored andcommitted
http2: add diagnostics channel 'http2.client.stream.created'
Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: #58246 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
1 parent cff62e3 commit b99d131

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

doc/api/diagnostics_channel.md

Lines changed: 9 additions & 0 deletions

lib/internal/http2/core.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ const { UV_EOF } = internalBinding('uv');
188188

189189
const { StreamPipe } = internalBinding('stream_pipe');
190190
const { _connectionListener: httpConnectionListener } = http;
191+
192+
const dc = require('diagnostics_channel');
193+
const onClientStreamCreatedChannel = dc.channel('http2.client.stream.created');
194+
191195
let debug = require('internal/util/debuglog').debuglog('http2', (fn) => {
192196
debug = fn;
193197
});
@@ -379,6 +383,12 @@ function onSessionHeaders(handle, id, cat, flags, headers, sensitiveHeaders) {
379383
} else {
380384
// eslint-disable-next-line no-use-before-define
381385
stream = new ClientHttp2Stream(session, handle, id, {});
386+
if (onClientStreamCreatedChannel.hasSubscribers) {
387+
onClientStreamCreatedChannel.publish({
388+
stream,
389+
headers: obj,
390+
});
391+
}
382392
if (endOfStream) {
383393
stream.push(null);
384394
}
@@ -1865,6 +1875,14 @@ class ClientHttp2Session extends Http2Session {
18651875
} else {
18661876
onConnect();
18671877
}
1878+
1879+
if (onClientStreamCreatedChannel.hasSubscribers) {
1880+
onClientStreamCreatedChannel.publish({
1881+
stream,
1882+
headers: headersParam,
1883+
});
1884+
}
1885+
18681886
return stream;
18691887
}
18701888
}
Lines changed: 60 additions & 0 deletions

0 commit comments

Comments
 (0)