diff --git a/test/parallel/test-diagnostics-channel-http-server-start.js b/test/parallel/test-diagnostics-channel-http-server-start.js index 9a8136d4cc5839..ad2f6ba48872e2 100644 --- a/test/parallel/test-diagnostics-channel-http-server-start.js +++ b/test/parallel/test-diagnostics-channel-http-server-start.js @@ -6,21 +6,18 @@ const dc = require('diagnostics_channel'); const assert = require('assert'); const http = require('http'); -const incomingStartChannel = dc.channel('http.server.request.start'); -const outgoingFinishChannel = dc.channel('http.server.response.finish'); - const als = new AsyncLocalStorage(); let context; // Bind requests to an AsyncLocalStorage context -incomingStartChannel.subscribe(common.mustCall((message) => { +dc.subscribe('http.server.request.start', common.mustCall((message) => { als.enterWith(message); context = message; })); // When the request ends, verify the context has been maintained // and that the messages contain the expected data -outgoingFinishChannel.subscribe(common.mustCall((message) => { +dc.subscribe('http.server.response.finish', common.mustCall((message) => { const data = { request, response, diff --git a/test/parallel/test-diagnostics-channel-http.js b/test/parallel/test-diagnostics-channel-http.js index 4de08d9253c10a..c2e84444e2866e 100644 --- a/test/parallel/test-diagnostics-channel-http.js +++ b/test/parallel/test-diagnostics-channel-http.js @@ -5,26 +5,24 @@ const http = require('http'); const net = require('net'); const dc = require('diagnostics_channel'); -const onClientRequestStart = dc.channel('http.client.request.start'); -const onClientResponseFinish = dc.channel('http.client.response.finish'); -const onServerRequestStart = dc.channel('http.server.request.start'); -const onServerResponseFinish = dc.channel('http.server.response.finish'); - const isHTTPServer = (server) => server instanceof http.Server; const isIncomingMessage = (object) => object instanceof http.IncomingMessage; const isOutgoingMessage = (object) => object instanceof http.OutgoingMessage; const isNetSocket = (socket) => socket instanceof net.Socket; -onClientRequestStart.subscribe(common.mustCall(({ request }) => { +dc.subscribe('http.client.request.start', common.mustCall(({ request }) => { assert.strictEqual(isOutgoingMessage(request), true); })); -onClientResponseFinish.subscribe(common.mustCall(({ request, response }) => { +dc.subscribe('http.client.response.finish', common.mustCall(({ + request, + response +}) => { assert.strictEqual(isOutgoingMessage(request), true); assert.strictEqual(isIncomingMessage(response), true); })); -onServerRequestStart.subscribe(common.mustCall(({ +dc.subscribe('http.server.request.start', common.mustCall(({ request, response, socket, @@ -36,7 +34,7 @@ onServerRequestStart.subscribe(common.mustCall(({ assert.strictEqual(isHTTPServer(server), true); })); -onServerResponseFinish.subscribe(common.mustCall(({ +dc.subscribe('http.server.response.finish', common.mustCall(({ request, response, socket,