Skip to content

Commit ce5d94b

Browse files
committed
feat: add latency to HttpRequest and Fetch
1 parent dcb798c commit ce5d94b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/nodes/Web.Fetch.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type P = {
2121
type R = Promise<unknown>;
2222

2323
export const module: ModuleDefinition<P, R> = {
24-
version: '1.7.3',
24+
version: '1.8.0',
2525
moduleName: 'Web / Fetch',
2626
description: `
2727
Sends an HTTP request using natively available Fetch API.
@@ -94,6 +94,7 @@ export const module: ModuleDefinition<P, R> = {
9494
};
9595

9696
export const compute: ModuleCompute<P, R> = async (params, ctx) => {
97+
const startedAt = Date.now();
9798
const {
9899
method,
99100
url,
@@ -136,6 +137,7 @@ export const compute: ModuleCompute<P, R> = async (params, ctx) => {
136137
status: res.status,
137138
headers: resHeaders,
138139
body: resBody,
140+
latency: Date.now() - startedAt,
139141
};
140142
};
141143

src/nodes/Web.HttpRequest.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type P = {
2929
type R = Promise<unknown>;
3030

3131
export const module: ModuleDefinition<P, R> = {
32-
version: '2.6.3',
32+
version: '2.7.0',
3333
moduleName: 'Web / Http Request',
3434
description: `
3535
Sends an HTTP request using backend-powered HTTP client.
@@ -145,9 +145,11 @@ interface HttpResponseSpec {
145145
status: number;
146146
headers: Record<string, string[]>;
147147
body: any;
148+
latency: number;
148149
}
149150

150151
async function sendSingle(params: P, ctx: GraphEvalContext): Promise<HttpResponseSpec> {
152+
const startedAt = Date.now();
151153
const {
152154
method,
153155
url,
@@ -187,6 +189,7 @@ async function sendSingle(params: P, ctx: GraphEvalContext): Promise<HttpRespons
187189
status,
188190
headers: convertResponseHeaders(responseHeaders),
189191
body: await readResponse(res, responseType),
192+
latency: Date.now() - startedAt,
190193
};
191194
}
192195

0 commit comments

Comments
 (0)