@sailfish-ai/sf-veritas 0.2.21 → 0.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/dist/consoleLocationTransformer-BSSB5msZ.cjs +1 -0
- package/dist/consoleLocationTransformer-DZu_9MDA.js +51 -0
- package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
- package/dist/plugins/funcspanEsbuildPlugin.mjs +20 -16
- package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.mjs +17 -13
- package/dist/plugins/funcspanTscPlugin.cjs +1 -1
- package/dist/plugins/funcspanTscPlugin.mjs +34 -30
- package/dist/plugins/funcspanVitePlugin.cjs +1 -1
- package/dist/plugins/funcspanVitePlugin.mjs +16 -12
- package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.mjs +55 -50
- package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.mjs +1 -1
- package/dist/runtimeConfig-BZ61efqE.js +485 -0
- package/dist/runtimeConfig-CWpFWsmz.cjs +6 -0
- package/dist/sf-veritas.cjs +13 -13
- package/dist/sf-veritas.mjs +206 -176
- package/dist/telemetryWorker.cjs +1 -0
- package/dist/types/dataTransmitter.d.ts +6 -5
- package/dist/types/exceptionTransmitter.d.ts +2 -1
- package/dist/types/networkHopTransmitter.d.ts +2 -1
- package/dist/types/networkRequestTransmitter.d.ts +2 -1
- package/dist/types/plugins/consoleLocationTransformer.d.ts +37 -0
- package/dist/types/requestUtils.d.ts +17 -6
- package/dist/types/sourceLocation.d.ts +19 -19
- package/dist/types/telemetryWorker.d.ts +1 -0
- package/dist/worker-pool-capture.cjs +1 -1
- package/dist/worker-pool-capture.mjs +1 -1
- package/dist/workerPoolSpanCapture-Bg5av6gn.cjs +83 -0
- package/dist/{workerPoolSpanCapture-DVYmzgbN.js → workerPoolSpanCapture-BjdZn3LE.js} +222 -168
- package/package.json +1 -1
- package/dist/runtimeConfig-CB57auSb.js +0 -444
- package/dist/runtimeConfig-sm_7bnKx.cjs +0 -9
- package/dist/workerPoolSpanCapture-DFnbcpkU.cjs +0 -83
package/dist/sf-veritas.mjs
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
var he = Object.defineProperty;
|
|
2
2
|
var me = (r, t, e) => t in r ? he(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var y = (r, t, e) => me(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { g, C as V, D as ye, v as
|
|
5
|
-
import { r as
|
|
6
|
-
import { B as
|
|
7
|
-
import { h as
|
|
8
|
-
import { a as
|
|
9
|
-
import { f as
|
|
10
|
-
import { createRequire as
|
|
4
|
+
import { g as f, C as V, D as ye, v as K, b as H, c as Se, d as ve, a as de } from "./contextManager-RxrMXs5c.js";
|
|
5
|
+
import { r as $t } from "./contextManager-RxrMXs5c.js";
|
|
6
|
+
import { B as R, n as w, f as Ie, g as W, p as j, a as le, b as $e, m as C, c as A, i as Y, d as _e, e as k, r as be, t as M, F as Fe } from "./workerPoolSpanCapture-BjdZn3LE.js";
|
|
7
|
+
import { h as bt, s as Ft } from "./workerPoolSpanCapture-BjdZn3LE.js";
|
|
8
|
+
import { a as Ne, C as De, i as b, b as we, c as ue, d as Pe, e as Ee } from "./runtimeConfig-BZ61efqE.js";
|
|
9
|
+
import { f as Dt, g as wt, s as Pt } from "./runtimeConfig-BZ61efqE.js";
|
|
10
|
+
import { createRequire as Re } from "node:module";
|
|
11
11
|
import * as Te from "fs";
|
|
12
|
-
import { readFileSync as Ce, appendFileSync as
|
|
12
|
+
import { readFileSync as Ce, appendFileSync as ke } from "fs";
|
|
13
13
|
import E from "http";
|
|
14
|
-
import
|
|
14
|
+
import U from "https";
|
|
15
15
|
import { s as Ue } from "./source-map-Cr6YkjTd.js";
|
|
16
16
|
import * as Z from "fs/promises";
|
|
17
17
|
import * as D from "path";
|
|
18
18
|
import { glob as Oe } from "glob";
|
|
19
|
-
import { threadId as
|
|
20
|
-
import { s as
|
|
21
|
-
class
|
|
19
|
+
import { threadId as O } from "worker_threads";
|
|
20
|
+
import { s as Rt, t as Tt, a as Ct } from "./funcSpanTransformer-S_WeAt_m.js";
|
|
21
|
+
class T extends R {
|
|
22
22
|
constructor() {
|
|
23
23
|
super(), this.setOperationName("IdentifyServiceDetails");
|
|
24
24
|
}
|
|
25
25
|
async doSend(t) {
|
|
26
|
-
if (!
|
|
26
|
+
if (!f().serviceIdentificationReceived) try {
|
|
27
27
|
this.send();
|
|
28
28
|
} catch (e) {
|
|
29
|
-
|
|
29
|
+
f().sfDebug && console.error(" Error during service identification:", e);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
async send() {
|
|
@@ -68,30 +68,36 @@ class C extends T {
|
|
|
68
68
|
serviceRole: $serviceRole,
|
|
69
69
|
)
|
|
70
70
|
}
|
|
71
|
-
`, e =
|
|
71
|
+
`, e = f(), i = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, library: e.packageLibraryType, version: e.version, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, framework: e.framework || void 0, additionalFrameworks: e.additionalFrameworks.length > 0 ? e.additionalFrameworks : void 0, serviceRole: e.serviceRole || void 0 });
|
|
72
72
|
w(this.endpoint, this.operationName, t, i);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
class
|
|
75
|
+
class Le extends R {
|
|
76
76
|
constructor() {
|
|
77
77
|
super();
|
|
78
|
-
y(this, "serviceIdentifier", new
|
|
78
|
+
y(this, "serviceIdentifier", new T());
|
|
79
|
+
y(this, "identifyStarted", !1);
|
|
79
80
|
this.setOperationName("CollectMetadata");
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
this.
|
|
82
|
+
startBackgroundIdentify() {
|
|
83
|
+
if (this.identifyStarted) return;
|
|
84
|
+
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
85
|
+
const e = setInterval(() => {
|
|
86
|
+
f().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
87
|
+
}, 5e3);
|
|
88
|
+
e && typeof e == "object" && "unref" in e && e.unref();
|
|
83
89
|
}
|
|
84
90
|
async doSend(e, i, n, s) {
|
|
85
|
-
this.
|
|
91
|
+
this.startBackgroundIdentify(), this.send(e, i, n, s);
|
|
86
92
|
}
|
|
87
93
|
async send(e, i, n, s) {
|
|
88
94
|
if (!i && !s) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
|
|
89
95
|
let l = [];
|
|
90
96
|
if (!s) {
|
|
91
|
-
const o =
|
|
97
|
+
const o = Ne(i);
|
|
92
98
|
s = o.traitsJson, l = o.excludedFields;
|
|
93
99
|
}
|
|
94
|
-
const a = this.getVariables({ userId: e, traitsJson: s, excludedFields: l, override: n, library:
|
|
100
|
+
const a = this.getVariables({ userId: e, traitsJson: s, excludedFields: l, override: n, library: f().packageLibraryType, version: f().version });
|
|
95
101
|
w(this.endpoint, this.operationName, this.getQuery(), a);
|
|
96
102
|
}
|
|
97
103
|
getQuery() {
|
|
@@ -105,33 +111,39 @@ class ke extends T {
|
|
|
105
111
|
class pe {
|
|
106
112
|
constructor(t) {
|
|
107
113
|
y(this, "metadataTransmitter");
|
|
108
|
-
this.apiKey = t, this.metadataTransmitter = new
|
|
114
|
+
this.apiKey = t, this.metadataTransmitter = new Le();
|
|
109
115
|
}
|
|
110
116
|
identify(t, e, i, n = !1) {
|
|
111
117
|
e || i ? this.addOrUpdateMetadata(t, e, i, n) : this.addOrUpdateMetadata(t, {}, void 0, n);
|
|
112
118
|
}
|
|
113
119
|
addOrUpdateMetadata(t, e = {}, i, n = !1) {
|
|
114
120
|
if (!e && !i) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
|
|
115
|
-
|
|
121
|
+
f().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), f().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", t, e, i), this.metadataTransmitter.doSend(t, e, n, i);
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
|
-
class Q extends
|
|
124
|
+
class Q extends R {
|
|
119
125
|
constructor() {
|
|
120
126
|
super();
|
|
121
|
-
y(this, "serviceIdentifier", new
|
|
127
|
+
y(this, "serviceIdentifier", new T());
|
|
128
|
+
y(this, "identifyStarted", !1);
|
|
122
129
|
}
|
|
123
|
-
|
|
124
|
-
this.
|
|
130
|
+
startBackgroundIdentify() {
|
|
131
|
+
if (this.identifyStarted) return;
|
|
132
|
+
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
133
|
+
const e = setInterval(() => {
|
|
134
|
+
f().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
135
|
+
}, 5e3);
|
|
136
|
+
e && typeof e == "object" && "unref" in e && e.unref();
|
|
125
137
|
}
|
|
126
138
|
async doSend(e) {
|
|
127
|
-
this.
|
|
139
|
+
this.startBackgroundIdentify(), this.send(e);
|
|
128
140
|
}
|
|
129
141
|
async send(e) {
|
|
130
142
|
try {
|
|
131
143
|
const i = Array.isArray(e) ? e : [e, "default", null, null], n = this.getVariables({ contents: i[0], level: i[1], sourceFile: i[2] || void 0, sourceLine: i[3] || void 0 });
|
|
132
144
|
w(this.endpoint, this.operationName, this.getQuery(), n);
|
|
133
145
|
} catch (i) {
|
|
134
|
-
|
|
146
|
+
f().sfDebug && console.error("🚨 Error in send():", i);
|
|
135
147
|
}
|
|
136
148
|
}
|
|
137
149
|
getQuery() {
|
|
@@ -162,11 +174,12 @@ class Q extends T {
|
|
|
162
174
|
`;
|
|
163
175
|
}
|
|
164
176
|
}
|
|
165
|
-
class
|
|
177
|
+
class Ae extends R {
|
|
166
178
|
constructor() {
|
|
167
179
|
super();
|
|
168
|
-
y(this, "serviceIdentifier", new
|
|
180
|
+
y(this, "serviceIdentifier", new T());
|
|
169
181
|
y(this, "supplementalFields", {});
|
|
182
|
+
y(this, "identifyStarted", !1);
|
|
170
183
|
this.setOperationName("CollectExceptions");
|
|
171
184
|
}
|
|
172
185
|
setSupplementalFields(e) {
|
|
@@ -176,15 +189,20 @@ class Le extends T {
|
|
|
176
189
|
const { isFromLocalService: e } = this.supplementalFields, i = {};
|
|
177
190
|
return e !== void 0 && (i.isFromLocalService = e), i;
|
|
178
191
|
}
|
|
179
|
-
|
|
180
|
-
this.
|
|
192
|
+
startBackgroundIdentify() {
|
|
193
|
+
if (this.identifyStarted) return;
|
|
194
|
+
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
195
|
+
const e = setInterval(() => {
|
|
196
|
+
f().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
197
|
+
}, 5e3);
|
|
198
|
+
e && typeof e == "object" && "unref" in e && e.unref();
|
|
181
199
|
}
|
|
182
200
|
async doSend(e, i) {
|
|
183
|
-
this.
|
|
201
|
+
this.startBackgroundIdentify(), this.send(e, i);
|
|
184
202
|
}
|
|
185
203
|
async send(e, i) {
|
|
186
|
-
|
|
187
|
-
const n = JSON.stringify(
|
|
204
|
+
f().sfDebug && console.log(" SENDING EXCEPTION...");
|
|
205
|
+
const n = JSON.stringify(De.encode(i)), s = this.normalizedSupplementalForGraphQL(), l = this.getVariables({ exceptionMessage: e, traceJson: n, reentrancyGuardPreactive: !1, library: f().packageLibraryType, version: f().version, ...s });
|
|
188
206
|
w(this.endpoint, this.operationName, this.getQuery(), l);
|
|
189
207
|
}
|
|
190
208
|
getQuery() {
|
|
@@ -221,17 +239,17 @@ class Le extends T {
|
|
|
221
239
|
}
|
|
222
240
|
const ee = "getting request source code";
|
|
223
241
|
var q = ((r) => (r.UNKNOWN = "unknown", r.ANONYMOUS = "anonymous", r.NOT_CAPTURED = "not captured", r))(q || {});
|
|
224
|
-
const te = "http:",
|
|
242
|
+
const te = "http:", qe = Re(import.meta.url);
|
|
225
243
|
let ne = !1;
|
|
226
|
-
function
|
|
227
|
-
const r =
|
|
244
|
+
function He() {
|
|
245
|
+
const r = f().sfDebug;
|
|
228
246
|
if (ne) return void (r && b("[patchNodeHttpInbound] Already installed, skipping."));
|
|
229
247
|
let t;
|
|
230
248
|
ne = !0;
|
|
231
249
|
try {
|
|
232
|
-
t =
|
|
250
|
+
t = qe("node:http"), r && b("[patchNodeHttpInbound] node:http required successfully.");
|
|
233
251
|
} catch (n) {
|
|
234
|
-
return void
|
|
252
|
+
return void we("Failed to require node:http:", n);
|
|
235
253
|
}
|
|
236
254
|
if (!t?.Server?.prototype) return void (r && b("[patchNodeHttpInbound] http.Server.prototype not found."));
|
|
237
255
|
const e = t.Server.prototype, i = e.emit;
|
|
@@ -246,8 +264,8 @@ function qe() {
|
|
|
246
264
|
r && (b("[patchNodeHttpInbound] Intercepted request event."), b("[patchNodeHttpInbound] Inbound headers:", o), b("[patchNodeHttpInbound] Trace header:", d), b("[patchNodeHttpInbound] FuncSpan override header:", p));
|
|
247
265
|
const c = V.getInstance();
|
|
248
266
|
c.setTraceId(d);
|
|
249
|
-
const
|
|
250
|
-
r && b("[patchNodeHttpInbound] Context traceId set:",
|
|
267
|
+
const g = c.getTraceId();
|
|
268
|
+
r && b("[patchNodeHttpInbound] Context traceId set:", g);
|
|
251
269
|
const m = () => c.runWith({ inboundHeaders: o, ...d ? { traceId: d } : {} }, () => {
|
|
252
270
|
d && c.setTraceId(d), r && b("[patchNodeHttpInbound] Running request handler in context.");
|
|
253
271
|
const u = () => {
|
|
@@ -263,12 +281,12 @@ function qe() {
|
|
|
263
281
|
}
|
|
264
282
|
}) : r && b("[patchNodeHttpInbound] Already patched, skipping.");
|
|
265
283
|
}
|
|
266
|
-
class
|
|
284
|
+
class Me extends Q {
|
|
267
285
|
constructor() {
|
|
268
286
|
super(), this.setOperationName("DomainsToNotPassHeaderTo");
|
|
269
287
|
}
|
|
270
288
|
async doSend(t) {
|
|
271
|
-
this.
|
|
289
|
+
this.send(t);
|
|
272
290
|
}
|
|
273
291
|
async send(t) {
|
|
274
292
|
const e = `
|
|
@@ -287,17 +305,23 @@ class He extends Q {
|
|
|
287
305
|
w(this.endpoint, this.operationName, e, i);
|
|
288
306
|
}
|
|
289
307
|
}
|
|
290
|
-
class
|
|
308
|
+
class xe extends R {
|
|
291
309
|
constructor() {
|
|
292
310
|
super();
|
|
293
|
-
y(this, "serviceIdentifier", new
|
|
311
|
+
y(this, "serviceIdentifier", new T());
|
|
312
|
+
y(this, "identifyStarted", !1);
|
|
294
313
|
this.setOperationName("CollectNetworkHops");
|
|
295
314
|
}
|
|
296
|
-
|
|
297
|
-
this.
|
|
315
|
+
startBackgroundIdentify() {
|
|
316
|
+
if (this.identifyStarted) return;
|
|
317
|
+
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
318
|
+
const e = setInterval(() => {
|
|
319
|
+
f().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
320
|
+
}, 5e3);
|
|
321
|
+
e && typeof e == "object" && "unref" in e && e.unref();
|
|
298
322
|
}
|
|
299
323
|
async doSend(e) {
|
|
300
|
-
this.
|
|
324
|
+
this.startBackgroundIdentify(), this.send(e);
|
|
301
325
|
}
|
|
302
326
|
async send(e) {
|
|
303
327
|
const { name: i, column: n, line: s, entrypoint: l, retryWithoutTraceId: a } = e, o = this.getVariables({ name: i, column: n, line: s, entrypoint: l, retryWithoutTraceId: a });
|
|
@@ -331,17 +355,23 @@ class Me extends T {
|
|
|
331
355
|
`;
|
|
332
356
|
}
|
|
333
357
|
}
|
|
334
|
-
class
|
|
358
|
+
class Be extends R {
|
|
335
359
|
constructor() {
|
|
336
360
|
super();
|
|
337
|
-
y(this, "serviceIdentifier", new
|
|
361
|
+
y(this, "serviceIdentifier", new T());
|
|
362
|
+
y(this, "identifyStarted", !1);
|
|
338
363
|
this.setOperationName("CollectNetworkRequest");
|
|
339
364
|
}
|
|
340
|
-
|
|
341
|
-
this.
|
|
365
|
+
startBackgroundIdentify() {
|
|
366
|
+
if (this.identifyStarted) return;
|
|
367
|
+
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
368
|
+
const e = setInterval(() => {
|
|
369
|
+
f().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
370
|
+
}, 5e3);
|
|
371
|
+
e && typeof e == "object" && "unref" in e && e.unref();
|
|
342
372
|
}
|
|
343
373
|
async doSend(e) {
|
|
344
|
-
this.
|
|
374
|
+
this.startBackgroundIdentify(), this.send(e);
|
|
345
375
|
}
|
|
346
376
|
getQuery() {
|
|
347
377
|
return `
|
|
@@ -368,7 +398,7 @@ class Ge {
|
|
|
368
398
|
y(this, "contextManager");
|
|
369
399
|
this.contextManager = V.getInstance(), t?.forEach((e) => {
|
|
370
400
|
typeof e == "string" && e.trim() && this.contextManager.getExcludedDomains().add(e);
|
|
371
|
-
}),
|
|
401
|
+
}), f().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
|
|
372
402
|
}
|
|
373
403
|
extractIdsFromTraceHeader(t, e = this.HEADER_TRACING) {
|
|
374
404
|
let i;
|
|
@@ -399,12 +429,12 @@ class Ge {
|
|
|
399
429
|
let a = (await new Ue.SourceMapConsumer(l)).originalPositionFor({ line: e, column: i });
|
|
400
430
|
a.source && (n = a);
|
|
401
431
|
} catch (l) {
|
|
402
|
-
|
|
432
|
+
f().sfDebug && console.error(`Could not read/parse map file at ${s}:`, l);
|
|
403
433
|
}
|
|
404
434
|
return { originalPos: n };
|
|
405
435
|
}
|
|
406
436
|
captureFirstUserLines(t, e = 10, i = !1) {
|
|
407
|
-
const n =
|
|
437
|
+
const n = f().sfDebug ? 10 : e, s = Error.stackTraceLimit;
|
|
408
438
|
Error.stackTraceLimit = Math.max(s, n);
|
|
409
439
|
const l = new Error(ee);
|
|
410
440
|
ee in Error && Error.captureStackTrace(l, this.captureFirstUserLines);
|
|
@@ -417,13 +447,13 @@ class Ge {
|
|
|
417
447
|
for (const p of d) {
|
|
418
448
|
const c = this.parseStackFrame(p);
|
|
419
449
|
c ? (async () => {
|
|
420
|
-
const { originalPos:
|
|
421
|
-
if (
|
|
422
|
-
|
|
423
|
-
const m = { line:
|
|
450
|
+
const { originalPos: g } = await this.getOriginalPosition(c.filePath, c.line, c.column);
|
|
451
|
+
if (g) {
|
|
452
|
+
f().sfDebug && console.log("[RequestInterceptor] First user code line:", g);
|
|
453
|
+
const m = { line: g.line?.toString() || q.UNKNOWN, column: g.column?.toString() || q.NOT_CAPTURED, name: g.name || q.NOT_CAPTURED, entrypoint: g.source, retryWithoutTraceId: i };
|
|
424
454
|
t.doSend(m);
|
|
425
455
|
}
|
|
426
|
-
})() :
|
|
456
|
+
})() : f().sfDebug && console.error("Could not parse stack line:", p);
|
|
427
457
|
}
|
|
428
458
|
}
|
|
429
459
|
addReentrancyGuardHeaders(t) {
|
|
@@ -434,16 +464,16 @@ class Ge {
|
|
|
434
464
|
}
|
|
435
465
|
addTracingHeaders(t, e) {
|
|
436
466
|
const i = new URL(e).hostname, n = this.shouldPropagateHeaders(i);
|
|
437
|
-
return n ? this.addTracingHeader(t, e) :
|
|
467
|
+
return n ? this.addTracingHeader(t, e) : f().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${i}`), n;
|
|
438
468
|
}
|
|
439
469
|
addTracingHeader(t, e) {
|
|
440
|
-
const i =
|
|
470
|
+
const i = W();
|
|
441
471
|
if (i) {
|
|
442
472
|
const a = j(i);
|
|
443
|
-
if (a && a.sample_rate === 0) return void (
|
|
473
|
+
if (a && a.sample_rate === 0) return void (f().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`));
|
|
444
474
|
}
|
|
445
|
-
const n = this.contextManager.getOrSetSfTraceId(), s = this.contextManager.getOrSetPageVisitUUID(), l =
|
|
446
|
-
t.set(this.HEADER_TRACING, `${n}/${s}/${l}`),
|
|
475
|
+
const n = this.contextManager.getOrSetSfTraceId(), s = this.contextManager.getOrSetPageVisitUUID(), l = K();
|
|
476
|
+
t.set(this.HEADER_TRACING, `${n}/${s}/${l}`), f().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
|
|
447
477
|
}
|
|
448
478
|
patchFetch(t, e) {
|
|
449
479
|
const i = globalThis.fetch;
|
|
@@ -455,15 +485,15 @@ class Ge {
|
|
|
455
485
|
let o;
|
|
456
486
|
typeof n == "string" || n instanceof URL ? o = n.toString() : n instanceof Request ? (o = n.url, n.headers.forEach((u, h) => {
|
|
457
487
|
l.set(h, u);
|
|
458
|
-
})) :
|
|
459
|
-
const d = new URL(o).hostname, p = new Headers(l), c = this.addTracingHeaders(l, o),
|
|
488
|
+
})) : f().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), f().sfDebug && console.log("[RequestInterceptor] Fetching request to:", o);
|
|
489
|
+
const d = new URL(o).hostname, p = new Headers(l), c = this.addTracingHeaders(l, o), g = { ...s, headers: l };
|
|
460
490
|
let m;
|
|
461
491
|
try {
|
|
462
492
|
let u = !1;
|
|
463
|
-
this.addTracingHeaders(p, o), m = await i(o,
|
|
493
|
+
this.addTracingHeaders(p, o), m = await i(o, g), c && x.includes(m.status) ? (m = await i(o, { ...s, headers: p }), u = !0, this.captureFirstUserLines(t, 10, u)) : this.contextManager.addSupportedDomains(d);
|
|
464
494
|
const h = Date.now();
|
|
465
|
-
|
|
466
|
-
const { sessionId: v, pageVisitId: I, requestId: _ } = this.extractIdsFromTraceHeader(l), S =
|
|
495
|
+
f().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${o}, Status: ${m.status}, Duration: ${h - a}ms`);
|
|
496
|
+
const { sessionId: v, pageVisitId: I, requestId: _ } = this.extractIdsFromTraceHeader(l), S = f(), F = { apiKey: S.apiKey, requestId: _, pageVisitId: I, recordingSessionId: v, serviceUuid: S.serviceUUID, timestampStart: a.toString(), timestampEnd: h.toString(), responseCode: m.status, success: !0, error: null, url: o, method: g.method || "GET", retryWithoutTraceId: u, parentSpanId: H() };
|
|
467
497
|
if (S.captureRequestHeaders) {
|
|
468
498
|
const $ = {};
|
|
469
499
|
l.forEach((N, P) => {
|
|
@@ -489,9 +519,9 @@ class Ge {
|
|
|
489
519
|
return e.doSend(F), m;
|
|
490
520
|
} catch (u) {
|
|
491
521
|
const h = Date.now();
|
|
492
|
-
|
|
522
|
+
f().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${o}, Error: ${u}, Duration: ${h - a}ms`);
|
|
493
523
|
}
|
|
494
|
-
} :
|
|
524
|
+
} : f().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
|
|
495
525
|
}
|
|
496
526
|
setHeader(t, e, i) {
|
|
497
527
|
t instanceof Headers ? t.set(e, i) : t[e] = i;
|
|
@@ -499,69 +529,69 @@ class Ge {
|
|
|
499
529
|
addTracingHeadersToPlainObject(t, e) {
|
|
500
530
|
const i = new URL(e).hostname, n = this.shouldPropagateHeaders(i);
|
|
501
531
|
if (n) {
|
|
502
|
-
const s =
|
|
532
|
+
const s = W();
|
|
503
533
|
if (s) {
|
|
504
534
|
const d = j(s);
|
|
505
|
-
if (d && d.sample_rate === 0) return
|
|
535
|
+
if (d && d.sample_rate === 0) return f().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`), !1;
|
|
506
536
|
}
|
|
507
|
-
const l = this.contextManager.getOrSetSfTraceId(), a = this.contextManager.getOrSetPageVisitUUID(), o =
|
|
508
|
-
t[this.HEADER_TRACING] = `${l}/${a}/${o}`,
|
|
509
|
-
} else
|
|
537
|
+
const l = this.contextManager.getOrSetSfTraceId(), a = this.contextManager.getOrSetPageVisitUUID(), o = K();
|
|
538
|
+
t[this.HEADER_TRACING] = `${l}/${a}/${o}`, f().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
|
|
539
|
+
} else f().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${i}`);
|
|
510
540
|
return n;
|
|
511
541
|
}
|
|
512
542
|
patchHttp(t, e) {
|
|
513
|
-
if (
|
|
514
|
-
const i = E.request.bind(E), n =
|
|
515
|
-
let
|
|
543
|
+
if (f().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !E || typeof E.request != "function") return void (f().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
|
|
544
|
+
const i = E.request.bind(E), n = U.request.bind(U), s = (o, d, p, c = te) => {
|
|
545
|
+
let g, m;
|
|
516
546
|
if (typeof o == "string" || o instanceof URL) {
|
|
517
547
|
const u = typeof o == "string" ? new URL(o) : o;
|
|
518
|
-
|
|
519
|
-
} else
|
|
520
|
-
return
|
|
548
|
+
g = { ...typeof d == "object" && d !== null ? d : {}, protocol: u.protocol || c, hostname: u.hostname, port: u.port || void 0, path: u.pathname + u.search }, m = typeof d == "function" ? d : p;
|
|
549
|
+
} else g = { ...o }, g.protocol || (g.protocol = c), m = typeof d == "function" ? d : void 0;
|
|
550
|
+
return g.headers || (g.headers = {}), [g, m];
|
|
521
551
|
}, l = (o, d, p) => {
|
|
522
|
-
const [c,
|
|
552
|
+
const [c, g] = s(o, d, p, te);
|
|
523
553
|
try {
|
|
524
554
|
const u = `${c.protocol}//${c.hostname}`;
|
|
525
555
|
this.addTracingHeadersToPlainObject(c.headers, u), this.captureFirstUserLines(t);
|
|
526
556
|
} catch (u) {
|
|
527
|
-
|
|
557
|
+
f().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", u);
|
|
528
558
|
}
|
|
529
559
|
let m = !1;
|
|
530
560
|
return i(c, (u) => {
|
|
531
561
|
const h = `${c.protocol}//${c.hostname}`;
|
|
532
562
|
if (this.shouldPropagateHeaders(new URL(h).hostname) && x.includes(u.statusCode || 0)) {
|
|
533
563
|
const S = { ...c, headers: { ...c.headers } };
|
|
534
|
-
delete S.headers[this.HEADER_TRACING], i(S,
|
|
564
|
+
delete S.headers[this.HEADER_TRACING], i(S, g), m = !0, this.captureFirstUserLines(t, 10, m);
|
|
535
565
|
}
|
|
536
566
|
const { sessionId: v, pageVisitId: I, requestId: _ } = this.extractIdsFromTraceHeader(c.headers);
|
|
537
|
-
e.doSend({ apiKey:
|
|
567
|
+
e.doSend({ apiKey: f().apiKey, requestId: _, pageVisitId: I, recordingSessionId: v, serviceUuid: f().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: u.statusCode || 0, success: !!u.statusCode && u.statusCode < 400, error: null, url: h, method: c.method || "GET", retryWithoutTraceId: m, parentSpanId: H() }), g?.(u);
|
|
538
568
|
});
|
|
539
569
|
}, a = (o, d, p) => {
|
|
540
|
-
const [c,
|
|
570
|
+
const [c, g] = s(o, d, p, "https:");
|
|
541
571
|
try {
|
|
542
572
|
const u = `${c.protocol}//${c.hostname}`;
|
|
543
573
|
this.addTracingHeadersToPlainObject(c.headers, u), this.captureFirstUserLines(t);
|
|
544
574
|
} catch (u) {
|
|
545
|
-
|
|
575
|
+
f().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", u);
|
|
546
576
|
}
|
|
547
577
|
let m = !1;
|
|
548
578
|
return n(c, (u) => {
|
|
549
579
|
const h = `${c.protocol}//${c.hostname}`;
|
|
550
580
|
if (this.shouldPropagateHeaders(new URL(h).hostname) && x.includes(u.statusCode || 0)) {
|
|
551
581
|
const S = { ...c, headers: { ...c.headers } };
|
|
552
|
-
delete S.headers[this.HEADER_TRACING], n(S,
|
|
582
|
+
delete S.headers[this.HEADER_TRACING], n(S, g), m = !0, this.captureFirstUserLines(t, 10, m);
|
|
553
583
|
}
|
|
554
584
|
const { sessionId: v, pageVisitId: I, requestId: _ } = this.extractIdsFromTraceHeader(c.headers);
|
|
555
|
-
e.doSend({ apiKey:
|
|
585
|
+
e.doSend({ apiKey: f().apiKey, requestId: _, pageVisitId: I, recordingSessionId: v, serviceUuid: f().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: u.statusCode || 0, success: !!u.statusCode && u.statusCode < 400, error: null, url: h, method: c.method || "GET", retryWithoutTraceId: m, parentSpanId: H() }), g?.(u);
|
|
556
586
|
});
|
|
557
587
|
};
|
|
558
|
-
E.request = l,
|
|
588
|
+
E.request = l, U.request = a, E.get = (o, d, p) => {
|
|
559
589
|
const c = l(o, d, p);
|
|
560
590
|
return c.end(), c;
|
|
561
|
-
},
|
|
591
|
+
}, U.get = (o, d, p) => {
|
|
562
592
|
const c = a(o, d, p);
|
|
563
593
|
return c.end(), c;
|
|
564
|
-
},
|
|
594
|
+
}, f().sfDebug && console.log("✅ HTTP and HTTPS request/get methods patched globally.");
|
|
565
595
|
}
|
|
566
596
|
tryPatch(t, e) {
|
|
567
597
|
try {
|
|
@@ -578,7 +608,7 @@ class Ke extends Q {
|
|
|
578
608
|
super(), this.setOperationName("UpdateServiceDetails");
|
|
579
609
|
}
|
|
580
610
|
async doSend() {
|
|
581
|
-
this.
|
|
611
|
+
this.send();
|
|
582
612
|
}
|
|
583
613
|
async send() {
|
|
584
614
|
const t = `
|
|
@@ -623,7 +653,7 @@ class Ke extends Q {
|
|
|
623
653
|
serviceRole: $serviceRole,
|
|
624
654
|
)
|
|
625
655
|
}
|
|
626
|
-
`, e =
|
|
656
|
+
`, e = f(), i = this.getVariables({ serviceIdentifier: e.serviceIdentifier, serviceVersion: e.serviceVersion, serviceAdditionalMetadata: e.serviceAdditionalMetadata, gitSha: e.gitSha || "", gitOrg: e.gitOrg || void 0, gitRepo: e.gitRepo || void 0, gitProvider: e.gitProvider || void 0, serviceDisplayName: e.serviceDisplayName || void 0, infrastructureType: e.infrastructureType || void 0, infrastructureDetails: e.infrastructureDetails || void 0, setupInterceptorsFile: e.setupInterceptorsFile || void 0, setupInterceptorsLine: e.setupInterceptorsLine || void 0, framework: e.framework || void 0, additionalFrameworks: e.additionalFrameworks?.length > 0 ? e.additionalFrameworks : void 0, serviceRole: e.serviceRole || void 0 });
|
|
627
657
|
w(this.endpoint, this.operationName, t, i);
|
|
628
658
|
}
|
|
629
659
|
}
|
|
@@ -653,7 +683,7 @@ class We {
|
|
|
653
683
|
const o = this.functionConfigs.get(s);
|
|
654
684
|
o && (a = o.get(e) || {});
|
|
655
685
|
}
|
|
656
|
-
return
|
|
686
|
+
return C(i, n, l, a);
|
|
657
687
|
}
|
|
658
688
|
hasRuntimeMode() {
|
|
659
689
|
return this.runtimeModeEnabled;
|
|
@@ -697,7 +727,7 @@ class We {
|
|
|
697
727
|
const l = D.join(t, n), a = await Oe(l, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
|
|
698
728
|
this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${n}' matched ${a.length} files`);
|
|
699
729
|
for (const o of a) {
|
|
700
|
-
const d = D.normalize(o), p =
|
|
730
|
+
const d = D.normalize(o), p = C(i, s);
|
|
701
731
|
this.fileConfigs.set(d, p), this.debug && a.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${o}`);
|
|
702
732
|
}
|
|
703
733
|
} catch (l) {
|
|
@@ -713,7 +743,7 @@ class We {
|
|
|
713
743
|
}
|
|
714
744
|
const [a, o] = l, d = D.normalize(D.join(t, a));
|
|
715
745
|
this.functionConfigs.has(d) || this.functionConfigs.set(d, /* @__PURE__ */ new Map());
|
|
716
|
-
const p = this.functionConfigs.get(d), c =
|
|
746
|
+
const p = this.functionConfigs.get(d), c = C(i, s);
|
|
717
747
|
p.set(o, c), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${d}::${o}`);
|
|
718
748
|
}
|
|
719
749
|
}
|
|
@@ -726,29 +756,29 @@ class We {
|
|
|
726
756
|
const n = this.directoryConfigs.get(e);
|
|
727
757
|
n && i.unshift(n), e = D.dirname(e);
|
|
728
758
|
}
|
|
729
|
-
return i.reduce((n, s) =>
|
|
759
|
+
return i.reduce((n, s) => C(n, s), {});
|
|
730
760
|
}
|
|
731
761
|
}
|
|
732
|
-
const
|
|
733
|
-
function
|
|
734
|
-
return globalThis[
|
|
762
|
+
const fe = "__sf_globalConfigLoader";
|
|
763
|
+
function ge() {
|
|
764
|
+
return globalThis[fe] ?? null;
|
|
735
765
|
}
|
|
736
|
-
async function
|
|
766
|
+
async function je(r, t) {
|
|
737
767
|
const e = new We(r, t);
|
|
738
768
|
(function(i) {
|
|
739
|
-
globalThis[
|
|
769
|
+
globalThis[fe] = i;
|
|
740
770
|
})(e), await e.loadAllConfigs();
|
|
741
771
|
}
|
|
742
|
-
function
|
|
743
|
-
const e =
|
|
772
|
+
function ze(r, t) {
|
|
773
|
+
const e = ge();
|
|
744
774
|
return e ? e.getConfig(r, t) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using default config (disabled)"), le());
|
|
745
775
|
}
|
|
746
|
-
function
|
|
747
|
-
return
|
|
776
|
+
function Je() {
|
|
777
|
+
return ge() !== null;
|
|
748
778
|
}
|
|
749
|
-
const
|
|
779
|
+
const Ve = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], re = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], Qe = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Xe = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
|
|
750
780
|
let ie = !1;
|
|
751
|
-
function
|
|
781
|
+
function Ye(r) {
|
|
752
782
|
if (typeof r != "string") return !1;
|
|
753
783
|
const t = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
754
784
|
if (t && r.includes(t)) return !0;
|
|
@@ -767,7 +797,7 @@ function oe(r) {
|
|
|
767
797
|
}
|
|
768
798
|
return !1;
|
|
769
799
|
}
|
|
770
|
-
function
|
|
800
|
+
function Ze() {
|
|
771
801
|
if (!se) try {
|
|
772
802
|
let r;
|
|
773
803
|
if (typeof require > "u") return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Skipping dns patching in pure ESM environment (require unavailable)"));
|
|
@@ -802,30 +832,30 @@ function Ye() {
|
|
|
802
832
|
}
|
|
803
833
|
}
|
|
804
834
|
let ae = !1, ce = !1, z = !1;
|
|
805
|
-
function
|
|
835
|
+
function et() {
|
|
806
836
|
if (z) return;
|
|
807
837
|
const r = process.env.SF_DEBUG === "true";
|
|
808
|
-
r && console.log("[WorkerPool] Initializing worker pool patching..."),
|
|
838
|
+
r && console.log("[WorkerPool] Initializing worker pool patching..."), k("fs") && (r && console.log("[WorkerPool] Patching fs module..."), (function() {
|
|
809
839
|
if (!ie) try {
|
|
810
840
|
const t = require("node:fs");
|
|
811
841
|
if (t.__sf_worker_pool_patched__) return;
|
|
812
842
|
Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
813
|
-
for (const e of
|
|
843
|
+
for (const e of Ve) if (typeof t[e] == "function") {
|
|
814
844
|
const i = t[e];
|
|
815
845
|
t[e] = function(...n) {
|
|
816
|
-
return
|
|
846
|
+
return Ye(n[0]) ? i.apply(this, n) : typeof n[n.length - 1] == "function" ? A("fs", e, i, n, this) : i.apply(this, n);
|
|
817
847
|
}, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
|
|
818
848
|
}
|
|
819
849
|
ie = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
|
|
820
850
|
} catch (t) {
|
|
821
851
|
console.error("[WorkerPool] Error patching fs module:", t);
|
|
822
852
|
}
|
|
823
|
-
})()),
|
|
853
|
+
})()), k("dns") && (r && console.log("[WorkerPool] Patching dns module..."), Ze()), k("crypto") && (r && console.log("[WorkerPool] Patching crypto module..."), (function() {
|
|
824
854
|
if (!ae) try {
|
|
825
855
|
const t = require("node:crypto");
|
|
826
856
|
if (t.__sf_worker_pool_patched__) return;
|
|
827
857
|
Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
828
|
-
for (const e of
|
|
858
|
+
for (const e of Qe) if (typeof t[e] == "function") {
|
|
829
859
|
const i = t[e];
|
|
830
860
|
t[e] = function(...n) {
|
|
831
861
|
return typeof n[n.length - 1] == "function" ? A("crypto", e, i, n, this) : i.apply(this, n);
|
|
@@ -835,12 +865,12 @@ function Ze() {
|
|
|
835
865
|
} catch (t) {
|
|
836
866
|
console.error("[WorkerPool] Error patching crypto module:", t);
|
|
837
867
|
}
|
|
838
|
-
})()),
|
|
868
|
+
})()), k("zlib") && (r && console.log("[WorkerPool] Patching zlib module..."), (function() {
|
|
839
869
|
if (!ce) try {
|
|
840
870
|
const t = require("node:zlib");
|
|
841
871
|
if (t.__sf_worker_pool_patched__) return;
|
|
842
872
|
Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
843
|
-
for (const e of
|
|
873
|
+
for (const e of Xe) if (typeof t[e] == "function") {
|
|
844
874
|
const i = t[e];
|
|
845
875
|
t[e] = function(...n) {
|
|
846
876
|
return typeof n[n.length - 1] == "function" ? A("zlib", e, i, n, this) : i.apply(this, n);
|
|
@@ -852,14 +882,14 @@ function Ze() {
|
|
|
852
882
|
}
|
|
853
883
|
})()), z = !0, r && console.log("[WorkerPool] Worker pool patching initialized");
|
|
854
884
|
}
|
|
855
|
-
function
|
|
885
|
+
function tt() {
|
|
856
886
|
return z;
|
|
857
887
|
}
|
|
858
|
-
let J = !1,
|
|
859
|
-
function
|
|
860
|
-
if (
|
|
888
|
+
let J = !1, B = !1;
|
|
889
|
+
function ft(r) {
|
|
890
|
+
if (B) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
|
|
861
891
|
else if (!J) {
|
|
862
|
-
|
|
892
|
+
B = !0, be();
|
|
863
893
|
try {
|
|
864
894
|
let t, e;
|
|
865
895
|
const i = ue(new Error().stack);
|
|
@@ -878,47 +908,47 @@ function pt(r) {
|
|
|
878
908
|
const a = `The required config is not provided: ${JSON.stringify(n)}`;
|
|
879
909
|
throw console.error(a), new Error(a);
|
|
880
910
|
}
|
|
881
|
-
|
|
911
|
+
Je() || je(void 0, n.sfDebug).catch((a) => {
|
|
882
912
|
n.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", a);
|
|
883
|
-
}), process.env.SF_WORKER_POOL_DISABLED === "true" ? n.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") :
|
|
913
|
+
}), process.env.SF_WORKER_POOL_DISABLED === "true" ? n.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : tt() || (et(), n.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
|
|
884
914
|
const s = new Q();
|
|
885
|
-
s.setServiceUUID(n.serviceUUID),
|
|
915
|
+
s.setServiceUUID(n.serviceUUID), Pe(s), (function(a = []) {
|
|
886
916
|
const o = new Ge(a);
|
|
887
|
-
new
|
|
888
|
-
const d = new
|
|
917
|
+
new Me().doSend(o.getExcludedDomains());
|
|
918
|
+
const d = new xe(), p = new Be();
|
|
889
919
|
o.patchFetch(d, p), o.patchHttp(d, p);
|
|
890
920
|
})(n.domainsToNotPropagateHeadersTo);
|
|
891
|
-
const l = new
|
|
892
|
-
l.setServiceUUID(n.serviceUUID),
|
|
921
|
+
const l = new Ae();
|
|
922
|
+
l.setServiceUUID(n.serviceUUID), Ee(l), He(), new Ke().send(), J = !0, n.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
|
|
893
923
|
} finally {
|
|
894
|
-
|
|
924
|
+
B = !1;
|
|
895
925
|
}
|
|
896
926
|
}
|
|
897
927
|
}
|
|
898
928
|
function gt() {
|
|
899
929
|
return J;
|
|
900
930
|
}
|
|
901
|
-
function
|
|
902
|
-
const n =
|
|
931
|
+
function ht(r, t, e, i = !1) {
|
|
932
|
+
const n = f();
|
|
903
933
|
new pe(n.apiKey).identify(r, t, e, i);
|
|
904
934
|
}
|
|
905
|
-
function
|
|
906
|
-
const n =
|
|
935
|
+
function mt(r, t = {}, e, i = !1) {
|
|
936
|
+
const n = f();
|
|
907
937
|
new pe(n.apiKey).addOrUpdateMetadata(r, t, e, i);
|
|
908
938
|
}
|
|
909
|
-
let
|
|
910
|
-
function
|
|
939
|
+
let G = null;
|
|
940
|
+
function yt(r, t, e, i) {
|
|
911
941
|
const n = function(...s) {
|
|
912
942
|
const l = de(), a = l?.sfDebug || !1;
|
|
913
943
|
a && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${e}::${t}`);
|
|
914
944
|
const o = (function(h, v) {
|
|
915
|
-
const I =
|
|
945
|
+
const I = W();
|
|
916
946
|
if (I) {
|
|
917
947
|
const _ = j(I);
|
|
918
948
|
if (_) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${h}::${v}`), _;
|
|
919
949
|
}
|
|
920
950
|
try {
|
|
921
|
-
return
|
|
951
|
+
return ze(h, v);
|
|
922
952
|
} catch {
|
|
923
953
|
return { sample_rate: process.env.SF_FUNCSPAN_SAMPLE_RATE ? parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE) : 1, capture_arguments: !0, capture_return_value: !0, arg_limit_mb: 1, return_limit_mb: 1, enable_sampling: !1, autocapture_all_child_functions: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
|
|
924
954
|
}
|
|
@@ -926,9 +956,9 @@ function mt(r, t, e, i) {
|
|
|
926
956
|
if (a && console.log(`[FuncSpan] Config for ${e}::${t}:`, o), o.enable_sampling && o.sample_rate < 1 && Math.random() > o.sample_rate) return a && console.log(`[FuncSpan] Skipping ${t} due to sampling`), r.apply(this, s);
|
|
927
957
|
if (o.sample_rate === 0) return a && console.log(`[FuncSpan] Skipping ${t} - sample_rate is 0.0`), r.apply(this, s);
|
|
928
958
|
a && console.log(`[FuncSpan] Capturing function span for ${t}`);
|
|
929
|
-
const d = V.getInstance(), p = d.getCurrentFunctionSpanId(), c =
|
|
959
|
+
const d = V.getInstance(), p = d.getCurrentFunctionSpanId(), c = K();
|
|
930
960
|
d.setCurrentFunctionSpanId(c);
|
|
931
|
-
const
|
|
961
|
+
const g = process.hrtime.bigint(), m = Date.now();
|
|
932
962
|
let u = null;
|
|
933
963
|
o.capture_arguments && (u = {}, i.paramNames.forEach((h, v) => {
|
|
934
964
|
v < s.length && (u[h] = s[v]);
|
|
@@ -936,19 +966,19 @@ function mt(r, t, e, i) {
|
|
|
936
966
|
try {
|
|
937
967
|
const h = r.apply(this, s);
|
|
938
968
|
if (h && typeof h.then == "function") return p ? d.setCurrentFunctionSpanId(p) : d.clearCurrentFunctionSpanId(), h.then((F) => {
|
|
939
|
-
const $ = process.hrtime.bigint(), N = Date.now(), P = Number($ -
|
|
969
|
+
const $ = process.hrtime.bigint(), N = Date.now(), P = Number($ - g);
|
|
940
970
|
let X = null;
|
|
941
|
-
return o.capture_return_value && o.return_limit_mb > 0 && (X = M(F, o.return_limit_mb)), L({ functionName: t, filePath: e, metadata: i, args: u, result: X, error: null, duration: N - m, durationNs: P, startTimeNs:
|
|
971
|
+
return o.capture_return_value && o.return_limit_mb > 0 && (X = M(F, o.return_limit_mb)), L({ functionName: t, filePath: e, metadata: i, args: u, result: X, error: null, duration: N - m, durationNs: P, startTimeNs: g.toString(), async: !0, spanId: c, parentSpanId: p, pid: process.pid, threadId: O }), F;
|
|
942
972
|
}, (F) => {
|
|
943
|
-
const $ = process.hrtime.bigint(), N = Date.now(), P = Number($ -
|
|
944
|
-
throw L({ functionName: t, filePath: e, metadata: i, args: u, result: null, error: F?.message || String(F), duration: N - m, durationNs: P, startTimeNs:
|
|
973
|
+
const $ = process.hrtime.bigint(), N = Date.now(), P = Number($ - g);
|
|
974
|
+
throw L({ functionName: t, filePath: e, metadata: i, args: u, result: null, error: F?.message || String(F), duration: N - m, durationNs: P, startTimeNs: g.toString(), async: !0, spanId: c, parentSpanId: p, pid: process.pid, threadId: O }), F;
|
|
945
975
|
});
|
|
946
|
-
const v = process.hrtime.bigint(), I = Date.now(), _ = Number(v -
|
|
976
|
+
const v = process.hrtime.bigint(), I = Date.now(), _ = Number(v - g);
|
|
947
977
|
let S = null;
|
|
948
|
-
return o.capture_return_value && o.return_limit_mb > 0 && (S = M(h, o.return_limit_mb)), L({ functionName: t, filePath: e, metadata: i, args: u, result: S, error: null, duration: I - m, durationNs: _, startTimeNs:
|
|
978
|
+
return o.capture_return_value && o.return_limit_mb > 0 && (S = M(h, o.return_limit_mb)), L({ functionName: t, filePath: e, metadata: i, args: u, result: S, error: null, duration: I - m, durationNs: _, startTimeNs: g.toString(), async: !1, spanId: c, parentSpanId: p, pid: process.pid, threadId: O }), p ? d.setCurrentFunctionSpanId(p) : d.clearCurrentFunctionSpanId(), h;
|
|
949
979
|
} catch (h) {
|
|
950
|
-
const v = process.hrtime.bigint(), I = Date.now(), _ = Number(v -
|
|
951
|
-
throw L({ functionName: t, filePath: e, metadata: i, args: u, result: null, error: h?.message || String(h), duration: I - m, durationNs: _, startTimeNs:
|
|
980
|
+
const v = process.hrtime.bigint(), I = Date.now(), _ = Number(v - g);
|
|
981
|
+
throw L({ functionName: t, filePath: e, metadata: i, args: u, result: null, error: h?.message || String(h), duration: I - m, durationNs: _, startTimeNs: g.toString(), async: !1, spanId: c, parentSpanId: p, pid: process.pid, threadId: O }), p ? d.setCurrentFunctionSpanId(p) : d.clearCurrentFunctionSpanId(), h;
|
|
952
982
|
}
|
|
953
983
|
};
|
|
954
984
|
Object.defineProperty(n, "name", { value: t, writable: !1 });
|
|
@@ -965,44 +995,44 @@ function L(r) {
|
|
|
965
995
|
if (n) try {
|
|
966
996
|
const s = n === "true" || n === "1" ? "funcspans.jsonl" : n, l = Date.now(), a = process.hrtime.bigint(), o = BigInt(r.startTimeNs), d = Number(a - o) / 1e6, p = new Date(l - d).toISOString(), c = JSON.stringify({ timestamp: p, functionName: r.functionName, filePath: r.filePath, line: r.metadata.line, column: r.metadata.column, 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, async: r.async, pid: r.pid, threadId: r.threadId }) + `
|
|
967
997
|
`;
|
|
968
|
-
|
|
998
|
+
ke(s, c, "utf-8");
|
|
969
999
|
} catch (s) {
|
|
970
1000
|
console.error("[FuncSpan] Error writing to JSONL file:", s);
|
|
971
1001
|
}
|
|
972
1002
|
if (e && console.log("[FuncSpan] Sending function span to transmitter:", i), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
|
|
973
|
-
(
|
|
1003
|
+
(G || (G = new Fe()), G).send([i]), e && console.log("[FuncSpan] Function span sent successfully");
|
|
974
1004
|
} catch (s) {
|
|
975
1005
|
e && console.error("[FuncSpan] Error sending function span:", s);
|
|
976
1006
|
}
|
|
977
1007
|
}
|
|
978
|
-
function
|
|
1008
|
+
function St(r) {
|
|
979
1009
|
return !!r.includes("captureFunctionSpan(") || !!r.includes("@sailfish-ai/sf-veritas") || !(!r.includes("/* @sailfish-instrumented */") && !r.includes("// @sailfish-instrumented"));
|
|
980
1010
|
}
|
|
981
1011
|
export {
|
|
982
1012
|
V as ContextManager,
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1013
|
+
mt as addOrUpdateMetadata,
|
|
1014
|
+
yt as captureFunctionSpan,
|
|
1015
|
+
bt as clearFuncspanOverride,
|
|
986
1016
|
H as getCurrentFunctionSpanId,
|
|
987
1017
|
le as getDefaultConfig,
|
|
988
1018
|
$e as getEnvConfig,
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1019
|
+
W as getFuncspanOverride,
|
|
1020
|
+
ze as getGlobalConfig,
|
|
1021
|
+
ht as identify,
|
|
1022
|
+
je as initializeConfigLoader,
|
|
1023
|
+
et as initializeWorkerPoolPatching,
|
|
1024
|
+
St as isAlreadyInstrumented,
|
|
1025
|
+
Je as isConfigLoaderInitialized,
|
|
1026
|
+
Dt as isProductionEnvironment,
|
|
1027
|
+
wt as isRuntimeModeEnabled,
|
|
998
1028
|
gt as isSetupInterceptorsInitialized,
|
|
999
|
-
|
|
1029
|
+
tt as isWorkerPoolInitialized,
|
|
1000
1030
|
j as parseHeaderOverride,
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1031
|
+
$t as runWithContext,
|
|
1032
|
+
Ft as setFuncspanOverride,
|
|
1033
|
+
Rt as setSkipTypeScriptPlugin,
|
|
1034
|
+
ft as setupInterceptors,
|
|
1035
|
+
Pt as shouldEnableRuntimeHooks,
|
|
1006
1036
|
Tt as transformFunctionSpans,
|
|
1007
1037
|
Ct as transformFunctionSpansSync
|
|
1008
1038
|
};
|