@sailfish-ai/sf-veritas 0.2.6 → 0.2.7
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/dist/funcSpanTransformer-BLhIRZqX.js +765 -0
- package/dist/funcSpanTransformer-BpWuHXKT.cjs +1 -0
- package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
- package/dist/plugins/funcspanEsbuildPlugin.mjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.mjs +1 -1
- package/dist/plugins/funcspanTscPlugin.cjs +1 -1
- package/dist/plugins/funcspanTscPlugin.mjs +1 -1
- package/dist/plugins/funcspanVitePlugin.cjs +1 -1
- package/dist/plugins/funcspanVitePlugin.mjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.mjs +1 -1
- package/dist/sf-veritas.cjs +15 -15
- package/dist/sf-veritas.mjs +367 -324
- package/dist/types/funcSpanConfig.d.ts +8 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/unifiedInterceptor.d.ts +4 -0
- package/dist/worker-pool-capture.cjs +1 -1
- package/dist/worker-pool-capture.mjs +1 -1
- package/dist/{workerPoolSpanCapture-BOnYC4s3.js → workerPoolSpanCapture-D0-0Z0Jw.js} +169 -156
- package/dist/workerPoolSpanCapture-DEwlTq0a.cjs +86 -0
- package/package.json +1 -1
- package/dist/funcSpanTransformer-TjdooSrw.cjs +0 -1
- package/dist/funcSpanTransformer-sqmZLAcs.js +0 -750
- package/dist/workerPoolSpanCapture-CNEouInA.cjs +0 -83
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (r, e, n) =>
|
|
4
|
-
import { AsyncLocalStorage as
|
|
5
|
-
import { appendFileSync as
|
|
6
|
-
import { threadId as
|
|
1
|
+
var te = Object.defineProperty;
|
|
2
|
+
var re = (r, e, n) => e in r ? te(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var c = (r, e, n) => re(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { AsyncLocalStorage as V, AsyncResource as ne } from "async_hooks";
|
|
5
|
+
import { appendFileSync as oe } from "fs";
|
|
6
|
+
import { threadId as w } from "worker_threads";
|
|
7
7
|
const l = [];
|
|
8
8
|
for (let r = 0; r < 256; ++r) l.push((r + 256).toString(16).slice(1));
|
|
9
|
-
let
|
|
10
|
-
const se = new Uint8Array(16),
|
|
9
|
+
let U;
|
|
10
|
+
const se = new Uint8Array(16), z = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
|
|
11
11
|
function C(r, e, n) {
|
|
12
|
-
if (
|
|
12
|
+
if (z.randomUUID && !r) return z.randomUUID();
|
|
13
13
|
const a = (r = r || {}).random ?? r.rng?.() ?? (function() {
|
|
14
|
-
if (!
|
|
14
|
+
if (!U) {
|
|
15
15
|
if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
16
|
-
|
|
16
|
+
U = crypto.getRandomValues.bind(crypto);
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return U(se);
|
|
19
19
|
})();
|
|
20
20
|
if (a.length < 16) throw new Error("Random bytes length must be >= 16");
|
|
21
|
-
return a[6] = 15 & a[6] | 64, a[8] = 63 & a[8] | 128, (function(
|
|
22
|
-
return (l[
|
|
21
|
+
return a[6] = 15 & a[6] | 64, a[8] = 63 & a[8] | 128, (function(s, i = 0) {
|
|
22
|
+
return (l[s[i + 0]] + l[s[i + 1]] + l[s[i + 2]] + l[s[i + 3]] + "-" + l[s[i + 4]] + l[s[i + 5]] + "-" + l[s[i + 6]] + l[s[i + 7]] + "-" + l[s[i + 8]] + l[s[i + 9]] + "-" + l[s[i + 10]] + l[s[i + 11]] + l[s[i + 12]] + l[s[i + 13]] + l[s[i + 14]] + l[s[i + 15]]).toLowerCase();
|
|
23
23
|
})(a);
|
|
24
24
|
}
|
|
25
|
-
class
|
|
25
|
+
class ae {
|
|
26
26
|
constructor(e) {
|
|
27
27
|
c(this, "apiKey");
|
|
28
28
|
c(this, "apiGraphqlEndpoint");
|
|
@@ -56,16 +56,16 @@ class oe {
|
|
|
56
56
|
this._serviceIdentificationReceived = e;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
const
|
|
59
|
+
const Y = Symbol.for("sailfish.sf_config");
|
|
60
60
|
function A() {
|
|
61
|
-
return globalThis[
|
|
61
|
+
return globalThis[Y];
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function Se(r) {
|
|
64
64
|
const e = A();
|
|
65
65
|
if (e) return { config: e };
|
|
66
|
-
const n = new
|
|
66
|
+
const n = new ae(r);
|
|
67
67
|
return (function(a) {
|
|
68
|
-
globalThis[
|
|
68
|
+
globalThis[Y] = a;
|
|
69
69
|
})(n), n.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", n), { config: n };
|
|
70
70
|
}
|
|
71
71
|
function f() {
|
|
@@ -73,7 +73,7 @@ function f() {
|
|
|
73
73
|
if (!r) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
|
|
74
74
|
return r;
|
|
75
75
|
}
|
|
76
|
-
const
|
|
76
|
+
const H = Symbol.for("sf.ctx.storeAls"), h = globalThis, k = h[H] ?? (h[H] = new V()), ie = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], J = Symbol.for("sf.ctx.als"), E = h[J] ?? (h[J] = new V()), j = Symbol.for("sf.ctx.sessionRegistry"), $ = h[j] ?? (h[j] = /* @__PURE__ */ new Map()), F = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(ie), supportedDomains: /* @__PURE__ */ new Set() }, _ = class _ {
|
|
77
77
|
constructor() {
|
|
78
78
|
}
|
|
79
79
|
current() {
|
|
@@ -86,26 +86,26 @@ const z = Symbol.for("sf.ctx.storeAls"), h = globalThis, k = h[z] ?? (h[z] = new
|
|
|
86
86
|
return k.enterWith(n), n;
|
|
87
87
|
}
|
|
88
88
|
runWith(e, n) {
|
|
89
|
-
const a = this.current() ?? /* @__PURE__ */ new Map(),
|
|
90
|
-
for (const [i, t] of Object.entries(e))
|
|
91
|
-
return k.run(
|
|
89
|
+
const a = this.current() ?? /* @__PURE__ */ new Map(), s = new Map(a);
|
|
90
|
+
for (const [i, t] of Object.entries(e)) s.set(i, t);
|
|
91
|
+
return k.run(s, n);
|
|
92
92
|
}
|
|
93
93
|
static getInstance() {
|
|
94
94
|
return h[_.GLOBAL_MANAGER_SYMBOL] || (h[_.GLOBAL_MANAGER_SYMBOL] = new _()), h[_.GLOBAL_MANAGER_SYMBOL];
|
|
95
95
|
}
|
|
96
96
|
getCurrentContext() {
|
|
97
|
-
return E.getStore() ||
|
|
97
|
+
return E.getStore() || F;
|
|
98
98
|
}
|
|
99
99
|
setCurrentContext(e) {
|
|
100
|
-
const n = E.getStore() ||
|
|
100
|
+
const n = E.getStore() || F;
|
|
101
101
|
E.enterWith({ ...n, ...e });
|
|
102
102
|
}
|
|
103
103
|
ensureSession(e) {
|
|
104
104
|
let n = $.get(e);
|
|
105
|
-
return n || (n = { ...
|
|
105
|
+
return n || (n = { ...F }, $.set(e, n)), n;
|
|
106
106
|
}
|
|
107
107
|
getContextFor(e) {
|
|
108
|
-
return $.get(e) ??
|
|
108
|
+
return $.get(e) ?? F;
|
|
109
109
|
}
|
|
110
110
|
updateContextFor(e, n) {
|
|
111
111
|
const a = this.ensureSession(e);
|
|
@@ -178,16 +178,16 @@ const z = Symbol.for("sf.ctx.storeAls"), h = globalThis, k = h[z] ?? (h[z] = new
|
|
|
178
178
|
};
|
|
179
179
|
c(_, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
|
|
180
180
|
let I = _;
|
|
181
|
-
function
|
|
181
|
+
function he(r) {
|
|
182
182
|
const e = { ...I.getInstance().getCurrentContext() };
|
|
183
183
|
E.run(e, () => {
|
|
184
184
|
r();
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function ye() {
|
|
188
188
|
return I.getInstance().getCurrentFunctionSpanId();
|
|
189
189
|
}
|
|
190
|
-
class
|
|
190
|
+
class ce {
|
|
191
191
|
constructor() {
|
|
192
192
|
c(this, "apiKey");
|
|
193
193
|
c(this, "endpoint");
|
|
@@ -217,41 +217,41 @@ class ie {
|
|
|
217
217
|
this.serviceUUID = e;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
const
|
|
221
|
-
let
|
|
222
|
-
async function
|
|
220
|
+
const ue = fetch;
|
|
221
|
+
let D = !1;
|
|
222
|
+
async function q(r, e, n, a) {
|
|
223
223
|
try {
|
|
224
|
-
const
|
|
224
|
+
const s = f();
|
|
225
225
|
let i;
|
|
226
226
|
try {
|
|
227
227
|
i = JSON.stringify({ query: n, variables: a, operationName: e });
|
|
228
228
|
} catch {
|
|
229
229
|
i = JSON.stringify({ query: n, operationName: e });
|
|
230
230
|
}
|
|
231
|
-
|
|
232
|
-
if (
|
|
233
|
-
const
|
|
234
|
-
|
|
231
|
+
D = !0, ue(r, { method: "POST", headers: { "Content-Type": "application/json" }, body: i }).then(async (t) => {
|
|
232
|
+
if (D = !1, !t.ok) return void (s.sfDebug && console.error(`GraphQL request failed with status ${t.status} for ${e}`));
|
|
233
|
+
const o = await t.json();
|
|
234
|
+
o.errors?.length ? (function(u, m, p) {
|
|
235
235
|
const g = u && typeof u == "object" && !Array.isArray(u) ? Object.keys(u)[0] : void 0;
|
|
236
236
|
console.error(g === "identifyServiceDetails" ? `IdentifyServiceDetails NOT sent successfully for service: UUID=${p.serviceUUID}` : `GraphQL request failed with errors: ${JSON.stringify(m)} for operation key ${g}`);
|
|
237
|
-
})(
|
|
237
|
+
})(o.data, o.errors, s) : s.sfDebug && (function(u, m, p) {
|
|
238
238
|
const g = u && typeof u == "object" && !Array.isArray(u) ? Object.keys(u)[0] : void 0, d = u[g] || !1;
|
|
239
239
|
g === "identifyServiceDetails" && (p.setServiceIdentificationReceived(d), f().sfDebug && console.log(`IdentifyServiceDetails sent successfully for service: UUID=${p.serviceUUID}; serviceIdentificationReceived=${g === "identifyServiceDetails" ? d : "N/A"}`));
|
|
240
|
-
})(
|
|
240
|
+
})(o.data, 0, s);
|
|
241
241
|
}).catch((t) => {
|
|
242
|
-
|
|
242
|
+
D = !1, s.sfDebug && (console.error(`[RequestUtils] Fetch error for ${e} to ${r}:`, t), t.cause && console.error("[RequestUtils] Error cause:", t.cause));
|
|
243
243
|
});
|
|
244
|
-
} catch (
|
|
245
|
-
|
|
244
|
+
} catch (s) {
|
|
245
|
+
D = !1, f().sfDebug && console.error("Error sending data to GraphQL server:", s);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function Ne() {
|
|
249
249
|
return { capture_arguments: b(process.env.SF_FUNCSPAN_CAPTURE_ARGUMENTS, !0), capture_return_value: b(process.env.SF_FUNCSPAN_CAPTURE_RETURN_VALUE, !0), arg_limit_mb: parseInt(process.env.SF_FUNCSPAN_ARG_LIMIT_MB || "1", 10), return_limit_mb: parseInt(process.env.SF_FUNCSPAN_RETURN_LIMIT_MB || "1", 10), autocapture_all_child_functions: b(process.env.SF_FUNCSPAN_AUTOCAPTURE_ALL_CHILD_FUNCTIONS, !1), sample_rate: parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE || "1.0"), enable_sampling: b(process.env.SF_FUNCSPAN_ENABLE_SAMPLING, !1), capture_sf_veritas: b(process.env.SF_FUNCSPAN_CAPTURE_SF_VERITAS, !1), parse_json_strings: b(process.env.SF_FUNCSPAN_PARSE_JSON_STRINGS, !1) };
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function _e() {
|
|
252
252
|
return { capture_arguments: !1, capture_return_value: !1, arg_limit_mb: 1, return_limit_mb: 1, autocapture_all_child_functions: !1, sample_rate: 0, enable_sampling: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function Ie(r) {
|
|
255
255
|
try {
|
|
256
256
|
const e = r.split("-");
|
|
257
257
|
return e.length !== 9 ? (console.error(`[FuncSpan] Invalid header format: expected 9 parts, got ${e.length}`), null) : { capture_arguments: e[0] === "1", capture_return_value: e[1] === "1", arg_limit_mb: parseInt(e[2], 10), return_limit_mb: parseInt(e[3], 10), autocapture_all_child_functions: e[4] === "1", sample_rate: parseFloat(e[5]), enable_sampling: e[6] === "1", capture_sf_veritas: e[7] === "1", parse_json_strings: e[8] === "1" };
|
|
@@ -264,22 +264,34 @@ function b(r, e) {
|
|
|
264
264
|
const n = r.toLowerCase();
|
|
265
265
|
return n === "true" || n === "1" || n === "yes";
|
|
266
266
|
}
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
function ve() {
|
|
272
|
-
return M.getStore();
|
|
267
|
+
const x = new V();
|
|
268
|
+
let L = !1;
|
|
269
|
+
function ve(r) {
|
|
270
|
+
x.enterWith(r);
|
|
273
271
|
}
|
|
274
272
|
function be() {
|
|
275
|
-
|
|
273
|
+
if (L) return x.getStore();
|
|
274
|
+
try {
|
|
275
|
+
L = !0;
|
|
276
|
+
const r = x.getStore(), e = new Error().stack?.split(`
|
|
277
|
+
`).slice(1, 4).join(`
|
|
278
|
+
`);
|
|
279
|
+
return console.log(`[getFuncspanOverride] Called from:
|
|
280
|
+
${e}`), console.log("[getFuncspanOverride] Returned value:", r), r;
|
|
281
|
+
} catch (r) {
|
|
282
|
+
return void console.error("[getFuncspanOverride] ❌ Error:", r);
|
|
283
|
+
} finally {
|
|
284
|
+
L = !1;
|
|
285
|
+
}
|
|
276
286
|
}
|
|
277
|
-
function Ce(
|
|
287
|
+
function Ce() {
|
|
288
|
+
}
|
|
289
|
+
function Te(...r) {
|
|
278
290
|
const e = {};
|
|
279
291
|
for (const n of r) for (const a in n) n[a] !== void 0 && (e[a] = n[a]);
|
|
280
292
|
return e;
|
|
281
293
|
}
|
|
282
|
-
function
|
|
294
|
+
function X(r, e) {
|
|
283
295
|
try {
|
|
284
296
|
const n = JSON.stringify(r).length / 1048576;
|
|
285
297
|
return n <= e ? r : { _truncated: !0, _originalSizeMB: n.toFixed(2), _limitMB: e, _preview: JSON.stringify(r).substring(0, 500) + "..." };
|
|
@@ -291,17 +303,17 @@ function N(r, e) {
|
|
|
291
303
|
const n = process.env[r];
|
|
292
304
|
return n === void 0 ? e : n === "true" || n === "1";
|
|
293
305
|
}
|
|
294
|
-
function
|
|
306
|
+
function Q(r, e) {
|
|
295
307
|
const n = process.env[r];
|
|
296
308
|
if (n === void 0) return e;
|
|
297
309
|
const a = parseFloat(n);
|
|
298
310
|
return isNaN(a) ? e : a;
|
|
299
311
|
}
|
|
300
|
-
function
|
|
301
|
-
return { enabled: N("SF_WORKER_POOL_ENABLED", !0), trackFs: N("SF_WORKER_POOL_TRACK_FS", !1), trackDns: N("SF_WORKER_POOL_TRACK_DNS", !0), trackCrypto: N("SF_WORKER_POOL_TRACK_CRYPTO", !1), trackZlib: N("SF_WORKER_POOL_TRACK_ZLIB", !1), captureArguments: N("SF_WORKER_POOL_CAPTURE_ARGUMENTS", !0), captureReturnValue: N("SF_WORKER_POOL_CAPTURE_RETURN_VALUE", !0), argLimitMb:
|
|
312
|
+
function K() {
|
|
313
|
+
return { enabled: N("SF_WORKER_POOL_ENABLED", !0), trackFs: N("SF_WORKER_POOL_TRACK_FS", !1), trackDns: N("SF_WORKER_POOL_TRACK_DNS", !0), trackCrypto: N("SF_WORKER_POOL_TRACK_CRYPTO", !1), trackZlib: N("SF_WORKER_POOL_TRACK_ZLIB", !1), captureArguments: N("SF_WORKER_POOL_CAPTURE_ARGUMENTS", !0), captureReturnValue: N("SF_WORKER_POOL_CAPTURE_RETURN_VALUE", !0), argLimitMb: Q("SF_WORKER_POOL_ARG_LIMIT_MB", 1), returnLimitMb: Q("SF_WORKER_POOL_RETURN_LIMIT_MB", 1) };
|
|
302
314
|
}
|
|
303
|
-
function
|
|
304
|
-
const e =
|
|
315
|
+
function $e(r) {
|
|
316
|
+
const e = K();
|
|
305
317
|
if (!e.enabled) return !1;
|
|
306
318
|
switch (r) {
|
|
307
319
|
case "fs":
|
|
@@ -316,18 +328,18 @@ function Te(r) {
|
|
|
316
328
|
return !1;
|
|
317
329
|
}
|
|
318
330
|
}
|
|
319
|
-
function
|
|
320
|
-
let
|
|
331
|
+
function Z(r, e, n, a) {
|
|
332
|
+
let s;
|
|
321
333
|
try {
|
|
322
334
|
switch (r) {
|
|
323
335
|
case "fs":
|
|
324
|
-
|
|
325
|
-
const
|
|
336
|
+
s = (function(i, t) {
|
|
337
|
+
const o = {};
|
|
326
338
|
switch (i) {
|
|
327
339
|
case "readFile":
|
|
328
340
|
case "writeFile":
|
|
329
341
|
case "appendFile":
|
|
330
|
-
|
|
342
|
+
o.path = String(t[0] || ""), t[1] && typeof t[1] == "object" ? (o.encoding = t[1].encoding || null, o.flag = t[1].flag || null) : typeof t[1] == "string" && (o.encoding = t[1]), i !== "writeFile" && i !== "appendFile" || (Buffer.isBuffer(t[1]) ? (o.dataType = "Buffer", o.dataSize = t[1].length) : typeof t[1] == "string" && (o.dataType = "string", o.dataSize = t[1].length));
|
|
331
343
|
break;
|
|
332
344
|
case "readdir":
|
|
333
345
|
case "stat":
|
|
@@ -337,34 +349,34 @@ function X(r, e, n, a) {
|
|
|
337
349
|
case "mkdir":
|
|
338
350
|
case "rmdir":
|
|
339
351
|
case "unlink":
|
|
340
|
-
|
|
352
|
+
o.path = String(t[0] || ""), t[1] && typeof t[1] == "object" && (o.options = { ...t[1] }, delete o.options.callback);
|
|
341
353
|
break;
|
|
342
354
|
case "rename":
|
|
343
|
-
|
|
355
|
+
o.oldPath = String(t[0] || ""), o.newPath = String(t[1] || "");
|
|
344
356
|
break;
|
|
345
357
|
case "open":
|
|
346
|
-
|
|
358
|
+
o.path = String(t[0] || ""), o.flags = t[1], o.mode = t[2];
|
|
347
359
|
break;
|
|
348
360
|
case "close":
|
|
349
361
|
case "fstat":
|
|
350
|
-
|
|
362
|
+
o.fd = t[0];
|
|
351
363
|
break;
|
|
352
364
|
case "read":
|
|
353
365
|
case "write":
|
|
354
|
-
|
|
366
|
+
o.fd = t[0], Buffer.isBuffer(t[1]) && (o.bufferSize = t[1].length), o.offset = t[2], o.length = t[3], o.position = t[4];
|
|
355
367
|
break;
|
|
356
368
|
default:
|
|
357
|
-
|
|
369
|
+
o.argsCount = t.length - 1;
|
|
358
370
|
}
|
|
359
|
-
return
|
|
371
|
+
return o;
|
|
360
372
|
})(e, n);
|
|
361
373
|
break;
|
|
362
374
|
case "dns":
|
|
363
|
-
|
|
364
|
-
const
|
|
375
|
+
s = (function(i, t) {
|
|
376
|
+
const o = {};
|
|
365
377
|
switch (i) {
|
|
366
378
|
case "lookup":
|
|
367
|
-
|
|
379
|
+
o.hostname = String(t[0] || ""), typeof t[1] == "object" ? (o.family = t[1].family, o.all = t[1].all) : typeof t[1] == "number" && (o.family = t[1]);
|
|
368
380
|
break;
|
|
369
381
|
case "resolve":
|
|
370
382
|
case "resolve4":
|
|
@@ -373,59 +385,59 @@ function X(r, e, n, a) {
|
|
|
373
385
|
case "resolveMx":
|
|
374
386
|
case "resolveNs":
|
|
375
387
|
case "resolveTxt":
|
|
376
|
-
|
|
388
|
+
o.hostname = String(t[0] || "");
|
|
377
389
|
break;
|
|
378
390
|
case "reverse":
|
|
379
|
-
|
|
391
|
+
o.ip = String(t[0] || "");
|
|
380
392
|
break;
|
|
381
393
|
default:
|
|
382
|
-
|
|
394
|
+
o.argsCount = t.length - 1;
|
|
383
395
|
}
|
|
384
|
-
return
|
|
396
|
+
return o;
|
|
385
397
|
})(e, n);
|
|
386
398
|
break;
|
|
387
399
|
case "crypto":
|
|
388
|
-
|
|
389
|
-
const
|
|
400
|
+
s = (function(i, t) {
|
|
401
|
+
const o = {};
|
|
390
402
|
switch (i) {
|
|
391
403
|
case "pbkdf2":
|
|
392
|
-
|
|
404
|
+
o.passwordType = typeof t[0], o.saltType = typeof t[1], o.iterations = t[2], o.keylen = t[3], o.digest = t[4];
|
|
393
405
|
break;
|
|
394
406
|
case "scrypt":
|
|
395
|
-
|
|
407
|
+
o.passwordType = typeof t[0], o.saltType = typeof t[1], o.keylen = t[2], typeof t[3] == "object" && (o.N = t[3].N, o.r = t[3].r, o.p = t[3].p);
|
|
396
408
|
break;
|
|
397
409
|
case "randomBytes":
|
|
398
|
-
|
|
410
|
+
o.size = t[0];
|
|
399
411
|
break;
|
|
400
412
|
case "generateKeyPair":
|
|
401
|
-
|
|
413
|
+
o.type = t[0], typeof t[1] == "object" && (o.modulusLength = t[1].modulusLength, o.namedCurve = t[1].namedCurve);
|
|
402
414
|
break;
|
|
403
415
|
default:
|
|
404
|
-
|
|
416
|
+
o.argsCount = t.length - 1;
|
|
405
417
|
}
|
|
406
|
-
return
|
|
418
|
+
return o;
|
|
407
419
|
})(e, n);
|
|
408
420
|
break;
|
|
409
421
|
case "zlib":
|
|
410
|
-
|
|
411
|
-
const
|
|
412
|
-
return Buffer.isBuffer(t[0]) ? (
|
|
422
|
+
s = (function(i, t) {
|
|
423
|
+
const o = {};
|
|
424
|
+
return Buffer.isBuffer(t[0]) ? (o.inputType = "Buffer", o.inputSize = t[0].length) : typeof t[0] == "string" ? (o.inputType = "string", o.inputSize = t[0].length) : o.inputType = typeof t[0], t[1] && typeof t[1] == "object" && typeof t[1] != "function" && (o.options = { ...t[1] }), o;
|
|
413
425
|
})(0, n);
|
|
414
426
|
break;
|
|
415
427
|
default:
|
|
416
428
|
return null;
|
|
417
429
|
}
|
|
418
|
-
return a > 0 ?
|
|
430
|
+
return a > 0 ? X(s, a) : s;
|
|
419
431
|
} catch {
|
|
420
432
|
return { error: "Failed to capture arguments", argsCount: n.length - 1 };
|
|
421
433
|
}
|
|
422
434
|
}
|
|
423
|
-
function
|
|
424
|
-
let
|
|
435
|
+
function ee(r, e, n, a) {
|
|
436
|
+
let s;
|
|
425
437
|
try {
|
|
426
438
|
switch (r) {
|
|
427
439
|
case "fs":
|
|
428
|
-
|
|
440
|
+
s = (function(i, t) {
|
|
429
441
|
if (!t) return null;
|
|
430
442
|
switch (i) {
|
|
431
443
|
case "readFile":
|
|
@@ -448,7 +460,7 @@ function Z(r, e, n, a) {
|
|
|
448
460
|
})(e, n);
|
|
449
461
|
break;
|
|
450
462
|
case "dns":
|
|
451
|
-
|
|
463
|
+
s = (function(i, t) {
|
|
452
464
|
if (!t) return null;
|
|
453
465
|
switch (i) {
|
|
454
466
|
case "lookup":
|
|
@@ -469,7 +481,7 @@ function Z(r, e, n, a) {
|
|
|
469
481
|
})(e, n);
|
|
470
482
|
break;
|
|
471
483
|
case "crypto":
|
|
472
|
-
|
|
484
|
+
s = (function(i, t) {
|
|
473
485
|
if (!t) return null;
|
|
474
486
|
switch (i) {
|
|
475
487
|
case "pbkdf2":
|
|
@@ -484,22 +496,22 @@ function Z(r, e, n, a) {
|
|
|
484
496
|
})(e, n);
|
|
485
497
|
break;
|
|
486
498
|
case "zlib":
|
|
487
|
-
|
|
499
|
+
s = (function(i, t) {
|
|
488
500
|
return t ? Buffer.isBuffer(t) ? { type: "Buffer", size: t.length } : typeof t == "string" ? { type: "string", size: t.length } : { type: typeof t } : null;
|
|
489
501
|
})(0, n);
|
|
490
502
|
break;
|
|
491
503
|
default:
|
|
492
504
|
return null;
|
|
493
505
|
}
|
|
494
|
-
return a > 0 ?
|
|
506
|
+
return a > 0 ? X(s, a) : s;
|
|
495
507
|
} catch {
|
|
496
508
|
return { error: "Failed to capture result", type: typeof n };
|
|
497
509
|
}
|
|
498
510
|
}
|
|
499
|
-
function
|
|
511
|
+
function le(r) {
|
|
500
512
|
return r.operationType === "worker_pool";
|
|
501
513
|
}
|
|
502
|
-
class
|
|
514
|
+
class pe extends ce {
|
|
503
515
|
constructor() {
|
|
504
516
|
super(), this.operationName = "CollectFunctionSpans";
|
|
505
517
|
}
|
|
@@ -507,20 +519,20 @@ class le extends ie {
|
|
|
507
519
|
const n = f().sfDebug;
|
|
508
520
|
n && console.log(`[FunctionSpanTransmitter] Preparing to send ${e.length} function span(s)`);
|
|
509
521
|
for (const a of e) try {
|
|
510
|
-
if (
|
|
522
|
+
if (le(a)) {
|
|
511
523
|
this.sendWorkerPoolSpan(a, n);
|
|
512
524
|
continue;
|
|
513
525
|
}
|
|
514
|
-
const
|
|
526
|
+
const s = a;
|
|
515
527
|
let i;
|
|
516
|
-
if (
|
|
517
|
-
const
|
|
518
|
-
i = JSON.stringify({ type:
|
|
519
|
-
} else i =
|
|
520
|
-
const t = this.getVariables({ library: "JS/TS BACKEND", version: f().version, spanId:
|
|
521
|
-
n && (console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(t, null, 2))),
|
|
522
|
-
} catch (
|
|
523
|
-
console.error(`[FunctionSpanTransmitter] Error preparing function span for ${a.functionName}:`,
|
|
528
|
+
if (s.result !== void 0 && s.result !== null) {
|
|
529
|
+
const o = typeof s.result;
|
|
530
|
+
i = JSON.stringify({ type: o, has_value: !0, value: s.result });
|
|
531
|
+
} else i = s.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
|
|
532
|
+
const t = this.getVariables({ library: "JS/TS BACKEND", version: f().version, spanId: s.spanId, parentSpanId: s.parentSpanId, filePath: s.filePath, lineNumber: s.metadata.line, columnNumber: s.metadata.column, functionName: s.functionName, arguments: JSON.stringify(s.args || {}), returnValue: i, startTimeNs: (1e6 * Date.now() - 1e6 * s.duration).toString(), durationNs: (1e6 * s.duration).toString() });
|
|
533
|
+
n && (console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(t, null, 2))), q(this.endpoint, this.operationName, this.getQuery(), t), n && console.log(`[FunctionSpanTransmitter] Queued function span for ${s.functionName}`);
|
|
534
|
+
} catch (s) {
|
|
535
|
+
console.error(`[FunctionSpanTransmitter] Error preparing function span for ${a.functionName}:`, s);
|
|
524
536
|
}
|
|
525
537
|
}
|
|
526
538
|
sendWorkerPoolSpan(e, n) {
|
|
@@ -530,8 +542,8 @@ class le extends ie {
|
|
|
530
542
|
const i = typeof e.result;
|
|
531
543
|
a = JSON.stringify({ type: i, has_value: !0, value: e.result });
|
|
532
544
|
} else a = e.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
|
|
533
|
-
const
|
|
534
|
-
n && (console.log(`[FunctionSpanTransmitter] Sending worker pool span: ${e.operationName}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(
|
|
545
|
+
const s = this.getVariables({ library: "JS/TS BACKEND", version: f().version, spanId: e.spanId, operationName: e.operationName, moduleName: e.moduleName, methodName: e.methodName, startTimeNs: e.startTimeNs, durationNs: e.durationNs, arguments: JSON.stringify(e.args || {}), returnValue: a, error: e.error, pid: e.pid, threadId: e.threadId });
|
|
546
|
+
n && (console.log(`[FunctionSpanTransmitter] Sending worker pool span: ${e.operationName}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(s, null, 2))), q(this.endpoint, "CollectWorkerPoolSpans", this.getWorkerPoolQuery(), s), n && console.log(`[FunctionSpanTransmitter] Queued worker pool span for ${e.operationName}`);
|
|
535
547
|
} catch (a) {
|
|
536
548
|
console.error(`[FunctionSpanTransmitter] Error preparing worker pool span for ${e.operationName}:`, a);
|
|
537
549
|
}
|
|
@@ -623,83 +635,84 @@ class le extends ie {
|
|
|
623
635
|
`;
|
|
624
636
|
}
|
|
625
637
|
}
|
|
626
|
-
let
|
|
627
|
-
function
|
|
638
|
+
let R = null;
|
|
639
|
+
function Ee(r, e, n, a, s) {
|
|
628
640
|
const i = A(), t = i?.sfDebug || !1;
|
|
629
641
|
t && console.log(`[WorkerPool] Capturing ${r}.${e}`);
|
|
630
|
-
const
|
|
642
|
+
const o = K(), u = I.getInstance().getCurrentFunctionSpanId(), m = C();
|
|
631
643
|
t && console.log(`[WorkerPool] Span ID: ${m}, Parent: ${u || "none"}`);
|
|
632
|
-
const p = new
|
|
644
|
+
const p = new ne("WorkerPoolOperation"), g = process.hrtime.bigint();
|
|
633
645
|
let d = null;
|
|
634
|
-
|
|
646
|
+
o.captureArguments && (d = Z(r, e, a, o.argLimitMb));
|
|
635
647
|
const S = a.findIndex((v) => typeof v == "function");
|
|
636
|
-
if (S === -1) return t && console.log(`[WorkerPool] No callback found for ${r}.${e}`), n.apply(
|
|
648
|
+
if (S === -1) return t && console.log(`[WorkerPool] No callback found for ${r}.${e}`), n.apply(s, a);
|
|
637
649
|
const y = a[S], T = [...a];
|
|
638
|
-
return T[S] = function(v, ...
|
|
639
|
-
const
|
|
640
|
-
y(v, ...
|
|
641
|
-
t && console.log(`[WorkerPool] ${r}.${e} completed in ${
|
|
642
|
-
let
|
|
643
|
-
v ?
|
|
650
|
+
return T[S] = function(v, ...P) {
|
|
651
|
+
const O = process.hrtime.bigint() - g, B = Number(O) / 1e6;
|
|
652
|
+
y(v, ...P), p.runInAsyncScope(() => {
|
|
653
|
+
t && console.log(`[WorkerPool] ${r}.${e} completed in ${B.toFixed(3)}ms (${O}ns)`);
|
|
654
|
+
let W = null, G = null;
|
|
655
|
+
v ? G = v?.message || String(v) : o.captureReturnValue && P.length > 0 && (W = ee(r, e, P[0], o.returnLimitMb)), M({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: B, durationNs: O.toString(), startTimeNs: g.toString(), args: d, result: W, error: G, spanId: m, parentSpanId: u, pid: process.pid, threadId: w });
|
|
644
656
|
}), p.emitDestroy();
|
|
645
|
-
}, n.apply(
|
|
657
|
+
}, n.apply(s, T);
|
|
646
658
|
}
|
|
647
|
-
function
|
|
659
|
+
function Ae(r, e, n, a, s) {
|
|
648
660
|
const i = A(), t = i?.sfDebug || !1;
|
|
649
661
|
t && console.log(`[WorkerPool] Capturing ${r}.${e} (Promise)`);
|
|
650
|
-
const
|
|
662
|
+
const o = K(), u = I.getInstance().getCurrentFunctionSpanId(), m = C();
|
|
651
663
|
t && console.log(`[WorkerPool] Span ID: ${m}, Parent: ${u || "none"}`);
|
|
652
664
|
const p = process.hrtime.bigint();
|
|
653
665
|
let g = null;
|
|
654
|
-
return
|
|
666
|
+
return o.captureArguments && (g = Z(r, e, a, o.argLimitMb)), n.apply(s, a).then((d) => {
|
|
655
667
|
const S = process.hrtime.bigint() - p, y = Number(S) / 1e6;
|
|
656
668
|
t && console.log(`[WorkerPool] ${r}.${e} completed in ${y.toFixed(3)}ms (${S}ns)`);
|
|
657
669
|
let T = null;
|
|
658
|
-
return
|
|
670
|
+
return o.captureReturnValue && (T = ee(r, e, d, o.returnLimitMb)), M({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: y, durationNs: S.toString(), startTimeNs: p.toString(), args: g, result: T, error: null, spanId: m, parentSpanId: u, pid: process.pid, threadId: w }), d;
|
|
659
671
|
}, (d) => {
|
|
660
672
|
const S = process.hrtime.bigint() - p, y = Number(S) / 1e6;
|
|
661
|
-
throw t && console.log(`[WorkerPool] ${r}.${e} failed in ${y.toFixed(3)}ms: ${d?.message || d}`),
|
|
673
|
+
throw t && console.log(`[WorkerPool] ${r}.${e} failed in ${y.toFixed(3)}ms: ${d?.message || d}`), M({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: y, durationNs: S.toString(), startTimeNs: p.toString(), args: g, result: null, error: d?.message || String(d), spanId: m, parentSpanId: u, pid: process.pid, threadId: w }), d;
|
|
662
674
|
});
|
|
663
675
|
}
|
|
664
|
-
function
|
|
676
|
+
function M(r) {
|
|
665
677
|
const e = A(), n = e?.sfDebug || !1;
|
|
666
678
|
n && console.log("[WorkerPool] Capturing span:", { operation: r.operationName, duration: `${r.duration}ms`, error: r.error, spanId: r.spanId, parentSpanId: r.parentSpanId }), process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true" && console.log(`
|
|
667
679
|
⚙️ Worker Pool Operation:`, { operation: r.operationName, duration: `${r.duration.toFixed(2)}ms`, arguments: r.args, result: r.error ? `Error: ${r.error}` : r.result, spanId: r.spanId, parentSpanId: r.parentSpanId || "none" });
|
|
668
680
|
const a = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
669
681
|
if (a) try {
|
|
670
|
-
const
|
|
682
|
+
const s = a === "true" || a === "1" ? "funcspans.jsonl" : a, i = Date.now(), t = process.hrtime.bigint(), o = BigInt(r.startTimeNs), u = Number(t - o) / 1e6, m = new Date(i - u).toISOString(), p = JSON.stringify({ timestamp: m, operationType: r.operationType, operationName: r.operationName, moduleName: r.moduleName, methodName: r.methodName, duration: r.duration, durationNs: r.durationNs, startTimeNs: r.startTimeNs, arguments: r.args, returnValue: r.error ? { error: String(r.error) } : r.result, spanId: r.spanId, parentSpanId: r.parentSpanId, pid: r.pid, threadId: r.threadId }) + `
|
|
671
683
|
`;
|
|
672
|
-
|
|
673
|
-
} catch (
|
|
674
|
-
console.error("[WorkerPool] Error writing to JSONL file:",
|
|
684
|
+
oe(s, p, "utf-8");
|
|
685
|
+
} catch (s) {
|
|
686
|
+
console.error("[WorkerPool] Error writing to JSONL file:", s);
|
|
675
687
|
}
|
|
676
688
|
if (n && console.log("[WorkerPool] Sending span to transmitter"), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
|
|
677
|
-
(
|
|
678
|
-
} catch (
|
|
679
|
-
n && console.error("[WorkerPool] Error sending span:",
|
|
689
|
+
(R || (R = new pe()), R).send([r]), n && console.log("[WorkerPool] Span sent successfully");
|
|
690
|
+
} catch (s) {
|
|
691
|
+
n && console.error("[WorkerPool] Error sending span:", s);
|
|
680
692
|
}
|
|
681
693
|
}
|
|
682
694
|
export {
|
|
683
|
-
|
|
695
|
+
ce as B,
|
|
684
696
|
I as C,
|
|
685
|
-
|
|
686
|
-
|
|
697
|
+
ie as D,
|
|
698
|
+
pe as F,
|
|
687
699
|
be as a,
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
700
|
+
ye as b,
|
|
701
|
+
Ee as c,
|
|
702
|
+
Ne as d,
|
|
703
|
+
_e as e,
|
|
704
|
+
x as f,
|
|
693
705
|
f as g,
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
706
|
+
Ae as h,
|
|
707
|
+
$e as i,
|
|
708
|
+
Se as j,
|
|
697
709
|
A as k,
|
|
698
|
-
Ce as
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
710
|
+
Ce as l,
|
|
711
|
+
Te as m,
|
|
712
|
+
q as n,
|
|
713
|
+
Ie as p,
|
|
714
|
+
he as r,
|
|
715
|
+
ve as s,
|
|
716
|
+
X as t,
|
|
704
717
|
C as v
|
|
705
718
|
};
|