@vercel/build-utils 9.2.1 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +9 -5
- package/dist/trace/trace.d.ts +1 -3
- package/dist/trace/trace.js +9 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
@@ -24231,6 +24231,7 @@ var buildsSchema = {
|
|
24231
24231
|
|
24232
24232
|
// src/trace/trace.ts
|
24233
24233
|
var import_node_crypto = require("crypto");
|
24234
|
+
var NUM_OF_MICROSEC_IN_NANOSEC = BigInt("1000");
|
24234
24235
|
function mapUndefinedAttributes(attrs) {
|
24235
24236
|
return Object.fromEntries(
|
24236
24237
|
Object.entries(attrs ?? {}).filter(
|
@@ -24250,23 +24251,26 @@ var Span = class _Span {
|
|
24250
24251
|
this.attrs = mapUndefinedAttributes(attrs);
|
24251
24252
|
this.status = "started";
|
24252
24253
|
this.id = (0, import_node_crypto.randomUUID)();
|
24253
|
-
this._start = Date.now();
|
24254
24254
|
this._reporter = reporter;
|
24255
|
+
this.now = Date.now();
|
24256
|
+
this._start = process.hrtime.bigint();
|
24255
24257
|
}
|
24256
24258
|
stop() {
|
24257
24259
|
if (this.status === "stopped") {
|
24258
24260
|
throw new Error(`Cannot stop a span which is already stopped`);
|
24259
24261
|
}
|
24260
24262
|
this.status = "stopped";
|
24261
|
-
const
|
24263
|
+
const end = process.hrtime.bigint();
|
24264
|
+
const duration = Number((end - this._start) / NUM_OF_MICROSEC_IN_NANOSEC);
|
24265
|
+
const timestamp = Number(this._start / NUM_OF_MICROSEC_IN_NANOSEC);
|
24262
24266
|
const traceEvent = {
|
24263
24267
|
name: this.name,
|
24264
|
-
duration
|
24265
|
-
timestamp
|
24268
|
+
duration,
|
24269
|
+
timestamp,
|
24266
24270
|
id: this.id,
|
24267
24271
|
parentId: this.parentId,
|
24268
24272
|
tags: this.attrs,
|
24269
|
-
startTime: this.
|
24273
|
+
startTime: this.now
|
24270
24274
|
};
|
24271
24275
|
if (this._reporter) {
|
24272
24276
|
this._reporter.report(traceEvent);
|
package/dist/trace/trace.d.ts
CHANGED
@@ -9,9 +9,6 @@ export type TraceEvent = {
|
|
9
9
|
startTime: number;
|
10
10
|
};
|
11
11
|
export type Reporter = {
|
12
|
-
flushAll: (opts?: {
|
13
|
-
end: boolean;
|
14
|
-
}) => Promise<void> | void;
|
15
12
|
report: (event: TraceEvent) => void;
|
16
13
|
};
|
17
14
|
interface Attributes {
|
@@ -24,6 +21,7 @@ export declare class Span {
|
|
24
21
|
private attrs;
|
25
22
|
private status;
|
26
23
|
private _start;
|
24
|
+
private now;
|
27
25
|
private _reporter;
|
28
26
|
constructor({ name, parentId, attrs, reporter, }: {
|
29
27
|
name: string;
|
package/dist/trace/trace.js
CHANGED
@@ -22,6 +22,7 @@ __export(trace_exports, {
|
|
22
22
|
});
|
23
23
|
module.exports = __toCommonJS(trace_exports);
|
24
24
|
var import_node_crypto = require("node:crypto");
|
25
|
+
const NUM_OF_MICROSEC_IN_NANOSEC = BigInt("1000");
|
25
26
|
function mapUndefinedAttributes(attrs) {
|
26
27
|
return Object.fromEntries(
|
27
28
|
Object.entries(attrs ?? {}).filter(
|
@@ -41,23 +42,26 @@ class Span {
|
|
41
42
|
this.attrs = mapUndefinedAttributes(attrs);
|
42
43
|
this.status = "started";
|
43
44
|
this.id = (0, import_node_crypto.randomUUID)();
|
44
|
-
this._start = Date.now();
|
45
45
|
this._reporter = reporter;
|
46
|
+
this.now = Date.now();
|
47
|
+
this._start = process.hrtime.bigint();
|
46
48
|
}
|
47
49
|
stop() {
|
48
50
|
if (this.status === "stopped") {
|
49
51
|
throw new Error(`Cannot stop a span which is already stopped`);
|
50
52
|
}
|
51
53
|
this.status = "stopped";
|
52
|
-
const
|
54
|
+
const end = process.hrtime.bigint();
|
55
|
+
const duration = Number((end - this._start) / NUM_OF_MICROSEC_IN_NANOSEC);
|
56
|
+
const timestamp = Number(this._start / NUM_OF_MICROSEC_IN_NANOSEC);
|
53
57
|
const traceEvent = {
|
54
58
|
name: this.name,
|
55
|
-
duration
|
56
|
-
timestamp
|
59
|
+
duration,
|
60
|
+
timestamp,
|
57
61
|
id: this.id,
|
58
62
|
parentId: this.parentId,
|
59
63
|
tags: this.attrs,
|
60
|
-
startTime: this.
|
64
|
+
startTime: this.now
|
61
65
|
};
|
62
66
|
if (this._reporter) {
|
63
67
|
this._reporter.report(traceEvent);
|