@sailfish-ai/sf-veritas 0.2.6 → 0.2.9
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/contextManager-CEPhVu9T.js +197 -0
- package/dist/contextManager-CGINtRN5.cjs +1 -0
- package/dist/funcSpanTransformer-B9WWl-g1.cjs +1 -0
- package/dist/funcSpanTransformer-CWNEWRxq.js +225 -0
- package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
- package/dist/plugins/funcspanEsbuildPlugin.mjs +17 -11
- package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.mjs +13 -8
- package/dist/plugins/funcspanTscPlugin.cjs +1 -1
- package/dist/plugins/funcspanTscPlugin.mjs +19 -14
- package/dist/plugins/funcspanVitePlugin.cjs +1 -1
- package/dist/plugins/funcspanVitePlugin.mjs +15 -10
- package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.mjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.mjs +22 -17
- package/dist/runtime/funcspanRegister.cjs +276 -0
- package/dist/runtimeConfig-CpQ27dZD.cjs +8 -0
- package/dist/runtimeConfig-emBNO3lJ.js +350 -0
- package/dist/sf-veritas.cjs +18 -18
- package/dist/sf-veritas.mjs +461 -620
- package/dist/source-map-Cr6YkjTd.js +631 -0
- package/dist/source-map-rHHEdpre.cjs +1 -0
- package/dist/types/dataTransmitter.d.ts +1 -0
- package/dist/types/funcSpanConfig.d.ts +8 -0
- package/dist/types/funcSpanConfigLoader.d.ts +10 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/logHandler.d.ts +5 -0
- package/dist/types/plugins/funcSpanTransformer.d.ts +13 -0
- package/dist/types/runtime/instrumentationDetector.d.ts +33 -0
- package/dist/types/runtime/runtimeConfig.d.ts +48 -0
- package/dist/types/sourceLocation.d.ts +30 -0
- 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-B5KN-q4b.js +528 -0
- package/dist/workerPoolSpanCapture-Dg_WGjmO.cjs +86 -0
- package/package.json +5 -2
- package/dist/funcSpanTransformer-TjdooSrw.cjs +0 -1
- package/dist/funcSpanTransformer-sqmZLAcs.js +0 -750
- package/dist/workerPoolSpanCapture-BOnYC4s3.js +0 -705
- package/dist/workerPoolSpanCapture-CNEouInA.cjs +0 -83
|
@@ -1,705 +0,0 @@
|
|
|
1
|
-
var ee = Object.defineProperty;
|
|
2
|
-
var te = (r, e, n) => e in r ? ee(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
-
var c = (r, e, n) => te(r, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
-
import { AsyncLocalStorage as x, AsyncResource as re } from "async_hooks";
|
|
5
|
-
import { appendFileSync as ne } from "fs";
|
|
6
|
-
import { threadId as R } from "worker_threads";
|
|
7
|
-
const l = [];
|
|
8
|
-
for (let r = 0; r < 256; ++r) l.push((r + 256).toString(16).slice(1));
|
|
9
|
-
let O;
|
|
10
|
-
const se = new Uint8Array(16), G = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
|
|
11
|
-
function C(r, e, n) {
|
|
12
|
-
if (G.randomUUID && !r) return G.randomUUID();
|
|
13
|
-
const a = (r = r || {}).random ?? r.rng?.() ?? (function() {
|
|
14
|
-
if (!O) {
|
|
15
|
-
if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
16
|
-
O = crypto.getRandomValues.bind(crypto);
|
|
17
|
-
}
|
|
18
|
-
return O(se);
|
|
19
|
-
})();
|
|
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(o, i = 0) {
|
|
22
|
-
return (l[o[i + 0]] + l[o[i + 1]] + l[o[i + 2]] + l[o[i + 3]] + "-" + l[o[i + 4]] + l[o[i + 5]] + "-" + l[o[i + 6]] + l[o[i + 7]] + "-" + l[o[i + 8]] + l[o[i + 9]] + "-" + l[o[i + 10]] + l[o[i + 11]] + l[o[i + 12]] + l[o[i + 13]] + l[o[i + 14]] + l[o[i + 15]]).toLowerCase();
|
|
23
|
-
})(a);
|
|
24
|
-
}
|
|
25
|
-
class oe {
|
|
26
|
-
constructor(e) {
|
|
27
|
-
c(this, "apiKey");
|
|
28
|
-
c(this, "apiGraphqlEndpoint");
|
|
29
|
-
c(this, "sfDebug");
|
|
30
|
-
c(this, "serviceIdentifier");
|
|
31
|
-
c(this, "serviceVersion");
|
|
32
|
-
c(this, "serviceUUID");
|
|
33
|
-
c(this, "serviceAdditionalMetadata");
|
|
34
|
-
c(this, "profilingModeEnabled");
|
|
35
|
-
c(this, "profilingMaxDepth");
|
|
36
|
-
c(this, "profilingMaxVariableSizeKb");
|
|
37
|
-
c(this, "domainsToNotPropagateHeadersTo");
|
|
38
|
-
c(this, "nodeModulesToCollectLocalVariablesOn");
|
|
39
|
-
c(this, "printConfigurationStatuses");
|
|
40
|
-
c(this, "logLevel");
|
|
41
|
-
c(this, "stackDepthLocals");
|
|
42
|
-
c(this, "stackDepthCodeTraceDepth");
|
|
43
|
-
c(this, "packageLibraryType");
|
|
44
|
-
c(this, "version");
|
|
45
|
-
c(this, "gitSha");
|
|
46
|
-
c(this, "_serviceIdentificationReceived", !1);
|
|
47
|
-
this.apiKey = e.apiKey, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = C(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.gitSha = e?.gitSha || process.env.GIT_SHA || process.env.VERCEL_GIT_COMMIT_SHA, this.serviceAdditionalMetadata = e?.serviceAdditionalMetadata || {}, this.profilingModeEnabled = e?.profilingModeEnabled ?? !1, this.profilingMaxDepth = e?.profilingMaxDepth ?? 5, this.profilingMaxVariableSizeKb = e?.profilingMaxVariableSizeKb ?? 25, this.domainsToNotPropagateHeadersTo = e?.domainsToNotPropagateHeadersTo || [], this.nodeModulesToCollectLocalVariablesOn = e?.nodeModulesToCollectLocalVariablesOn || ["_all_"], this.printConfigurationStatuses = process.env.PRINT_CONFIGURATION_STATUSES || "true", this.logLevel = process.env.LOG_LEVEL || "INFO", this.stackDepthLocals = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS, 10) : 5, isNaN(this.stackDepthLocals) && (this.stackDepthLocals = -1), this.stackDepthCodeTraceDepth = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH, 10) : -1, isNaN(this.stackDepthCodeTraceDepth) && (this.stackDepthCodeTraceDepth = -1), this.packageLibraryType = "JS/TS BACKEND", this.version = this.getPackageVersion();
|
|
48
|
-
}
|
|
49
|
-
getPackageVersion() {
|
|
50
|
-
return "0.1.15";
|
|
51
|
-
}
|
|
52
|
-
get serviceIdentificationReceived() {
|
|
53
|
-
return this._serviceIdentificationReceived;
|
|
54
|
-
}
|
|
55
|
-
setServiceIdentificationReceived(e) {
|
|
56
|
-
this._serviceIdentificationReceived = e;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const Q = Symbol.for("sailfish.sf_config");
|
|
60
|
-
function A() {
|
|
61
|
-
return globalThis[Q];
|
|
62
|
-
}
|
|
63
|
-
function me(r) {
|
|
64
|
-
const e = A();
|
|
65
|
-
if (e) return { config: e };
|
|
66
|
-
const n = new oe(r);
|
|
67
|
-
return (function(a) {
|
|
68
|
-
globalThis[Q] = a;
|
|
69
|
-
})(n), n.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", n), { config: n };
|
|
70
|
-
}
|
|
71
|
-
function f() {
|
|
72
|
-
const r = A();
|
|
73
|
-
if (!r) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
|
|
74
|
-
return r;
|
|
75
|
-
}
|
|
76
|
-
const z = Symbol.for("sf.ctx.storeAls"), h = globalThis, k = h[z] ?? (h[z] = new x()), ae = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], H = Symbol.for("sf.ctx.als"), E = h[H] ?? (h[H] = new x()), J = Symbol.for("sf.ctx.sessionRegistry"), $ = h[J] ?? (h[J] = /* @__PURE__ */ new Map()), D = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(ae), supportedDomains: /* @__PURE__ */ new Set() }, _ = class _ {
|
|
77
|
-
constructor() {
|
|
78
|
-
}
|
|
79
|
-
current() {
|
|
80
|
-
return k.getStore();
|
|
81
|
-
}
|
|
82
|
-
ensureStore() {
|
|
83
|
-
const e = this.current();
|
|
84
|
-
if (e) return e;
|
|
85
|
-
const n = /* @__PURE__ */ new Map();
|
|
86
|
-
return k.enterWith(n), n;
|
|
87
|
-
}
|
|
88
|
-
runWith(e, n) {
|
|
89
|
-
const a = this.current() ?? /* @__PURE__ */ new Map(), o = new Map(a);
|
|
90
|
-
for (const [i, t] of Object.entries(e)) o.set(i, t);
|
|
91
|
-
return k.run(o, n);
|
|
92
|
-
}
|
|
93
|
-
static getInstance() {
|
|
94
|
-
return h[_.GLOBAL_MANAGER_SYMBOL] || (h[_.GLOBAL_MANAGER_SYMBOL] = new _()), h[_.GLOBAL_MANAGER_SYMBOL];
|
|
95
|
-
}
|
|
96
|
-
getCurrentContext() {
|
|
97
|
-
return E.getStore() || D;
|
|
98
|
-
}
|
|
99
|
-
setCurrentContext(e) {
|
|
100
|
-
const n = E.getStore() || D;
|
|
101
|
-
E.enterWith({ ...n, ...e });
|
|
102
|
-
}
|
|
103
|
-
ensureSession(e) {
|
|
104
|
-
let n = $.get(e);
|
|
105
|
-
return n || (n = { ...D }, $.set(e, n)), n;
|
|
106
|
-
}
|
|
107
|
-
getContextFor(e) {
|
|
108
|
-
return $.get(e) ?? D;
|
|
109
|
-
}
|
|
110
|
-
updateContextFor(e, n) {
|
|
111
|
-
const a = this.ensureSession(e);
|
|
112
|
-
$.set(e, { ...a, ...n });
|
|
113
|
-
}
|
|
114
|
-
runWithSession(e, n) {
|
|
115
|
-
const a = { ...this.ensureSession(e) };
|
|
116
|
-
return E.run(a, n);
|
|
117
|
-
}
|
|
118
|
-
deleteSession(e) {
|
|
119
|
-
$.delete(e);
|
|
120
|
-
}
|
|
121
|
-
getTraceId() {
|
|
122
|
-
return this.getCurrentContext().traceId;
|
|
123
|
-
}
|
|
124
|
-
getPageVisitUUID() {
|
|
125
|
-
return this.getCurrentContext().pageVisitUUID;
|
|
126
|
-
}
|
|
127
|
-
setTraceId(e) {
|
|
128
|
-
this.setCurrentContext({ traceId: e });
|
|
129
|
-
}
|
|
130
|
-
setPageVisitUUID(e) {
|
|
131
|
-
this.setCurrentContext({ pageVisitUUID: e });
|
|
132
|
-
}
|
|
133
|
-
getCurrentFunctionSpanId() {
|
|
134
|
-
return this.getCurrentContext().currentFunctionSpanId;
|
|
135
|
-
}
|
|
136
|
-
setCurrentFunctionSpanId(e) {
|
|
137
|
-
this.setCurrentContext({ currentFunctionSpanId: e });
|
|
138
|
-
}
|
|
139
|
-
clearCurrentFunctionSpanId() {
|
|
140
|
-
this.setCurrentContext({ currentFunctionSpanId: void 0 });
|
|
141
|
-
}
|
|
142
|
-
getOrSetSfTraceId(e, n = !1) {
|
|
143
|
-
let a = this.getTraceId();
|
|
144
|
-
return a || (a = e || (n ? C() : `nonsession-applogs-v3/${f().apiKey}/${C()}`), this.setTraceId(a), f().sfDebug && console.log(" Created new trace ID:", a), a);
|
|
145
|
-
}
|
|
146
|
-
getOrSetPageVisitUUID() {
|
|
147
|
-
let e = this.getPageVisitUUID();
|
|
148
|
-
return e || (e = C(), this.setPageVisitUUID(e), f().sfDebug && console.log(" Created new page visit UUID:", e), e);
|
|
149
|
-
}
|
|
150
|
-
getHandledExceptions() {
|
|
151
|
-
return this.getCurrentContext().handledExceptions;
|
|
152
|
-
}
|
|
153
|
-
markExceptionHandled(e) {
|
|
154
|
-
const n = this.getHandledExceptions();
|
|
155
|
-
n.add(e), this.setCurrentContext({ handledExceptions: n });
|
|
156
|
-
}
|
|
157
|
-
hasHandledException(e) {
|
|
158
|
-
return this.getHandledExceptions().has(e);
|
|
159
|
-
}
|
|
160
|
-
resetHandledExceptions() {
|
|
161
|
-
this.setCurrentContext({ handledExceptions: /* @__PURE__ */ new Set() });
|
|
162
|
-
}
|
|
163
|
-
getExcludedDomains() {
|
|
164
|
-
return this.getCurrentContext().excludedDomains;
|
|
165
|
-
}
|
|
166
|
-
getSupportedDomains() {
|
|
167
|
-
return this.getCurrentContext().supportedDomains;
|
|
168
|
-
}
|
|
169
|
-
addSupportedDomains(e) {
|
|
170
|
-
this.getCurrentContext().supportedDomains.add(e.toLowerCase().trim());
|
|
171
|
-
}
|
|
172
|
-
setTraceIdFor(e, n) {
|
|
173
|
-
this.updateContextFor(e, { traceId: n });
|
|
174
|
-
}
|
|
175
|
-
setPageVisitUUIDFor(e, n) {
|
|
176
|
-
this.updateContextFor(e, { pageVisitUUID: n });
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
c(_, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
|
|
180
|
-
let I = _;
|
|
181
|
-
function Se(r) {
|
|
182
|
-
const e = { ...I.getInstance().getCurrentContext() };
|
|
183
|
-
E.run(e, () => {
|
|
184
|
-
r();
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
function he() {
|
|
188
|
-
return I.getInstance().getCurrentFunctionSpanId();
|
|
189
|
-
}
|
|
190
|
-
class ie {
|
|
191
|
-
constructor() {
|
|
192
|
-
c(this, "apiKey");
|
|
193
|
-
c(this, "endpoint");
|
|
194
|
-
c(this, "queryType", "mutation");
|
|
195
|
-
c(this, "operationName", "");
|
|
196
|
-
c(this, "serviceUUID", f().serviceUUID);
|
|
197
|
-
c(this, "contextManager");
|
|
198
|
-
this.apiKey = f().apiKey, this.endpoint = f().apiGraphqlEndpoint, this.contextManager = I.getInstance();
|
|
199
|
-
}
|
|
200
|
-
get queryName() {
|
|
201
|
-
return this.operationName ? this.operationName.charAt(0).toLowerCase() + this.operationName.slice(1) : "";
|
|
202
|
-
}
|
|
203
|
-
getDefaultVariables() {
|
|
204
|
-
const e = Date.now().toString(), n = this.contextManager.getOrSetSfTraceId(), a = this.contextManager.getCurrentFunctionSpanId();
|
|
205
|
-
return { apiKey: this.apiKey, serviceUuid: this.serviceUUID, sessionId: n, timestampMs: e, parentSpanId: a };
|
|
206
|
-
}
|
|
207
|
-
getVariables(e = {}) {
|
|
208
|
-
return { ...this.getDefaultVariables(), ...e };
|
|
209
|
-
}
|
|
210
|
-
setOperationName(e) {
|
|
211
|
-
this.operationName = e;
|
|
212
|
-
}
|
|
213
|
-
setEndpoint(e) {
|
|
214
|
-
this.endpoint = e;
|
|
215
|
-
}
|
|
216
|
-
setServiceUUID(e) {
|
|
217
|
-
this.serviceUUID = e;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
const ce = fetch;
|
|
221
|
-
let P = !1;
|
|
222
|
-
async function j(r, e, n, a) {
|
|
223
|
-
try {
|
|
224
|
-
const o = f();
|
|
225
|
-
let i;
|
|
226
|
-
try {
|
|
227
|
-
i = JSON.stringify({ query: n, variables: a, operationName: e });
|
|
228
|
-
} catch {
|
|
229
|
-
i = JSON.stringify({ query: n, operationName: e });
|
|
230
|
-
}
|
|
231
|
-
P = !0, ce(r, { method: "POST", headers: { "Content-Type": "application/json" }, body: i }).then(async (t) => {
|
|
232
|
-
if (P = !1, !t.ok) return void (o.sfDebug && console.error(`GraphQL request failed with status ${t.status} for ${e}`));
|
|
233
|
-
const s = await t.json();
|
|
234
|
-
s.errors?.length ? (function(u, m, p) {
|
|
235
|
-
const g = u && typeof u == "object" && !Array.isArray(u) ? Object.keys(u)[0] : void 0;
|
|
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
|
-
})(s.data, s.errors, o) : o.sfDebug && (function(u, m, p) {
|
|
238
|
-
const g = u && typeof u == "object" && !Array.isArray(u) ? Object.keys(u)[0] : void 0, d = u[g] || !1;
|
|
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
|
-
})(s.data, 0, o);
|
|
241
|
-
}).catch((t) => {
|
|
242
|
-
P = !1, o.sfDebug && (console.error(`[RequestUtils] Fetch error for ${e} to ${r}:`, t), t.cause && console.error("[RequestUtils] Error cause:", t.cause));
|
|
243
|
-
});
|
|
244
|
-
} catch (o) {
|
|
245
|
-
P = !1, f().sfDebug && console.error("Error sending data to GraphQL server:", o);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
function ye() {
|
|
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
|
-
}
|
|
251
|
-
function Ne() {
|
|
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
|
-
}
|
|
254
|
-
function _e(r) {
|
|
255
|
-
try {
|
|
256
|
-
const e = r.split("-");
|
|
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" };
|
|
258
|
-
} catch (e) {
|
|
259
|
-
return console.error(`[FuncSpan] Failed to parse header override "${r}":`, e), null;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function b(r, e) {
|
|
263
|
-
if (!r) return e;
|
|
264
|
-
const n = r.toLowerCase();
|
|
265
|
-
return n === "true" || n === "1" || n === "yes";
|
|
266
|
-
}
|
|
267
|
-
const M = new x();
|
|
268
|
-
function Ie(r) {
|
|
269
|
-
M.enterWith(r);
|
|
270
|
-
}
|
|
271
|
-
function ve() {
|
|
272
|
-
return M.getStore();
|
|
273
|
-
}
|
|
274
|
-
function be() {
|
|
275
|
-
M.enterWith(void 0);
|
|
276
|
-
}
|
|
277
|
-
function Ce(...r) {
|
|
278
|
-
const e = {};
|
|
279
|
-
for (const n of r) for (const a in n) n[a] !== void 0 && (e[a] = n[a]);
|
|
280
|
-
return e;
|
|
281
|
-
}
|
|
282
|
-
function Y(r, e) {
|
|
283
|
-
try {
|
|
284
|
-
const n = JSON.stringify(r).length / 1048576;
|
|
285
|
-
return n <= e ? r : { _truncated: !0, _originalSizeMB: n.toFixed(2), _limitMB: e, _preview: JSON.stringify(r).substring(0, 500) + "..." };
|
|
286
|
-
} catch {
|
|
287
|
-
return { _error: "Failed to serialize data", _type: typeof r };
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
function N(r, e) {
|
|
291
|
-
const n = process.env[r];
|
|
292
|
-
return n === void 0 ? e : n === "true" || n === "1";
|
|
293
|
-
}
|
|
294
|
-
function q(r, e) {
|
|
295
|
-
const n = process.env[r];
|
|
296
|
-
if (n === void 0) return e;
|
|
297
|
-
const a = parseFloat(n);
|
|
298
|
-
return isNaN(a) ? e : a;
|
|
299
|
-
}
|
|
300
|
-
function V() {
|
|
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: q("SF_WORKER_POOL_ARG_LIMIT_MB", 1), returnLimitMb: q("SF_WORKER_POOL_RETURN_LIMIT_MB", 1) };
|
|
302
|
-
}
|
|
303
|
-
function Te(r) {
|
|
304
|
-
const e = V();
|
|
305
|
-
if (!e.enabled) return !1;
|
|
306
|
-
switch (r) {
|
|
307
|
-
case "fs":
|
|
308
|
-
return e.trackFs;
|
|
309
|
-
case "dns":
|
|
310
|
-
return e.trackDns;
|
|
311
|
-
case "crypto":
|
|
312
|
-
return e.trackCrypto;
|
|
313
|
-
case "zlib":
|
|
314
|
-
return e.trackZlib;
|
|
315
|
-
default:
|
|
316
|
-
return !1;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
function X(r, e, n, a) {
|
|
320
|
-
let o;
|
|
321
|
-
try {
|
|
322
|
-
switch (r) {
|
|
323
|
-
case "fs":
|
|
324
|
-
o = (function(i, t) {
|
|
325
|
-
const s = {};
|
|
326
|
-
switch (i) {
|
|
327
|
-
case "readFile":
|
|
328
|
-
case "writeFile":
|
|
329
|
-
case "appendFile":
|
|
330
|
-
s.path = String(t[0] || ""), t[1] && typeof t[1] == "object" ? (s.encoding = t[1].encoding || null, s.flag = t[1].flag || null) : typeof t[1] == "string" && (s.encoding = t[1]), i !== "writeFile" && i !== "appendFile" || (Buffer.isBuffer(t[1]) ? (s.dataType = "Buffer", s.dataSize = t[1].length) : typeof t[1] == "string" && (s.dataType = "string", s.dataSize = t[1].length));
|
|
331
|
-
break;
|
|
332
|
-
case "readdir":
|
|
333
|
-
case "stat":
|
|
334
|
-
case "lstat":
|
|
335
|
-
case "access":
|
|
336
|
-
case "chmod":
|
|
337
|
-
case "mkdir":
|
|
338
|
-
case "rmdir":
|
|
339
|
-
case "unlink":
|
|
340
|
-
s.path = String(t[0] || ""), t[1] && typeof t[1] == "object" && (s.options = { ...t[1] }, delete s.options.callback);
|
|
341
|
-
break;
|
|
342
|
-
case "rename":
|
|
343
|
-
s.oldPath = String(t[0] || ""), s.newPath = String(t[1] || "");
|
|
344
|
-
break;
|
|
345
|
-
case "open":
|
|
346
|
-
s.path = String(t[0] || ""), s.flags = t[1], s.mode = t[2];
|
|
347
|
-
break;
|
|
348
|
-
case "close":
|
|
349
|
-
case "fstat":
|
|
350
|
-
s.fd = t[0];
|
|
351
|
-
break;
|
|
352
|
-
case "read":
|
|
353
|
-
case "write":
|
|
354
|
-
s.fd = t[0], Buffer.isBuffer(t[1]) && (s.bufferSize = t[1].length), s.offset = t[2], s.length = t[3], s.position = t[4];
|
|
355
|
-
break;
|
|
356
|
-
default:
|
|
357
|
-
s.argsCount = t.length - 1;
|
|
358
|
-
}
|
|
359
|
-
return s;
|
|
360
|
-
})(e, n);
|
|
361
|
-
break;
|
|
362
|
-
case "dns":
|
|
363
|
-
o = (function(i, t) {
|
|
364
|
-
const s = {};
|
|
365
|
-
switch (i) {
|
|
366
|
-
case "lookup":
|
|
367
|
-
s.hostname = String(t[0] || ""), typeof t[1] == "object" ? (s.family = t[1].family, s.all = t[1].all) : typeof t[1] == "number" && (s.family = t[1]);
|
|
368
|
-
break;
|
|
369
|
-
case "resolve":
|
|
370
|
-
case "resolve4":
|
|
371
|
-
case "resolve6":
|
|
372
|
-
case "resolveAny":
|
|
373
|
-
case "resolveMx":
|
|
374
|
-
case "resolveNs":
|
|
375
|
-
case "resolveTxt":
|
|
376
|
-
s.hostname = String(t[0] || "");
|
|
377
|
-
break;
|
|
378
|
-
case "reverse":
|
|
379
|
-
s.ip = String(t[0] || "");
|
|
380
|
-
break;
|
|
381
|
-
default:
|
|
382
|
-
s.argsCount = t.length - 1;
|
|
383
|
-
}
|
|
384
|
-
return s;
|
|
385
|
-
})(e, n);
|
|
386
|
-
break;
|
|
387
|
-
case "crypto":
|
|
388
|
-
o = (function(i, t) {
|
|
389
|
-
const s = {};
|
|
390
|
-
switch (i) {
|
|
391
|
-
case "pbkdf2":
|
|
392
|
-
s.passwordType = typeof t[0], s.saltType = typeof t[1], s.iterations = t[2], s.keylen = t[3], s.digest = t[4];
|
|
393
|
-
break;
|
|
394
|
-
case "scrypt":
|
|
395
|
-
s.passwordType = typeof t[0], s.saltType = typeof t[1], s.keylen = t[2], typeof t[3] == "object" && (s.N = t[3].N, s.r = t[3].r, s.p = t[3].p);
|
|
396
|
-
break;
|
|
397
|
-
case "randomBytes":
|
|
398
|
-
s.size = t[0];
|
|
399
|
-
break;
|
|
400
|
-
case "generateKeyPair":
|
|
401
|
-
s.type = t[0], typeof t[1] == "object" && (s.modulusLength = t[1].modulusLength, s.namedCurve = t[1].namedCurve);
|
|
402
|
-
break;
|
|
403
|
-
default:
|
|
404
|
-
s.argsCount = t.length - 1;
|
|
405
|
-
}
|
|
406
|
-
return s;
|
|
407
|
-
})(e, n);
|
|
408
|
-
break;
|
|
409
|
-
case "zlib":
|
|
410
|
-
o = (function(i, t) {
|
|
411
|
-
const s = {};
|
|
412
|
-
return Buffer.isBuffer(t[0]) ? (s.inputType = "Buffer", s.inputSize = t[0].length) : typeof t[0] == "string" ? (s.inputType = "string", s.inputSize = t[0].length) : s.inputType = typeof t[0], t[1] && typeof t[1] == "object" && typeof t[1] != "function" && (s.options = { ...t[1] }), s;
|
|
413
|
-
})(0, n);
|
|
414
|
-
break;
|
|
415
|
-
default:
|
|
416
|
-
return null;
|
|
417
|
-
}
|
|
418
|
-
return a > 0 ? Y(o, a) : o;
|
|
419
|
-
} catch {
|
|
420
|
-
return { error: "Failed to capture arguments", argsCount: n.length - 1 };
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function Z(r, e, n, a) {
|
|
424
|
-
let o;
|
|
425
|
-
try {
|
|
426
|
-
switch (r) {
|
|
427
|
-
case "fs":
|
|
428
|
-
o = (function(i, t) {
|
|
429
|
-
if (!t) return null;
|
|
430
|
-
switch (i) {
|
|
431
|
-
case "readFile":
|
|
432
|
-
return Buffer.isBuffer(t) ? { type: "Buffer", size: t.length } : typeof t == "string" ? { type: "string", size: t.length } : { type: typeof t };
|
|
433
|
-
case "readdir":
|
|
434
|
-
return { count: Array.isArray(t) ? t.length : 0, items: t };
|
|
435
|
-
case "stat":
|
|
436
|
-
case "lstat":
|
|
437
|
-
case "fstat":
|
|
438
|
-
return { size: t.size, mode: t.mode, isFile: t.isFile(), isDirectory: t.isDirectory() };
|
|
439
|
-
case "open":
|
|
440
|
-
return { fd: t };
|
|
441
|
-
case "read":
|
|
442
|
-
return { bytesRead: t };
|
|
443
|
-
case "write":
|
|
444
|
-
return { bytesWritten: t };
|
|
445
|
-
default:
|
|
446
|
-
return t;
|
|
447
|
-
}
|
|
448
|
-
})(e, n);
|
|
449
|
-
break;
|
|
450
|
-
case "dns":
|
|
451
|
-
o = (function(i, t) {
|
|
452
|
-
if (!t) return null;
|
|
453
|
-
switch (i) {
|
|
454
|
-
case "lookup":
|
|
455
|
-
return Array.isArray(t) ? { count: t.length, addresses: t } : t;
|
|
456
|
-
case "resolve":
|
|
457
|
-
case "resolve4":
|
|
458
|
-
case "resolve6":
|
|
459
|
-
case "resolveAny":
|
|
460
|
-
case "resolveMx":
|
|
461
|
-
case "resolveNs":
|
|
462
|
-
case "resolveTxt":
|
|
463
|
-
return { count: Array.isArray(t) ? t.length : 0, records: t };
|
|
464
|
-
case "reverse":
|
|
465
|
-
return { hostnames: t };
|
|
466
|
-
default:
|
|
467
|
-
return t;
|
|
468
|
-
}
|
|
469
|
-
})(e, n);
|
|
470
|
-
break;
|
|
471
|
-
case "crypto":
|
|
472
|
-
o = (function(i, t) {
|
|
473
|
-
if (!t) return null;
|
|
474
|
-
switch (i) {
|
|
475
|
-
case "pbkdf2":
|
|
476
|
-
case "scrypt":
|
|
477
|
-
case "randomBytes":
|
|
478
|
-
return Buffer.isBuffer(t) ? { type: "Buffer", size: t.length } : { type: typeof t };
|
|
479
|
-
case "generateKeyPair":
|
|
480
|
-
return { hasPublicKey: !!t?.publicKey, hasPrivateKey: !!t?.privateKey };
|
|
481
|
-
default:
|
|
482
|
-
return t;
|
|
483
|
-
}
|
|
484
|
-
})(e, n);
|
|
485
|
-
break;
|
|
486
|
-
case "zlib":
|
|
487
|
-
o = (function(i, t) {
|
|
488
|
-
return t ? Buffer.isBuffer(t) ? { type: "Buffer", size: t.length } : typeof t == "string" ? { type: "string", size: t.length } : { type: typeof t } : null;
|
|
489
|
-
})(0, n);
|
|
490
|
-
break;
|
|
491
|
-
default:
|
|
492
|
-
return null;
|
|
493
|
-
}
|
|
494
|
-
return a > 0 ? Y(o, a) : o;
|
|
495
|
-
} catch {
|
|
496
|
-
return { error: "Failed to capture result", type: typeof n };
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
function ue(r) {
|
|
500
|
-
return r.operationType === "worker_pool";
|
|
501
|
-
}
|
|
502
|
-
class le extends ie {
|
|
503
|
-
constructor() {
|
|
504
|
-
super(), this.operationName = "CollectFunctionSpans";
|
|
505
|
-
}
|
|
506
|
-
send(e) {
|
|
507
|
-
const n = f().sfDebug;
|
|
508
|
-
n && console.log(`[FunctionSpanTransmitter] Preparing to send ${e.length} function span(s)`);
|
|
509
|
-
for (const a of e) try {
|
|
510
|
-
if (ue(a)) {
|
|
511
|
-
this.sendWorkerPoolSpan(a, n);
|
|
512
|
-
continue;
|
|
513
|
-
}
|
|
514
|
-
const o = a;
|
|
515
|
-
let i;
|
|
516
|
-
if (o.result !== void 0 && o.result !== null) {
|
|
517
|
-
const s = typeof o.result;
|
|
518
|
-
i = JSON.stringify({ type: s, has_value: !0, value: o.result });
|
|
519
|
-
} else i = o.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
|
|
520
|
-
const t = this.getVariables({ library: "JS/TS BACKEND", version: f().version, spanId: o.spanId, parentSpanId: o.parentSpanId, filePath: o.filePath, lineNumber: o.metadata.line, columnNumber: o.metadata.column, functionName: o.functionName, arguments: JSON.stringify(o.args || {}), returnValue: i, startTimeNs: (1e6 * Date.now() - 1e6 * o.duration).toString(), durationNs: (1e6 * o.duration).toString() });
|
|
521
|
-
n && (console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(t, null, 2))), j(this.endpoint, this.operationName, this.getQuery(), t), n && console.log(`[FunctionSpanTransmitter] Queued function span for ${o.functionName}`);
|
|
522
|
-
} catch (o) {
|
|
523
|
-
console.error(`[FunctionSpanTransmitter] Error preparing function span for ${a.functionName}:`, o);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
sendWorkerPoolSpan(e, n) {
|
|
527
|
-
try {
|
|
528
|
-
let a;
|
|
529
|
-
if (e.result !== void 0 && e.result !== null) {
|
|
530
|
-
const i = typeof e.result;
|
|
531
|
-
a = JSON.stringify({ type: i, has_value: !0, value: e.result });
|
|
532
|
-
} 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 o = 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 });
|
|
534
|
-
n && (console.log(`[FunctionSpanTransmitter] Sending worker pool span: ${e.operationName}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(o, null, 2))), j(this.endpoint, "CollectWorkerPoolSpans", this.getWorkerPoolQuery(), o), n && console.log(`[FunctionSpanTransmitter] Queued worker pool span for ${e.operationName}`);
|
|
535
|
-
} catch (a) {
|
|
536
|
-
console.error(`[FunctionSpanTransmitter] Error preparing worker pool span for ${e.operationName}:`, a);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
getWorkerPoolQuery() {
|
|
540
|
-
return `
|
|
541
|
-
mutation CollectWorkerPoolSpans(
|
|
542
|
-
$apiKey: String!,
|
|
543
|
-
$serviceUuid: String!,
|
|
544
|
-
$sessionId: String!,
|
|
545
|
-
$timestampMs: String!,
|
|
546
|
-
$library: String!,
|
|
547
|
-
$version: String!,
|
|
548
|
-
$spanId: String!,
|
|
549
|
-
$operationName: String!,
|
|
550
|
-
$moduleName: String!,
|
|
551
|
-
$methodName: String!,
|
|
552
|
-
$startTimeNs: String!,
|
|
553
|
-
$durationNs: String!,
|
|
554
|
-
$parentSpanId: String,
|
|
555
|
-
$arguments: String,
|
|
556
|
-
$returnValue: String,
|
|
557
|
-
$error: String,
|
|
558
|
-
$pid: Int,
|
|
559
|
-
$threadId: Int
|
|
560
|
-
) {
|
|
561
|
-
collectWorkerPoolSpans(
|
|
562
|
-
apiKey: $apiKey,
|
|
563
|
-
serviceUuid: $serviceUuid,
|
|
564
|
-
sessionId: $sessionId,
|
|
565
|
-
timestampMs: $timestampMs,
|
|
566
|
-
library: $library,
|
|
567
|
-
version: $version,
|
|
568
|
-
spanId: $spanId,
|
|
569
|
-
operationName: $operationName,
|
|
570
|
-
moduleName: $moduleName,
|
|
571
|
-
methodName: $methodName,
|
|
572
|
-
startTimeNs: $startTimeNs,
|
|
573
|
-
durationNs: $durationNs,
|
|
574
|
-
parentSpanId: $parentSpanId,
|
|
575
|
-
arguments: $arguments,
|
|
576
|
-
returnValue: $returnValue,
|
|
577
|
-
error: $error,
|
|
578
|
-
pid: $pid,
|
|
579
|
-
threadId: $threadId
|
|
580
|
-
)
|
|
581
|
-
}
|
|
582
|
-
`;
|
|
583
|
-
}
|
|
584
|
-
getQuery() {
|
|
585
|
-
return `
|
|
586
|
-
${this.queryType} ${this.operationName}(
|
|
587
|
-
$apiKey: String!,
|
|
588
|
-
$serviceUuid: String!,
|
|
589
|
-
$sessionId: String!,
|
|
590
|
-
$timestampMs: String!,
|
|
591
|
-
$parentSpanId: String,
|
|
592
|
-
$library: String!,
|
|
593
|
-
$version: String!,
|
|
594
|
-
$spanId: String!,
|
|
595
|
-
$filePath: String!,
|
|
596
|
-
$lineNumber: Int!,
|
|
597
|
-
$columnNumber: Int!,
|
|
598
|
-
$functionName: String!,
|
|
599
|
-
$arguments: String!,
|
|
600
|
-
$returnValue: String,
|
|
601
|
-
$startTimeNs: String!,
|
|
602
|
-
$durationNs: String!
|
|
603
|
-
) {
|
|
604
|
-
${this.queryName}(
|
|
605
|
-
apiKey: $apiKey,
|
|
606
|
-
serviceUuid: $serviceUuid,
|
|
607
|
-
sessionId: $sessionId,
|
|
608
|
-
timestampMs: $timestampMs,
|
|
609
|
-
parentSpanId: $parentSpanId,
|
|
610
|
-
library: $library,
|
|
611
|
-
version: $version,
|
|
612
|
-
spanId: $spanId,
|
|
613
|
-
filePath: $filePath,
|
|
614
|
-
lineNumber: $lineNumber,
|
|
615
|
-
columnNumber: $columnNumber,
|
|
616
|
-
functionName: $functionName,
|
|
617
|
-
arguments: $arguments,
|
|
618
|
-
returnValue: $returnValue,
|
|
619
|
-
startTimeNs: $startTimeNs,
|
|
620
|
-
durationNs: $durationNs
|
|
621
|
-
)
|
|
622
|
-
}
|
|
623
|
-
`;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
let L = null;
|
|
627
|
-
function $e(r, e, n, a, o) {
|
|
628
|
-
const i = A(), t = i?.sfDebug || !1;
|
|
629
|
-
t && console.log(`[WorkerPool] Capturing ${r}.${e}`);
|
|
630
|
-
const s = V(), u = I.getInstance().getCurrentFunctionSpanId(), m = C();
|
|
631
|
-
t && console.log(`[WorkerPool] Span ID: ${m}, Parent: ${u || "none"}`);
|
|
632
|
-
const p = new re("WorkerPoolOperation"), g = process.hrtime.bigint();
|
|
633
|
-
let d = null;
|
|
634
|
-
s.captureArguments && (d = X(r, e, a, s.argLimitMb));
|
|
635
|
-
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(o, a);
|
|
637
|
-
const y = a[S], T = [...a];
|
|
638
|
-
return T[S] = function(v, ...F) {
|
|
639
|
-
const U = process.hrtime.bigint() - g, K = Number(U) / 1e6;
|
|
640
|
-
y(v, ...F), p.runInAsyncScope(() => {
|
|
641
|
-
t && console.log(`[WorkerPool] ${r}.${e} completed in ${K.toFixed(3)}ms (${U}ns)`);
|
|
642
|
-
let B = null, W = null;
|
|
643
|
-
v ? W = v?.message || String(v) : s.captureReturnValue && F.length > 0 && (B = Z(r, e, F[0], s.returnLimitMb)), w({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: K, durationNs: U.toString(), startTimeNs: g.toString(), args: d, result: B, error: W, spanId: m, parentSpanId: u, pid: process.pid, threadId: R });
|
|
644
|
-
}), p.emitDestroy();
|
|
645
|
-
}, n.apply(o, T);
|
|
646
|
-
}
|
|
647
|
-
function Ee(r, e, n, a, o) {
|
|
648
|
-
const i = A(), t = i?.sfDebug || !1;
|
|
649
|
-
t && console.log(`[WorkerPool] Capturing ${r}.${e} (Promise)`);
|
|
650
|
-
const s = V(), u = I.getInstance().getCurrentFunctionSpanId(), m = C();
|
|
651
|
-
t && console.log(`[WorkerPool] Span ID: ${m}, Parent: ${u || "none"}`);
|
|
652
|
-
const p = process.hrtime.bigint();
|
|
653
|
-
let g = null;
|
|
654
|
-
return s.captureArguments && (g = X(r, e, a, s.argLimitMb)), n.apply(o, a).then((d) => {
|
|
655
|
-
const S = process.hrtime.bigint() - p, y = Number(S) / 1e6;
|
|
656
|
-
t && console.log(`[WorkerPool] ${r}.${e} completed in ${y.toFixed(3)}ms (${S}ns)`);
|
|
657
|
-
let T = null;
|
|
658
|
-
return s.captureReturnValue && (T = Z(r, e, d, s.returnLimitMb)), w({ 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: R }), d;
|
|
659
|
-
}, (d) => {
|
|
660
|
-
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}`), w({ 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: R }), d;
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
function w(r) {
|
|
665
|
-
const e = A(), n = e?.sfDebug || !1;
|
|
666
|
-
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
|
-
⚙️ 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
|
-
const a = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
669
|
-
if (a) try {
|
|
670
|
-
const o = a === "true" || a === "1" ? "funcspans.jsonl" : a, i = Date.now(), t = process.hrtime.bigint(), s = BigInt(r.startTimeNs), u = Number(t - s) / 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
|
-
`;
|
|
672
|
-
ne(o, p, "utf-8");
|
|
673
|
-
} catch (o) {
|
|
674
|
-
console.error("[WorkerPool] Error writing to JSONL file:", o);
|
|
675
|
-
}
|
|
676
|
-
if (n && console.log("[WorkerPool] Sending span to transmitter"), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
|
|
677
|
-
(L || (L = new le()), L).send([r]), n && console.log("[WorkerPool] Span sent successfully");
|
|
678
|
-
} catch (o) {
|
|
679
|
-
n && console.error("[WorkerPool] Error sending span:", o);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
export {
|
|
683
|
-
ie as B,
|
|
684
|
-
I as C,
|
|
685
|
-
ae as D,
|
|
686
|
-
le as F,
|
|
687
|
-
be as a,
|
|
688
|
-
ve as b,
|
|
689
|
-
$e as c,
|
|
690
|
-
he as d,
|
|
691
|
-
ye as e,
|
|
692
|
-
Ne as f,
|
|
693
|
-
f as g,
|
|
694
|
-
Ee as h,
|
|
695
|
-
Te as i,
|
|
696
|
-
me as j,
|
|
697
|
-
A as k,
|
|
698
|
-
Ce as m,
|
|
699
|
-
j as n,
|
|
700
|
-
_e as p,
|
|
701
|
-
Se as r,
|
|
702
|
-
Ie as s,
|
|
703
|
-
Y as t,
|
|
704
|
-
C as v
|
|
705
|
-
};
|