@sailfish-ai/sf-veritas 0.3.2 → 0.4.1
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-B1hI1vbB.cjs +1 -0
- package/dist/{contextManager-CZy0w11U.js → contextManager-CE9FcHd2.js} +55 -47
- 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/funcspanWebpackPlugin.cjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.mjs +1 -1
- package/dist/{runtimeConfig-ButdW4zP.js → runtimeConfig-B6ERoLRD.js} +279 -277
- package/dist/{runtimeConfig-C4_zc4Zg.cjs → runtimeConfig-BgTE3gmS.cjs} +4 -4
- package/dist/sf-veritas.cjs +27 -19
- package/dist/sf-veritas.mjs +1657 -612
- package/dist/types/baseTransmitter.d.ts +1 -0
- package/dist/types/constants.d.ts +6 -0
- package/dist/types/contextManager.d.ts +15 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/patches/asyncQueues/_stubs/bee-queue.d.ts +10 -0
- package/dist/types/patches/asyncQueues/_stubs/rabbitmq.d.ts +11 -0
- package/dist/types/patches/asyncQueues/_stubs/sqs.d.ts +9 -0
- package/dist/types/patches/asyncQueues/asyncQueueTracer.d.ts +127 -0
- package/dist/types/patches/asyncQueues/asyncQueues.bench.d.ts +1 -0
- package/dist/types/patches/asyncQueues/bullmq.d.ts +27 -0
- package/dist/types/patches/asyncQueues/bullmqPro.d.ts +3 -0
- package/dist/types/patches/asyncQueues/confluentKafkaJs.d.ts +3 -0
- package/dist/types/patches/asyncQueues/index.d.ts +15 -0
- package/dist/types/patches/asyncQueues/kafkajs.d.ts +7 -0
- package/dist/types/setupConfig.d.ts +3 -0
- package/dist/worker-pool-capture.cjs +1 -1
- package/dist/worker-pool-capture.mjs +1 -1
- package/dist/{workerPoolSpanCapture-BomWTMM2.js → workerPoolSpanCapture-B5AjE5B9.js} +115 -115
- package/dist/workerPoolSpanCapture-CVp5eCI6.cjs +83 -0
- package/package.json +2 -1
- package/dist/contextManager-qXvO_a5y.cjs +0 -1
- package/dist/workerPoolSpanCapture-BUFN_RMW.cjs +0 -83
package/dist/sf-veritas.mjs
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { g 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
|
|
11
|
-
import * as
|
|
12
|
-
import { readFileSync as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { s as
|
|
16
|
-
import * as
|
|
17
|
-
import * as
|
|
18
|
-
import { glob as
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
1
|
+
var St = Object.defineProperty;
|
|
2
|
+
var bt = (n, t, e) => t in n ? St(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var D = (n, t, e) => bt(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { g as m, C as x, D as vt, v as G, b as H, N as It, c as $t, d as Et, a as nt } from "./contextManager-CE9FcHd2.js";
|
|
5
|
+
import { r as Mn } from "./contextManager-CE9FcHd2.js";
|
|
6
|
+
import { B as X, n as j, f as _t, g as ve, p as Ie, a as rt, b as wt, m as te, c as ie, i as Te, d as kt, e as ne, r as Ut, t as de, F as Dt } from "./workerPoolSpanCapture-B5AjE5B9.js";
|
|
7
|
+
import { h as xn, s as jn } from "./workerPoolSpanCapture-B5AjE5B9.js";
|
|
8
|
+
import { a as Nt, C as Pt, i as A, b as Ft, c as ot, d as qt, e as Ct } from "./runtimeConfig-B6ERoLRD.js";
|
|
9
|
+
import { f as Qn, g as Jn, s as Wn } from "./runtimeConfig-B6ERoLRD.js";
|
|
10
|
+
import { createRequire as Tt } from "node:module";
|
|
11
|
+
import * as At from "fs";
|
|
12
|
+
import { readFileSync as Bt, appendFileSync as Lt } from "fs";
|
|
13
|
+
import Q from "http";
|
|
14
|
+
import re from "https";
|
|
15
|
+
import { s as Rt } from "./source-map-Cr6YkjTd.js";
|
|
16
|
+
import * as Ae from "fs/promises";
|
|
17
|
+
import * as B from "path";
|
|
18
|
+
import { glob as Ot } from "glob";
|
|
19
|
+
import { AsyncLocalStorage as Mt } from "async_hooks";
|
|
20
|
+
import { threadId as oe } from "worker_threads";
|
|
21
|
+
import { s as zn, t as Vn, a as Xn } from "./funcSpanTransformer-S_WeAt_m.js";
|
|
22
|
+
class ee extends X {
|
|
22
23
|
constructor() {
|
|
23
24
|
super(), this.setOperationName("IdentifyServiceDetails");
|
|
24
25
|
}
|
|
25
26
|
async doSend(t) {
|
|
26
|
-
if (!
|
|
27
|
+
if (!m().serviceIdentificationReceived) try {
|
|
27
28
|
this.send();
|
|
28
29
|
} catch (e) {
|
|
29
|
-
|
|
30
|
+
m().sfDebug && console.error(" Error during service identification:", e);
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
async send() {
|
|
@@ -48,6 +49,7 @@ class O extends k {
|
|
|
48
49
|
$framework: String,
|
|
49
50
|
$additionalFrameworks: JSON,
|
|
50
51
|
$serviceRole: String,
|
|
52
|
+
$dataSensitivityLevel: String,
|
|
51
53
|
) {
|
|
52
54
|
${this.queryName}(
|
|
53
55
|
apiKey: $apiKey,
|
|
@@ -66,39 +68,40 @@ class O extends k {
|
|
|
66
68
|
framework: $framework,
|
|
67
69
|
additionalFrameworks: $additionalFrameworks,
|
|
68
70
|
serviceRole: $serviceRole,
|
|
71
|
+
dataSensitivityLevel: $dataSensitivityLevel,
|
|
69
72
|
)
|
|
70
73
|
}
|
|
71
|
-
`, e =
|
|
72
|
-
|
|
74
|
+
`, e = m(), o = 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 });
|
|
75
|
+
j(this.endpoint, this.operationName, t, o);
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
|
-
class
|
|
78
|
+
class Ht extends X {
|
|
76
79
|
constructor() {
|
|
77
80
|
super();
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
D(this, "serviceIdentifier", new ee());
|
|
82
|
+
D(this, "identifyStarted", !1);
|
|
80
83
|
this.setOperationName("CollectMetadata");
|
|
81
84
|
}
|
|
82
85
|
startBackgroundIdentify() {
|
|
83
86
|
if (this.identifyStarted) return;
|
|
84
87
|
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
85
88
|
const e = setInterval(() => {
|
|
86
|
-
|
|
89
|
+
m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
87
90
|
}, 5e3);
|
|
88
91
|
e && typeof e == "object" && "unref" in e && e.unref();
|
|
89
92
|
}
|
|
90
|
-
async doSend(e,
|
|
91
|
-
this.startBackgroundIdentify(), this.send(e,
|
|
93
|
+
async doSend(e, o, r, i) {
|
|
94
|
+
this.startBackgroundIdentify(), this.send(e, o, r, i);
|
|
92
95
|
}
|
|
93
|
-
async send(e,
|
|
94
|
-
if (!
|
|
95
|
-
let
|
|
96
|
-
if (!
|
|
97
|
-
const
|
|
98
|
-
|
|
96
|
+
async send(e, o, r, i) {
|
|
97
|
+
if (!o && !i) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
|
|
98
|
+
let d = [];
|
|
99
|
+
if (!i) {
|
|
100
|
+
const a = Nt(o);
|
|
101
|
+
i = a.traitsJson, d = a.excludedFields;
|
|
99
102
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
103
|
+
const l = this.getVariables({ userId: e, traitsJson: i, excludedFields: d, override: r, library: m().packageLibraryType, version: m().version });
|
|
104
|
+
j(this.endpoint, this.operationName, this.getQuery(), l);
|
|
102
105
|
}
|
|
103
106
|
getQuery() {
|
|
104
107
|
return `
|
|
@@ -108,30 +111,30 @@ class We extends k {
|
|
|
108
111
|
`;
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
class
|
|
114
|
+
class st {
|
|
112
115
|
constructor(t) {
|
|
113
|
-
|
|
114
|
-
this.apiKey = t, this.metadataTransmitter = new
|
|
116
|
+
D(this, "metadataTransmitter");
|
|
117
|
+
this.apiKey = t, this.metadataTransmitter = new Ht();
|
|
115
118
|
}
|
|
116
|
-
identify(t, e,
|
|
117
|
-
e ||
|
|
119
|
+
identify(t, e, o, r = !1) {
|
|
120
|
+
e || o ? this.addOrUpdateMetadata(t, e, o, r) : this.addOrUpdateMetadata(t, {}, void 0, r);
|
|
118
121
|
}
|
|
119
|
-
addOrUpdateMetadata(t, e = {},
|
|
120
|
-
if (!e && !
|
|
121
|
-
|
|
122
|
+
addOrUpdateMetadata(t, e = {}, o, r = !1) {
|
|
123
|
+
if (!e && !o) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
|
|
124
|
+
m().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), m().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", t, e, o), this.metadataTransmitter.doSend(t, e, r, o);
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
|
-
class
|
|
127
|
+
class Ce extends X {
|
|
125
128
|
constructor() {
|
|
126
129
|
super();
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
D(this, "serviceIdentifier", new ee());
|
|
131
|
+
D(this, "identifyStarted", !1);
|
|
129
132
|
}
|
|
130
133
|
startBackgroundIdentify() {
|
|
131
134
|
if (this.identifyStarted) return;
|
|
132
135
|
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
133
136
|
const e = setInterval(() => {
|
|
134
|
-
|
|
137
|
+
m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
135
138
|
}, 5e3);
|
|
136
139
|
e && typeof e == "object" && "unref" in e && e.unref();
|
|
137
140
|
}
|
|
@@ -140,10 +143,10 @@ class re extends k {
|
|
|
140
143
|
}
|
|
141
144
|
async send(e) {
|
|
142
145
|
try {
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
} catch (
|
|
146
|
-
|
|
146
|
+
const o = Array.isArray(e) ? e : [e, "default", null, null], r = this.getVariables({ contents: o[0], level: o[1], sourceFile: o[2] || void 0, sourceLine: o[3] || void 0 });
|
|
147
|
+
j(this.endpoint, this.operationName, this.getQuery(), r);
|
|
148
|
+
} catch (o) {
|
|
149
|
+
m().sfDebug && console.error("🚨 Error in send():", o);
|
|
147
150
|
}
|
|
148
151
|
}
|
|
149
152
|
getQuery() {
|
|
@@ -157,7 +160,8 @@ class re extends k {
|
|
|
157
160
|
$contents: String!,
|
|
158
161
|
$parentSpanId: String,
|
|
159
162
|
$sourceFile: String,
|
|
160
|
-
$sourceLine: Int
|
|
163
|
+
$sourceLine: Int,
|
|
164
|
+
$dataSensitivityLevel: String
|
|
161
165
|
) {
|
|
162
166
|
${this.queryName}(
|
|
163
167
|
apiKey: $apiKey,
|
|
@@ -168,42 +172,43 @@ class re extends k {
|
|
|
168
172
|
contents: $contents,
|
|
169
173
|
parentSpanId: $parentSpanId,
|
|
170
174
|
sourceFile: $sourceFile,
|
|
171
|
-
sourceLine: $sourceLine
|
|
175
|
+
sourceLine: $sourceLine,
|
|
176
|
+
dataSensitivityLevel: $dataSensitivityLevel
|
|
172
177
|
)
|
|
173
178
|
}
|
|
174
179
|
`;
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
|
-
class
|
|
182
|
+
class xt extends X {
|
|
178
183
|
constructor() {
|
|
179
184
|
super();
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
D(this, "serviceIdentifier", new ee());
|
|
186
|
+
D(this, "supplementalFields", {});
|
|
187
|
+
D(this, "identifyStarted", !1);
|
|
183
188
|
this.setOperationName("CollectExceptions");
|
|
184
189
|
}
|
|
185
190
|
setSupplementalFields(e) {
|
|
186
191
|
this.supplementalFields = { ...this.supplementalFields, ...e };
|
|
187
192
|
}
|
|
188
193
|
normalizedSupplementalForGraphQL() {
|
|
189
|
-
const { isFromLocalService: e } = this.supplementalFields,
|
|
190
|
-
return e !== void 0 && (
|
|
194
|
+
const { isFromLocalService: e } = this.supplementalFields, o = {};
|
|
195
|
+
return e !== void 0 && (o.isFromLocalService = e), o;
|
|
191
196
|
}
|
|
192
197
|
startBackgroundIdentify() {
|
|
193
198
|
if (this.identifyStarted) return;
|
|
194
199
|
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
195
200
|
const e = setInterval(() => {
|
|
196
|
-
|
|
201
|
+
m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
197
202
|
}, 5e3);
|
|
198
203
|
e && typeof e == "object" && "unref" in e && e.unref();
|
|
199
204
|
}
|
|
200
|
-
async doSend(e,
|
|
201
|
-
this.startBackgroundIdentify(), this.send(e,
|
|
205
|
+
async doSend(e, o) {
|
|
206
|
+
this.startBackgroundIdentify(), this.send(e, o);
|
|
202
207
|
}
|
|
203
|
-
async send(e,
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
208
|
+
async send(e, o) {
|
|
209
|
+
m().sfDebug && console.log(" SENDING EXCEPTION...");
|
|
210
|
+
const r = JSON.stringify(Pt.encode(o)), i = this.normalizedSupplementalForGraphQL(), d = this.getVariables({ exceptionMessage: e, traceJson: r, reentrancyGuardPreactive: !1, library: m().packageLibraryType, version: m().version, ...i });
|
|
211
|
+
j(this.endpoint, this.operationName, this.getQuery(), d);
|
|
207
212
|
}
|
|
208
213
|
getQuery() {
|
|
209
214
|
return `
|
|
@@ -218,7 +223,8 @@ class je extends k {
|
|
|
218
223
|
$timestampMs: String!,
|
|
219
224
|
$version: String!,
|
|
220
225
|
$isFromLocalService: Boolean,
|
|
221
|
-
$parentSpanId: String
|
|
226
|
+
$parentSpanId: String,
|
|
227
|
+
$dataSensitivityLevel: String
|
|
222
228
|
) {
|
|
223
229
|
${this.queryName}(
|
|
224
230
|
apiKey: $apiKey,
|
|
@@ -231,88 +237,89 @@ class je extends k {
|
|
|
231
237
|
timestampMs: $timestampMs,
|
|
232
238
|
version: $version,
|
|
233
239
|
isFromLocalService: $isFromLocalService,
|
|
234
|
-
parentSpanId: $parentSpanId
|
|
240
|
+
parentSpanId: $parentSpanId,
|
|
241
|
+
dataSensitivityLevel: $dataSensitivityLevel
|
|
235
242
|
)
|
|
236
243
|
}
|
|
237
244
|
`;
|
|
238
245
|
}
|
|
239
246
|
}
|
|
240
|
-
const
|
|
241
|
-
var
|
|
242
|
-
const
|
|
243
|
-
let
|
|
244
|
-
function
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
247
|
+
const Y = "X-Sf3-Rid", Be = "X-Sf4-Prid", Le = "getting request source code";
|
|
248
|
+
var ae = ((n) => (n.UNKNOWN = "unknown", n.ANONYMOUS = "anonymous", n.NOT_CAPTURED = "not captured", n))(ae || {});
|
|
249
|
+
const Re = "http:", jt = Tt(import.meta.url);
|
|
250
|
+
let Oe = !1;
|
|
251
|
+
function Kt() {
|
|
252
|
+
const n = m().sfDebug;
|
|
253
|
+
if (Oe) return void (n && A("[patchNodeHttpInbound] Already installed, skipping."));
|
|
247
254
|
let t;
|
|
248
|
-
|
|
255
|
+
Oe = !0;
|
|
249
256
|
try {
|
|
250
|
-
t =
|
|
251
|
-
} catch (
|
|
252
|
-
return void
|
|
253
|
-
}
|
|
254
|
-
if (!t?.Server?.prototype) return void (
|
|
255
|
-
const e = t.Server.prototype,
|
|
256
|
-
|
|
257
|
-
if (
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
if (!
|
|
261
|
-
for (const [
|
|
262
|
-
return
|
|
263
|
-
})(
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
257
|
+
t = jt("node:http"), n && A("[patchNodeHttpInbound] node:http required successfully.");
|
|
258
|
+
} catch (r) {
|
|
259
|
+
return void Ft("Failed to require node:http:", r);
|
|
260
|
+
}
|
|
261
|
+
if (!t?.Server?.prototype) return void (n && A("[patchNodeHttpInbound] http.Server.prototype not found."));
|
|
262
|
+
const e = t.Server.prototype, o = e.emit;
|
|
263
|
+
o && !e.__sf_inbound_patched__ ? (Object.defineProperty(e, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), n && A("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), e.emit = function(r, ...i) {
|
|
264
|
+
if (r !== "request") return n && A(`[patchNodeHttpInbound] Passing through event: ${r}`), o.call(this, r, ...i);
|
|
265
|
+
const d = i[0], l = i[1], a = (function(g) {
|
|
266
|
+
const f = {};
|
|
267
|
+
if (!g) return f;
|
|
268
|
+
for (const [y, S] of Object.entries(g)) S != null && (Array.isArray(S) ? f[y.toLowerCase()] = S.join(", ") : f[y.toLowerCase()] = String(S));
|
|
269
|
+
return f;
|
|
270
|
+
})(d?.headers), s = a["x-sf3-rid"], u = a["x-sf3-functionspancaptureoverride"];
|
|
271
|
+
n && (A("[patchNodeHttpInbound] Intercepted request event."), A("[patchNodeHttpInbound] Inbound headers:", a), A("[patchNodeHttpInbound] Trace header:", s), A("[patchNodeHttpInbound] FuncSpan override header:", u));
|
|
272
|
+
const c = x.getInstance();
|
|
273
|
+
c.setTraceId(s);
|
|
274
|
+
const p = c.getTraceId();
|
|
275
|
+
n && A("[patchNodeHttpInbound] Context traceId set:", p);
|
|
276
|
+
const h = () => c.runWith({ inboundHeaders: a, ...s ? { traceId: s } : {} }, () => {
|
|
277
|
+
s && c.setTraceId(s), n && A("[patchNodeHttpInbound] Running request handler in context.");
|
|
278
|
+
const g = () => {
|
|
279
|
+
n && A("[patchNodeHttpInbound] Response finished/closed for traceId:", c.getTraceId());
|
|
273
280
|
};
|
|
274
|
-
return
|
|
281
|
+
return l.on("finish", g), l.on("close", g), o.call(this, r, d, l);
|
|
275
282
|
});
|
|
276
|
-
if (!
|
|
283
|
+
if (!u) return h();
|
|
277
284
|
try {
|
|
278
|
-
return
|
|
285
|
+
return _t.run(u, () => h());
|
|
279
286
|
} catch {
|
|
280
|
-
return
|
|
287
|
+
return h();
|
|
281
288
|
}
|
|
282
|
-
}) :
|
|
289
|
+
}) : n && A("[patchNodeHttpInbound] Already patched, skipping.");
|
|
283
290
|
}
|
|
284
|
-
const
|
|
285
|
-
function
|
|
286
|
-
const e = `${
|
|
287
|
-
let
|
|
288
|
-
return
|
|
291
|
+
const Me = /* @__PURE__ */ new Map();
|
|
292
|
+
function pe(n, t) {
|
|
293
|
+
const e = `${n}|${t}`;
|
|
294
|
+
let o = Me.get(e);
|
|
295
|
+
return o || (o = new RegExp(n, t), Me.set(e, o)), o;
|
|
289
296
|
}
|
|
290
|
-
function
|
|
291
|
-
let e,
|
|
292
|
-
if (typeof
|
|
297
|
+
function fe(n, t) {
|
|
298
|
+
let e, o;
|
|
299
|
+
if (typeof n == "string" ? e = n : typeof URL < "u" && n instanceof URL ? e = n.href : typeof Request < "u" && n instanceof Request ? e = n.url : n != null && typeof n.toString == "function" && (e = n.toString()), !e) return !1;
|
|
293
300
|
try {
|
|
294
|
-
|
|
301
|
+
o = new URL(e, "http://localhost/");
|
|
295
302
|
} catch {
|
|
296
303
|
return !1;
|
|
297
304
|
}
|
|
298
|
-
const { hostname:
|
|
299
|
-
if (!/^https?:$/.test(
|
|
300
|
-
const
|
|
301
|
-
return t.some((
|
|
302
|
-
const
|
|
303
|
-
if (!
|
|
304
|
-
let [
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
return
|
|
305
|
+
const { hostname: r, pathname: i, port: d, protocol: l } = o;
|
|
306
|
+
if (!/^https?:$/.test(l)) return !1;
|
|
307
|
+
const a = r.startsWith("www.") ? r.slice(4).toLowerCase() : r.toLowerCase();
|
|
308
|
+
return t.some((s) => {
|
|
309
|
+
const u = String(s || "").replace(/^[a-zA-Z]+:\/\//, "");
|
|
310
|
+
if (!u) return !1;
|
|
311
|
+
let [c, p] = u.split("/", 2), h = "";
|
|
312
|
+
c.includes(":") && ([c, h] = c.split(":"));
|
|
313
|
+
const g = pe(`^${c.replace(/\./g, "\\.").replace(/\*/g, ".*")}$`, "i"), f = a.startsWith("www.") ? a.slice(4) : a;
|
|
314
|
+
if (h && d !== h) return !1;
|
|
315
|
+
if (c.startsWith("*.")) {
|
|
316
|
+
const y = c.slice(2).toLowerCase();
|
|
317
|
+
return a === y || f === y || a.endsWith("." + y) ? p ? pe(`^/${p.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(i) : !0 : !1;
|
|
311
318
|
}
|
|
312
|
-
return !
|
|
319
|
+
return !g.test(f) && !g.test(a) ? !1 : p ? pe(`^/${p.replace(/\*/g, ".*").replace(/\/$/, "")}`, "i").test(i) : !0;
|
|
313
320
|
});
|
|
314
321
|
}
|
|
315
|
-
class
|
|
322
|
+
class Qt extends Ce {
|
|
316
323
|
constructor() {
|
|
317
324
|
super(), this.setOperationName("DomainsToNotPassHeaderTo");
|
|
318
325
|
}
|
|
@@ -332,22 +339,22 @@ class Je extends re {
|
|
|
332
339
|
domains: $domains
|
|
333
340
|
)
|
|
334
341
|
}
|
|
335
|
-
`,
|
|
336
|
-
|
|
342
|
+
`, o = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: t };
|
|
343
|
+
j(this.endpoint, this.operationName, e, o);
|
|
337
344
|
}
|
|
338
345
|
}
|
|
339
|
-
class
|
|
346
|
+
class Jt extends X {
|
|
340
347
|
constructor() {
|
|
341
348
|
super();
|
|
342
|
-
|
|
343
|
-
|
|
349
|
+
D(this, "serviceIdentifier", new ee());
|
|
350
|
+
D(this, "identifyStarted", !1);
|
|
344
351
|
this.setOperationName("CollectNetworkHops");
|
|
345
352
|
}
|
|
346
353
|
startBackgroundIdentify() {
|
|
347
354
|
if (this.identifyStarted) return;
|
|
348
355
|
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
349
356
|
const e = setInterval(() => {
|
|
350
|
-
|
|
357
|
+
m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
351
358
|
}, 5e3);
|
|
352
359
|
e && typeof e == "object" && "unref" in e && e.unref();
|
|
353
360
|
}
|
|
@@ -355,8 +362,8 @@ class Qe extends k {
|
|
|
355
362
|
this.startBackgroundIdentify(), this.send(e);
|
|
356
363
|
}
|
|
357
364
|
async send(e) {
|
|
358
|
-
const { name:
|
|
359
|
-
|
|
365
|
+
const { name: o, column: r, line: i, entrypoint: d, retryWithoutTraceId: l } = e, a = this.getVariables({ name: o, column: r, line: i, entrypoint: d, retryWithoutTraceId: l });
|
|
366
|
+
j(this.endpoint, this.operationName, this.getQuery(), a);
|
|
360
367
|
}
|
|
361
368
|
getQuery() {
|
|
362
369
|
return `
|
|
@@ -368,7 +375,8 @@ class Qe extends k {
|
|
|
368
375
|
$column: String!,
|
|
369
376
|
$name: String!,
|
|
370
377
|
$entrypoint: String!,
|
|
371
|
-
$serviceUuid: String
|
|
378
|
+
$serviceUuid: String,
|
|
379
|
+
$dataSensitivityLevel: String
|
|
372
380
|
${this.operationName === "CollectNetworkHops" ? ", $retryWithoutTraceId: Boolean" : ""}
|
|
373
381
|
) {
|
|
374
382
|
${this.queryName}(
|
|
@@ -379,25 +387,26 @@ class Qe extends k {
|
|
|
379
387
|
column: $column,
|
|
380
388
|
name: $name,
|
|
381
389
|
entrypoint: $entrypoint,
|
|
382
|
-
serviceUuid: $serviceUuid
|
|
390
|
+
serviceUuid: $serviceUuid,
|
|
391
|
+
dataSensitivityLevel: $dataSensitivityLevel
|
|
383
392
|
${this.operationName === "CollectNetworkHops" ? ", retryWithoutTraceId: $retryWithoutTraceId" : ""}
|
|
384
393
|
)
|
|
385
394
|
}
|
|
386
395
|
`;
|
|
387
396
|
}
|
|
388
397
|
}
|
|
389
|
-
class
|
|
398
|
+
class it extends X {
|
|
390
399
|
constructor() {
|
|
391
400
|
super();
|
|
392
|
-
|
|
393
|
-
|
|
401
|
+
D(this, "serviceIdentifier", new ee());
|
|
402
|
+
D(this, "identifyStarted", !1);
|
|
394
403
|
this.setOperationName("CollectNetworkRequest");
|
|
395
404
|
}
|
|
396
405
|
startBackgroundIdentify() {
|
|
397
406
|
if (this.identifyStarted) return;
|
|
398
407
|
this.identifyStarted = !0, this.serviceIdentifier.doSend({});
|
|
399
408
|
const e = setInterval(() => {
|
|
400
|
-
|
|
409
|
+
m().serviceIdentificationReceived ? clearInterval(e) : this.serviceIdentifier.doSend({});
|
|
401
410
|
}, 5e3);
|
|
402
411
|
e && typeof e == "object" && "unref" in e && e.unref();
|
|
403
412
|
}
|
|
@@ -415,349 +424,349 @@ class Xe extends k {
|
|
|
415
424
|
`;
|
|
416
425
|
}
|
|
417
426
|
async send(e) {
|
|
418
|
-
const
|
|
419
|
-
await
|
|
427
|
+
const o = { data: { ...e, dataSensitivityLevel: m().dataSensitivityLevel } };
|
|
428
|
+
await j(this.endpoint, this.operationName, this.getQuery(), o);
|
|
420
429
|
}
|
|
421
430
|
}
|
|
422
|
-
const
|
|
423
|
-
function
|
|
424
|
-
return t !== "none" && (t === "all" ||
|
|
431
|
+
const he = [400, 403];
|
|
432
|
+
function ye(n, t) {
|
|
433
|
+
return t !== "none" && (t === "all" || n === "GET" || n === "HEAD" || n === "OPTIONS");
|
|
425
434
|
}
|
|
426
|
-
class
|
|
435
|
+
class Wt {
|
|
427
436
|
constructor(t = []) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
this.contextManager =
|
|
437
|
+
D(this, "HEADER_TRACING", "X-Sf3-Rid");
|
|
438
|
+
D(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
|
|
439
|
+
D(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
|
|
440
|
+
D(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
|
|
441
|
+
D(this, "contextManager");
|
|
442
|
+
this.contextManager = x.getInstance(), t?.forEach((e) => {
|
|
434
443
|
typeof e == "string" && e.trim() && this.contextManager.getExcludedDomains().add(e);
|
|
435
|
-
}),
|
|
444
|
+
}), m().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
|
|
436
445
|
}
|
|
437
446
|
extractIdsFromTraceHeader(t, e = this.HEADER_TRACING) {
|
|
438
|
-
let
|
|
439
|
-
if (t instanceof Headers)
|
|
447
|
+
let o;
|
|
448
|
+
if (t instanceof Headers) o = t.get(e) ?? void 0;
|
|
440
449
|
else {
|
|
441
|
-
const
|
|
442
|
-
for (const [
|
|
443
|
-
|
|
450
|
+
const i = e.toLowerCase();
|
|
451
|
+
for (const [d, l] of Object.entries(t)) if (d.toLowerCase() === i) {
|
|
452
|
+
o = l;
|
|
444
453
|
break;
|
|
445
454
|
}
|
|
446
455
|
}
|
|
447
|
-
if (!
|
|
448
|
-
const
|
|
449
|
-
return
|
|
456
|
+
if (!o) return {};
|
|
457
|
+
const r = o.split("/").filter(Boolean);
|
|
458
|
+
return r.length < 3 ? {} : { sessionId: r[0], pageVisitId: r[1], requestId: r[r.length - 1] };
|
|
450
459
|
}
|
|
451
460
|
parseStackFrame(t) {
|
|
452
461
|
const e = /\((.*):(\d+):(\d+)\)$/.exec(t.trim());
|
|
453
462
|
if (!e) return null;
|
|
454
|
-
const [,
|
|
455
|
-
return { filePath:
|
|
463
|
+
const [, o, r, i] = e;
|
|
464
|
+
return { filePath: o, line: parseInt(r, 10), column: parseInt(i, 10) };
|
|
456
465
|
}
|
|
457
|
-
async getOriginalPosition(t, e,
|
|
458
|
-
let
|
|
459
|
-
if (t.includes("://")) return { originalPos:
|
|
460
|
-
const
|
|
466
|
+
async getOriginalPosition(t, e, o) {
|
|
467
|
+
let r = { source: t, line: e, column: o, name: null };
|
|
468
|
+
if (t.includes("://")) return { originalPos: r };
|
|
469
|
+
const i = t + ".map";
|
|
461
470
|
try {
|
|
462
|
-
const
|
|
463
|
-
let
|
|
464
|
-
|
|
465
|
-
} catch (
|
|
466
|
-
|
|
471
|
+
const d = JSON.parse(Bt(i, "utf-8"));
|
|
472
|
+
let l = (await new Rt.SourceMapConsumer(d)).originalPositionFor({ line: e, column: o });
|
|
473
|
+
l.source && (r = l);
|
|
474
|
+
} catch (d) {
|
|
475
|
+
m().sfDebug && console.error(`Could not read/parse map file at ${i}:`, d);
|
|
467
476
|
}
|
|
468
|
-
return { originalPos:
|
|
469
|
-
}
|
|
470
|
-
captureFirstUserLines(t, e = 10,
|
|
471
|
-
const
|
|
472
|
-
Error.stackTraceLimit = Math.max(
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
const
|
|
476
|
-
Error.stackTraceLimit =
|
|
477
|
-
const
|
|
478
|
-
`).slice(1),
|
|
479
|
-
for (const
|
|
480
|
-
if (!(
|
|
481
|
-
for (const
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
const { originalPos:
|
|
485
|
-
if (
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
t.doSend(
|
|
477
|
+
return { originalPos: r };
|
|
478
|
+
}
|
|
479
|
+
captureFirstUserLines(t, e = 10, o = !1) {
|
|
480
|
+
const r = m().sfDebug ? 10 : e, i = Error.stackTraceLimit;
|
|
481
|
+
Error.stackTraceLimit = Math.max(i, r);
|
|
482
|
+
const d = new Error(Le);
|
|
483
|
+
Le in Error && Error.captureStackTrace(d, this.captureFirstUserLines);
|
|
484
|
+
const l = ot(d.stack);
|
|
485
|
+
Error.stackTraceLimit = i;
|
|
486
|
+
const a = l.split(`
|
|
487
|
+
`).slice(1), s = [];
|
|
488
|
+
for (const u of a)
|
|
489
|
+
if (!(u.includes("node:internal") || u.includes("internal/modules") || u.includes("internal/process") || u.includes("node_modules") || u.includes(".next/server/chunks") || u.includes("RequestInterceptor") || u.includes("contextManager") || u.includes("setupConfig")) && (s.push(u.trim()), s.length >= e)) break;
|
|
490
|
+
for (const u of s) {
|
|
491
|
+
const c = this.parseStackFrame(u);
|
|
492
|
+
c ? (async () => {
|
|
493
|
+
const { originalPos: p } = await this.getOriginalPosition(c.filePath, c.line, c.column);
|
|
494
|
+
if (p) {
|
|
495
|
+
m().sfDebug && console.log("[RequestInterceptor] First user code line:", p);
|
|
496
|
+
const h = { line: p.line?.toString() || ae.UNKNOWN, column: p.column?.toString() || ae.NOT_CAPTURED, name: p.name || ae.NOT_CAPTURED, entrypoint: p.source, retryWithoutTraceId: o };
|
|
497
|
+
t.doSend(h);
|
|
489
498
|
}
|
|
490
|
-
})() :
|
|
499
|
+
})() : m().sfDebug && console.error("Could not parse stack line:", u);
|
|
491
500
|
}
|
|
492
501
|
}
|
|
493
502
|
addReentrancyGuardHeaders(t) {
|
|
494
503
|
t.set(this.HEADER_LOG_GUARD, "true"), t.set(this.HEADER_PRINT_GUARD, "true"), t.set(this.HEADER_EXCEPTION_GUARD, "true");
|
|
495
504
|
}
|
|
496
505
|
shouldPropagateHeaders(t) {
|
|
497
|
-
const e =
|
|
498
|
-
return !!
|
|
506
|
+
const e = m(), o = e.domainsToPropagateHeadersTo, r = e.domainsToNotPropagateHeadersTo || [], i = Array.from(vt);
|
|
507
|
+
return !!fe(t, o) && !(r.length > 0 && fe(t, r)) && !fe(t, i);
|
|
499
508
|
}
|
|
500
509
|
addTracingHeaders(t, e) {
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
503
|
-
else if (
|
|
504
|
-
let
|
|
510
|
+
const o = this.shouldPropagateHeaders(e);
|
|
511
|
+
if (o) this.addTracingHeader(t, e);
|
|
512
|
+
else if (m().sfDebug) {
|
|
513
|
+
let r = e;
|
|
505
514
|
try {
|
|
506
|
-
|
|
515
|
+
r = new URL(e).hostname;
|
|
507
516
|
} catch {
|
|
508
517
|
}
|
|
509
|
-
console.error(`[RequestInterceptor] Excluded domain: ${
|
|
518
|
+
console.error(`[RequestInterceptor] Excluded domain: ${r}`);
|
|
510
519
|
}
|
|
511
|
-
return
|
|
520
|
+
return o;
|
|
512
521
|
}
|
|
513
522
|
deriveTraceBaseAndParent(t) {
|
|
514
523
|
const e = t.split("/").filter(Boolean);
|
|
515
524
|
return e.length < 2 ? { base: t, parent: t } : { base: `${e[0]}/${e[1]}`, parent: t };
|
|
516
525
|
}
|
|
517
526
|
addTracingHeader(t, e) {
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
527
|
+
const o = ve();
|
|
528
|
+
if (o) {
|
|
529
|
+
const a = Ie(o);
|
|
530
|
+
if (a && a.sample_rate === 0) return void (m().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`));
|
|
522
531
|
}
|
|
523
|
-
const
|
|
524
|
-
t.set(this.HEADER_TRACING, `${
|
|
532
|
+
const r = this.contextManager.getOrSetSfTraceId(), { base: i, parent: d } = this.deriveTraceBaseAndParent(r), l = G();
|
|
533
|
+
t.set(this.HEADER_TRACING, `${i}/${l}`), t.set(Be, d), m().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
|
|
525
534
|
}
|
|
526
535
|
patchFetch(t, e) {
|
|
527
|
-
const
|
|
528
|
-
typeof
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
536
|
+
const o = globalThis.fetch;
|
|
537
|
+
typeof o == "function" ? globalThis.fetch = async (r, i) => {
|
|
538
|
+
const d = new Headers(i?.headers);
|
|
539
|
+
if (d.get(this.HEADER_LOG_GUARD) === "true" || d.get(this.HEADER_PRINT_GUARD) === "true" || d.get(this.HEADER_EXCEPTION_GUARD) === "true") return o(r, i);
|
|
531
540
|
this.captureFirstUserLines(t);
|
|
532
|
-
const
|
|
533
|
-
let
|
|
534
|
-
if (typeof
|
|
541
|
+
const l = Date.now();
|
|
542
|
+
let a, s = "GET";
|
|
543
|
+
if (typeof r == "string" || r instanceof URL) a = r.toString(), s = (i?.method || "GET").toUpperCase();
|
|
535
544
|
else {
|
|
536
|
-
if (!(
|
|
537
|
-
|
|
538
|
-
|
|
545
|
+
if (!(r instanceof Request)) return m().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), o(r, i);
|
|
546
|
+
a = r.url, s = r.method.toUpperCase(), r.headers.forEach((v, I) => {
|
|
547
|
+
d.set(I, v);
|
|
539
548
|
});
|
|
540
549
|
}
|
|
541
|
-
|
|
542
|
-
let
|
|
550
|
+
m().sfDebug && console.log("[RequestInterceptor] Fetching request to:", a);
|
|
551
|
+
let u = "unknown";
|
|
543
552
|
try {
|
|
544
|
-
|
|
553
|
+
u = new URL(a).hostname;
|
|
545
554
|
} catch {
|
|
546
|
-
return
|
|
555
|
+
return m().sfDebug && console.warn(`[RequestInterceptor] Could not parse URL '${a}' — passing through without tracing headers.`), o(r, i);
|
|
547
556
|
}
|
|
548
|
-
const
|
|
549
|
-
let
|
|
557
|
+
const c = new Headers(d), p = this.addTracingHeaders(d, a), h = (v) => r instanceof Request ? [new Request(r, { ...i || {}, headers: v }), void 0] : [a, { ...i, headers: v }], g = m().retryOnClientError;
|
|
558
|
+
let f, y = !1;
|
|
550
559
|
try {
|
|
551
|
-
const [
|
|
552
|
-
if (
|
|
553
|
-
const [
|
|
554
|
-
|
|
560
|
+
const [v, I] = h(d);
|
|
561
|
+
if (f = await o(v, I), p && ye(s, g) && he.includes(f.status)) {
|
|
562
|
+
const [_, $] = h(c);
|
|
563
|
+
f = await o(_, $), y = !0;
|
|
555
564
|
try {
|
|
556
|
-
this.captureFirstUserLines(t, 10,
|
|
557
|
-
} catch (
|
|
558
|
-
|
|
565
|
+
this.captureFirstUserLines(t, 10, y);
|
|
566
|
+
} catch (k) {
|
|
567
|
+
m().sfDebug && console.error("[RequestInterceptor] captureFirstUserLines (retry) failed:", k);
|
|
559
568
|
}
|
|
560
569
|
} else try {
|
|
561
|
-
this.contextManager.addSupportedDomains(
|
|
562
|
-
} catch (
|
|
563
|
-
|
|
570
|
+
this.contextManager.addSupportedDomains(u);
|
|
571
|
+
} catch (_) {
|
|
572
|
+
m().sfDebug && console.error("[RequestInterceptor] addSupportedDomains failed:", _);
|
|
564
573
|
}
|
|
565
|
-
} catch (
|
|
566
|
-
const
|
|
567
|
-
|
|
574
|
+
} catch (v) {
|
|
575
|
+
const I = Date.now();
|
|
576
|
+
m().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${v}, Duration: ${I - l}ms`);
|
|
568
577
|
try {
|
|
569
|
-
const { sessionId:
|
|
570
|
-
e.doSend({ apiKey:
|
|
571
|
-
} catch (
|
|
572
|
-
|
|
578
|
+
const { sessionId: _, pageVisitId: $, requestId: k } = this.extractIdsFromTraceHeader(d), q = m();
|
|
579
|
+
e.doSend({ apiKey: q.apiKey, requestId: k, pageVisitId: $, recordingSessionId: _, serviceUuid: q.serviceUUID, timestampStart: l.toString(), timestampEnd: I.toString(), responseCode: 0, success: !1, error: v instanceof Error ? v.message : typeof v == "string" ? v : JSON.stringify(v), url: a, method: s, retryWithoutTraceId: y, parentSpanId: H() });
|
|
580
|
+
} catch (_) {
|
|
581
|
+
m().sfDebug && console.error("[RequestInterceptor] Error telemetry send failed:", _);
|
|
573
582
|
}
|
|
574
|
-
throw
|
|
583
|
+
throw v;
|
|
575
584
|
}
|
|
576
|
-
const
|
|
585
|
+
const S = Date.now();
|
|
577
586
|
try {
|
|
578
|
-
|
|
579
|
-
const { sessionId:
|
|
580
|
-
if (
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}),
|
|
587
|
+
m().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${f.status}, Duration: ${S - l}ms`);
|
|
588
|
+
const { sessionId: v, pageVisitId: I, requestId: _ } = this.extractIdsFromTraceHeader(d), $ = m(), k = { apiKey: $.apiKey, requestId: _, pageVisitId: I, recordingSessionId: v, serviceUuid: $.serviceUUID, timestampStart: l.toString(), timestampEnd: S.toString(), responseCode: f.status, success: !0, error: null, url: a, method: s, retryWithoutTraceId: y, parentSpanId: H() };
|
|
589
|
+
if ($.captureRequestHeaders) {
|
|
590
|
+
const E = {};
|
|
591
|
+
d.forEach((F, N) => {
|
|
592
|
+
E[N] = F;
|
|
593
|
+
}), k.requestHeaders = E;
|
|
585
594
|
}
|
|
586
|
-
if (
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}),
|
|
595
|
+
if ($.captureResponseHeaders) {
|
|
596
|
+
const E = {};
|
|
597
|
+
f.headers.forEach((F, N) => {
|
|
598
|
+
E[N] = F;
|
|
599
|
+
}), k.responseHeaders = E;
|
|
591
600
|
}
|
|
592
|
-
if (
|
|
593
|
-
const
|
|
601
|
+
if ($.captureRequestBody && i?.body) {
|
|
602
|
+
const E = i.body, F = $.requestBodyLimitBytes;
|
|
594
603
|
try {
|
|
595
|
-
if (typeof
|
|
596
|
-
else if (
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
} else if (typeof ArrayBuffer < "u" && (
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
} else if (typeof Blob < "u" &&
|
|
603
|
-
else if (typeof FormData < "u" &&
|
|
604
|
-
else if (typeof ReadableStream < "u" &&
|
|
604
|
+
if (typeof E == "string") k.requestBody = E.length > F ? E.substring(0, F) + "...[truncated]" : E;
|
|
605
|
+
else if (E instanceof URLSearchParams) {
|
|
606
|
+
const N = E.toString();
|
|
607
|
+
k.requestBody = N.length > F ? N.substring(0, F) + "...[truncated]" : N;
|
|
608
|
+
} else if (typeof ArrayBuffer < "u" && (E instanceof ArrayBuffer || ArrayBuffer.isView(E))) {
|
|
609
|
+
const N = E.byteLength ?? E.byteLength;
|
|
610
|
+
k.requestBody = `[binary body, ${N} bytes — not captured]`;
|
|
611
|
+
} else if (typeof Blob < "u" && E instanceof Blob) k.requestBody = `[Blob, ${E.size} bytes, type=${E.type || "unknown"} — not captured]`;
|
|
612
|
+
else if (typeof FormData < "u" && E instanceof FormData) k.requestBody = "[FormData — not captured]";
|
|
613
|
+
else if (typeof ReadableStream < "u" && E instanceof ReadableStream) k.requestBody = "[ReadableStream — not captured]";
|
|
605
614
|
else {
|
|
606
|
-
const
|
|
607
|
-
|
|
615
|
+
const N = JSON.stringify(E);
|
|
616
|
+
N && N !== "{}" && (k.requestBody = N.length > F ? N.substring(0, F) + "...[truncated]" : N);
|
|
608
617
|
}
|
|
609
618
|
} catch {
|
|
610
619
|
}
|
|
611
620
|
}
|
|
612
|
-
let
|
|
613
|
-
if (
|
|
614
|
-
const
|
|
615
|
-
if (!
|
|
616
|
-
const
|
|
617
|
-
|
|
621
|
+
let q;
|
|
622
|
+
if ($.captureResponseBody) {
|
|
623
|
+
const E = (f.headers.get("content-type") || "").toLowerCase();
|
|
624
|
+
if (!E || E.includes("json") || E.includes("xml") || E.includes("text/") || E.includes("javascript") || E.includes("ecmascript") || E.includes("x-www-form-urlencoded") || E.includes("application/graphql")) {
|
|
625
|
+
const F = f.clone(), N = $.responseBodyLimitBytes;
|
|
626
|
+
q = (async () => {
|
|
618
627
|
try {
|
|
619
|
-
const
|
|
628
|
+
const M = await F.text(), K = M.length > N ? M.substring(0, N) + "...[truncated]" : M;
|
|
620
629
|
try {
|
|
621
|
-
e.doSend({ ...
|
|
630
|
+
e.doSend({ ...k, responseBody: K });
|
|
622
631
|
} catch {
|
|
623
632
|
}
|
|
624
633
|
} catch {
|
|
625
634
|
}
|
|
626
|
-
})(),
|
|
635
|
+
})(), q.catch(() => {
|
|
627
636
|
});
|
|
628
|
-
} else
|
|
637
|
+
} else k.responseBody = `[non-text body, content-type=${E} — not captured]`;
|
|
629
638
|
}
|
|
630
|
-
|
|
631
|
-
} catch (
|
|
632
|
-
|
|
639
|
+
q || e.doSend(k);
|
|
640
|
+
} catch (v) {
|
|
641
|
+
m().sfDebug && console.error("[RequestInterceptor] Post-fetch telemetry failed (response still returned):", v);
|
|
633
642
|
}
|
|
634
|
-
return
|
|
635
|
-
} :
|
|
643
|
+
return f;
|
|
644
|
+
} : m().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
|
|
636
645
|
}
|
|
637
|
-
setHeader(t, e,
|
|
638
|
-
t instanceof Headers ? t.set(e,
|
|
646
|
+
setHeader(t, e, o) {
|
|
647
|
+
t instanceof Headers ? t.set(e, o) : t[e] = o;
|
|
639
648
|
}
|
|
640
649
|
addTracingHeadersToPlainObject(t, e) {
|
|
641
|
-
const
|
|
642
|
-
if (
|
|
643
|
-
const
|
|
644
|
-
if (
|
|
645
|
-
const
|
|
646
|
-
if (
|
|
650
|
+
const o = this.shouldPropagateHeaders(e);
|
|
651
|
+
if (o) {
|
|
652
|
+
const r = ve();
|
|
653
|
+
if (r) {
|
|
654
|
+
const s = Ie(r);
|
|
655
|
+
if (s && s.sample_rate === 0) return m().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${e}`), !1;
|
|
647
656
|
}
|
|
648
|
-
const
|
|
649
|
-
t[this.HEADER_TRACING] = `${
|
|
650
|
-
} else if (
|
|
651
|
-
let
|
|
657
|
+
const i = this.contextManager.getOrSetSfTraceId(), { base: d, parent: l } = this.deriveTraceBaseAndParent(i), a = G();
|
|
658
|
+
t[this.HEADER_TRACING] = `${d}/${a}`, t[Be] = l, m().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${e}`);
|
|
659
|
+
} else if (m().sfDebug) {
|
|
660
|
+
let r = e;
|
|
652
661
|
try {
|
|
653
|
-
|
|
662
|
+
r = new URL(e).hostname;
|
|
654
663
|
} catch {
|
|
655
664
|
}
|
|
656
|
-
console.error(`[RequestInterceptor] Excluded domain: ${
|
|
665
|
+
console.error(`[RequestInterceptor] Excluded domain: ${r}`);
|
|
657
666
|
}
|
|
658
|
-
return
|
|
667
|
+
return o;
|
|
659
668
|
}
|
|
660
669
|
patchHttp(t, e) {
|
|
661
|
-
if (
|
|
662
|
-
const
|
|
663
|
-
let
|
|
664
|
-
if (typeof
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
} else
|
|
668
|
-
return
|
|
669
|
-
},
|
|
670
|
-
const [
|
|
670
|
+
if (m().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !Q || typeof Q.request != "function") return void (m().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
|
|
671
|
+
const o = Q.request.bind(Q), r = re.request.bind(re), i = (a, s, u, c = Re) => {
|
|
672
|
+
let p, h;
|
|
673
|
+
if (typeof a == "string" || a instanceof URL) {
|
|
674
|
+
const g = typeof a == "string" ? new URL(a) : a;
|
|
675
|
+
p = { ...typeof s == "object" && s !== null ? s : {}, protocol: g.protocol || c, hostname: g.hostname, port: g.port || void 0, path: g.pathname + g.search }, h = typeof s == "function" ? s : u;
|
|
676
|
+
} else p = { ...a }, p.protocol || (p.protocol = c), h = typeof s == "function" ? s : void 0;
|
|
677
|
+
return p.headers || (p.headers = {}), [p, h];
|
|
678
|
+
}, d = (a, s, u) => {
|
|
679
|
+
const [c, p] = i(a, s, u, Re);
|
|
671
680
|
try {
|
|
672
|
-
const
|
|
673
|
-
this.addTracingHeadersToPlainObject(
|
|
674
|
-
} catch (
|
|
675
|
-
|
|
681
|
+
const y = `${c.protocol}//${c.hostname}`;
|
|
682
|
+
this.addTracingHeadersToPlainObject(c.headers, y), this.captureFirstUserLines(t);
|
|
683
|
+
} catch (y) {
|
|
684
|
+
m().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", y);
|
|
676
685
|
}
|
|
677
|
-
const
|
|
686
|
+
const h = (c.method || "GET").toUpperCase(), g = m().retryOnClientError, f = (y, S, v) => {
|
|
678
687
|
try {
|
|
679
|
-
const { sessionId:
|
|
680
|
-
e.doSend({ apiKey:
|
|
688
|
+
const { sessionId: I, pageVisitId: _, requestId: $ } = this.extractIdsFromTraceHeader(c.headers);
|
|
689
|
+
e.doSend({ apiKey: m().apiKey, requestId: $, pageVisitId: _, recordingSessionId: I, serviceUuid: m().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: y.statusCode || 0, success: !!y.statusCode && y.statusCode < 400, error: null, url: S, method: h, retryWithoutTraceId: v, parentSpanId: H() });
|
|
681
690
|
} catch {
|
|
682
691
|
}
|
|
683
|
-
|
|
692
|
+
p?.(y);
|
|
684
693
|
};
|
|
685
|
-
return
|
|
686
|
-
const
|
|
687
|
-
let
|
|
694
|
+
return o(c, (y) => {
|
|
695
|
+
const S = `${c.protocol}//${c.hostname}`;
|
|
696
|
+
let v = !1;
|
|
688
697
|
try {
|
|
689
|
-
|
|
698
|
+
v = this.shouldPropagateHeaders(S);
|
|
690
699
|
} catch {
|
|
691
|
-
|
|
700
|
+
v = !1;
|
|
692
701
|
}
|
|
693
|
-
if (
|
|
694
|
-
|
|
702
|
+
if (v && ye(h, g) && he.includes(y.statusCode || 0)) {
|
|
703
|
+
y.resume();
|
|
695
704
|
try {
|
|
696
|
-
const { sessionId:
|
|
697
|
-
e.doSend({ apiKey:
|
|
705
|
+
const { sessionId: _, pageVisitId: $, requestId: k } = this.extractIdsFromTraceHeader(c.headers);
|
|
706
|
+
e.doSend({ apiKey: m().apiKey, requestId: k, pageVisitId: $, recordingSessionId: _, serviceUuid: m().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: y.statusCode || 0, success: !1, error: null, url: S, method: h, retryWithoutTraceId: !1, parentSpanId: H() });
|
|
698
707
|
} catch {
|
|
699
708
|
}
|
|
700
709
|
try {
|
|
701
710
|
this.captureFirstUserLines(t, 10, !0);
|
|
702
711
|
} catch {
|
|
703
712
|
}
|
|
704
|
-
const
|
|
705
|
-
return delete
|
|
706
|
-
|
|
713
|
+
const I = { ...c, headers: { ...c.headers } };
|
|
714
|
+
return delete I.headers[this.HEADER_TRACING], void o(I, (_) => {
|
|
715
|
+
f(_, S, !0);
|
|
707
716
|
}).end();
|
|
708
717
|
}
|
|
709
|
-
|
|
718
|
+
f(y, S, !1);
|
|
710
719
|
});
|
|
711
|
-
},
|
|
712
|
-
const [
|
|
720
|
+
}, l = (a, s, u) => {
|
|
721
|
+
const [c, p] = i(a, s, u, "https:");
|
|
713
722
|
try {
|
|
714
|
-
const
|
|
715
|
-
this.addTracingHeadersToPlainObject(
|
|
716
|
-
} catch (
|
|
717
|
-
|
|
723
|
+
const y = `${c.protocol}//${c.hostname}`;
|
|
724
|
+
this.addTracingHeadersToPlainObject(c.headers, y), this.captureFirstUserLines(t);
|
|
725
|
+
} catch (y) {
|
|
726
|
+
m().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", y);
|
|
718
727
|
}
|
|
719
|
-
const
|
|
728
|
+
const h = (c.method || "GET").toUpperCase(), g = m().retryOnClientError, f = (y, S, v) => {
|
|
720
729
|
try {
|
|
721
|
-
const { sessionId:
|
|
722
|
-
e.doSend({ apiKey:
|
|
730
|
+
const { sessionId: I, pageVisitId: _, requestId: $ } = this.extractIdsFromTraceHeader(c.headers);
|
|
731
|
+
e.doSend({ apiKey: m().apiKey, requestId: $, pageVisitId: _, recordingSessionId: I, serviceUuid: m().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: y.statusCode || 0, success: !!y.statusCode && y.statusCode < 400, error: null, url: S, method: h, retryWithoutTraceId: v, parentSpanId: H() });
|
|
723
732
|
} catch {
|
|
724
733
|
}
|
|
725
|
-
|
|
734
|
+
p?.(y);
|
|
726
735
|
};
|
|
727
|
-
return
|
|
728
|
-
const
|
|
729
|
-
let
|
|
736
|
+
return r(c, (y) => {
|
|
737
|
+
const S = `${c.protocol}//${c.hostname}`;
|
|
738
|
+
let v = !1;
|
|
730
739
|
try {
|
|
731
|
-
|
|
740
|
+
v = this.shouldPropagateHeaders(S);
|
|
732
741
|
} catch {
|
|
733
|
-
|
|
742
|
+
v = !1;
|
|
734
743
|
}
|
|
735
|
-
if (
|
|
736
|
-
|
|
744
|
+
if (v && ye(h, g) && he.includes(y.statusCode || 0)) {
|
|
745
|
+
y.resume();
|
|
737
746
|
try {
|
|
738
|
-
const { sessionId:
|
|
739
|
-
e.doSend({ apiKey:
|
|
747
|
+
const { sessionId: _, pageVisitId: $, requestId: k } = this.extractIdsFromTraceHeader(c.headers);
|
|
748
|
+
e.doSend({ apiKey: m().apiKey, requestId: k, pageVisitId: $, recordingSessionId: _, serviceUuid: m().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: y.statusCode || 0, success: !1, error: null, url: S, method: h, retryWithoutTraceId: !1, parentSpanId: H() });
|
|
740
749
|
} catch {
|
|
741
750
|
}
|
|
742
751
|
try {
|
|
743
752
|
this.captureFirstUserLines(t, 10, !0);
|
|
744
753
|
} catch {
|
|
745
754
|
}
|
|
746
|
-
const
|
|
747
|
-
return delete
|
|
748
|
-
|
|
755
|
+
const I = { ...c, headers: { ...c.headers } };
|
|
756
|
+
return delete I.headers[this.HEADER_TRACING], void r(I, (_) => {
|
|
757
|
+
f(_, S, !0);
|
|
749
758
|
}).end();
|
|
750
759
|
}
|
|
751
|
-
|
|
760
|
+
f(y, S, !1);
|
|
752
761
|
});
|
|
753
762
|
};
|
|
754
|
-
|
|
755
|
-
const
|
|
756
|
-
return
|
|
757
|
-
},
|
|
758
|
-
const
|
|
759
|
-
return
|
|
760
|
-
},
|
|
763
|
+
Q.request = d, re.request = l, Q.get = (a, s, u) => {
|
|
764
|
+
const c = d(a, s, u);
|
|
765
|
+
return c.end(), c;
|
|
766
|
+
}, re.get = (a, s, u) => {
|
|
767
|
+
const c = l(a, s, u);
|
|
768
|
+
return c.end(), c;
|
|
769
|
+
}, m().sfDebug && console.log("✅ HTTP and HTTPS request/get methods patched globally.");
|
|
761
770
|
}
|
|
762
771
|
tryPatch(t, e) {
|
|
763
772
|
try {
|
|
@@ -769,7 +778,7 @@ class Ye {
|
|
|
769
778
|
return [...this.contextManager.getExcludedDomains()];
|
|
770
779
|
}
|
|
771
780
|
}
|
|
772
|
-
class
|
|
781
|
+
class Gt extends Ce {
|
|
773
782
|
constructor() {
|
|
774
783
|
super(), this.setOperationName("UpdateServiceDetails");
|
|
775
784
|
}
|
|
@@ -819,386 +828,1422 @@ class Ze extends re {
|
|
|
819
828
|
serviceRole: $serviceRole,
|
|
820
829
|
)
|
|
821
830
|
}
|
|
822
|
-
`, e =
|
|
823
|
-
|
|
831
|
+
`, e = m(), o = 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 });
|
|
832
|
+
j(this.endpoint, this.operationName, t, o);
|
|
824
833
|
}
|
|
825
834
|
}
|
|
826
|
-
class
|
|
835
|
+
class zt {
|
|
827
836
|
constructor(t = [process.cwd()], e = !1) {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
837
|
+
D(this, "rootPaths");
|
|
838
|
+
D(this, "fileConfigs", /* @__PURE__ */ new Map());
|
|
839
|
+
D(this, "functionConfigs", /* @__PURE__ */ new Map());
|
|
840
|
+
D(this, "directoryConfigs", /* @__PURE__ */ new Map());
|
|
841
|
+
D(this, "hasSailfishFiles", !1);
|
|
842
|
+
D(this, "runtimeModeEnabled", !1);
|
|
843
|
+
D(this, "debug");
|
|
835
844
|
this.rootPaths = t, this.debug = e || process.env.SF_DEBUG === "true";
|
|
836
845
|
}
|
|
837
846
|
async loadAllConfigs() {
|
|
838
847
|
this.debug && console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:", this.rootPaths);
|
|
839
848
|
const t = [];
|
|
840
|
-
for (const e of this.rootPaths)
|
|
849
|
+
for (const e of this.rootPaths) At.existsSync(e) ? await this._walkDirectory(e, t) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${e}`);
|
|
841
850
|
t.length > 0 ? (this.hasSailfishFiles = !0, this.debug && (console.log(`[FuncSpan ConfigLoader] Found ${t.length} .sailfish files:`), t.forEach((e) => console.log(`[FuncSpan ConfigLoader] - ${e}`)))) : this.debug && console.log("[FuncSpan ConfigLoader] No .sailfish files found - function spans disabled by default");
|
|
842
851
|
for (const e of t) await this._loadConfigFile(e);
|
|
843
852
|
await this._resolveInheritance(), this.debug && console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`);
|
|
844
853
|
}
|
|
845
854
|
getConfig(t, e) {
|
|
846
|
-
const
|
|
847
|
-
let
|
|
855
|
+
const o = this.hasSailfishFiles ? wt() : rt(), r = this._getDirectoryConfig(t), i = B.normalize(t), d = this.fileConfigs.get(i) || {};
|
|
856
|
+
let l = {};
|
|
848
857
|
if (e) {
|
|
849
|
-
const
|
|
850
|
-
|
|
858
|
+
const a = this.functionConfigs.get(i);
|
|
859
|
+
a && (l = a.get(e) || {});
|
|
851
860
|
}
|
|
852
|
-
return
|
|
861
|
+
return te(o, r, d, l);
|
|
853
862
|
}
|
|
854
863
|
hasRuntimeMode() {
|
|
855
864
|
return this.runtimeModeEnabled;
|
|
856
865
|
}
|
|
857
866
|
async _walkDirectory(t, e) {
|
|
858
867
|
try {
|
|
859
|
-
const
|
|
860
|
-
for (const
|
|
861
|
-
const
|
|
862
|
-
|
|
868
|
+
const o = await Ae.readdir(t, { withFileTypes: !0 });
|
|
869
|
+
for (const r of o) {
|
|
870
|
+
const i = B.join(t, r.name);
|
|
871
|
+
r.isFile() && r.name === ".sailfish" ? e.push(i) : r.name === "node_modules" || r.isDirectory() && r.name.startsWith(".") && r.name !== ".sailfish" || r.isDirectory() && await this._walkDirectory(i, e);
|
|
863
872
|
}
|
|
864
|
-
} catch (
|
|
865
|
-
this.debug && console.error(`[FuncSpan ConfigLoader] Error walking directory ${t}:`,
|
|
873
|
+
} catch (o) {
|
|
874
|
+
this.debug && console.error(`[FuncSpan ConfigLoader] Error walking directory ${t}:`, o);
|
|
866
875
|
}
|
|
867
876
|
}
|
|
868
877
|
async _loadConfigFile(t) {
|
|
869
878
|
try {
|
|
870
|
-
const e = await
|
|
871
|
-
let
|
|
879
|
+
const e = await Ae.readFile(t, "utf-8"), o = B.dirname(t);
|
|
880
|
+
let r = null;
|
|
872
881
|
try {
|
|
873
|
-
|
|
882
|
+
r = JSON.parse(e);
|
|
874
883
|
} catch {
|
|
875
884
|
try {
|
|
876
|
-
|
|
885
|
+
r = require("toml").parse(e);
|
|
877
886
|
} catch {
|
|
878
887
|
try {
|
|
879
|
-
|
|
880
|
-
} catch (
|
|
881
|
-
return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${t} as JSON, TOML, or YAML:`,
|
|
888
|
+
r = require("js-yaml").load(e);
|
|
889
|
+
} catch (i) {
|
|
890
|
+
return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${t} as JSON, TOML, or YAML:`, i));
|
|
882
891
|
}
|
|
883
892
|
}
|
|
884
893
|
}
|
|
885
|
-
if (!
|
|
886
|
-
|
|
894
|
+
if (!r) return;
|
|
895
|
+
r.runtime_mode === !0 && (this.runtimeModeEnabled = !0, this.debug && console.log(`[FuncSpan ConfigLoader] Runtime mode ENABLED in ${t}`)), r.default && this.directoryConfigs.set(o, r.default), r.files && await this._expandFileGlobs(o, r.files, r.default || {}), r.functions && this._storeFunctionConfigs(o, r.functions, r.default || {}), this.debug && (console.log(`[FuncSpan ConfigLoader] Loaded config from ${t}`), console.log(`[FuncSpan ConfigLoader] Directory: ${o}`), console.log(`[FuncSpan ConfigLoader] Has default: ${!!r.default}`), console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(r.files || {}).length}`), console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(r.functions || {}).length}`));
|
|
887
896
|
} catch (e) {
|
|
888
897
|
this.debug && console.error(`[FuncSpan ConfigLoader] Error loading ${t}:`, e);
|
|
889
898
|
}
|
|
890
899
|
}
|
|
891
|
-
async _expandFileGlobs(t, e,
|
|
892
|
-
for (const [
|
|
893
|
-
const
|
|
894
|
-
this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${
|
|
895
|
-
for (const
|
|
896
|
-
const
|
|
897
|
-
this.fileConfigs.set(
|
|
900
|
+
async _expandFileGlobs(t, e, o) {
|
|
901
|
+
for (const [r, i] of Object.entries(e)) try {
|
|
902
|
+
const d = B.join(t, r), l = await Ot(d, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
|
|
903
|
+
this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${r}' matched ${l.length} files`);
|
|
904
|
+
for (const a of l) {
|
|
905
|
+
const s = B.normalize(a), u = te(o, i);
|
|
906
|
+
this.fileConfigs.set(s, u), this.debug && l.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${a}`);
|
|
898
907
|
}
|
|
899
|
-
} catch (
|
|
900
|
-
this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${
|
|
908
|
+
} catch (d) {
|
|
909
|
+
this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${r}':`, d);
|
|
901
910
|
}
|
|
902
911
|
}
|
|
903
|
-
_storeFunctionConfigs(t, e,
|
|
904
|
-
for (const [
|
|
905
|
-
const
|
|
906
|
-
if (
|
|
907
|
-
this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${
|
|
912
|
+
_storeFunctionConfigs(t, e, o) {
|
|
913
|
+
for (const [r, i] of Object.entries(e)) {
|
|
914
|
+
const d = r.split("::");
|
|
915
|
+
if (d.length !== 2) {
|
|
916
|
+
this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${r}' (expected format: 'file.ts::functionName')`);
|
|
908
917
|
continue;
|
|
909
918
|
}
|
|
910
|
-
const [
|
|
911
|
-
this.functionConfigs.has(
|
|
912
|
-
const
|
|
913
|
-
|
|
919
|
+
const [l, a] = d, s = B.normalize(B.join(t, l));
|
|
920
|
+
this.functionConfigs.has(s) || this.functionConfigs.set(s, /* @__PURE__ */ new Map());
|
|
921
|
+
const u = this.functionConfigs.get(s), c = te(o, i);
|
|
922
|
+
u.set(a, c), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${s}::${a}`);
|
|
914
923
|
}
|
|
915
924
|
}
|
|
916
925
|
async _resolveInheritance() {
|
|
917
926
|
}
|
|
918
927
|
_getDirectoryConfig(t) {
|
|
919
|
-
let e =
|
|
920
|
-
const
|
|
921
|
-
for (; e && e !==
|
|
922
|
-
const
|
|
923
|
-
|
|
928
|
+
let e = B.dirname(B.normalize(t));
|
|
929
|
+
const o = [];
|
|
930
|
+
for (; e && e !== B.dirname(e); ) {
|
|
931
|
+
const r = this.directoryConfigs.get(e);
|
|
932
|
+
r && o.unshift(r), e = B.dirname(e);
|
|
924
933
|
}
|
|
925
|
-
return
|
|
934
|
+
return o.reduce((r, i) => te(r, i), {});
|
|
926
935
|
}
|
|
927
936
|
}
|
|
928
|
-
const
|
|
929
|
-
function
|
|
930
|
-
return globalThis[
|
|
937
|
+
const at = "__sf_globalConfigLoader";
|
|
938
|
+
function ct() {
|
|
939
|
+
return globalThis[at] ?? null;
|
|
931
940
|
}
|
|
932
|
-
async function
|
|
933
|
-
const e = new
|
|
934
|
-
(function(
|
|
935
|
-
globalThis[
|
|
941
|
+
async function Vt(n, t) {
|
|
942
|
+
const e = new zt(n, t);
|
|
943
|
+
(function(o) {
|
|
944
|
+
globalThis[at] = o;
|
|
936
945
|
})(e), await e.loadAllConfigs();
|
|
937
946
|
}
|
|
938
|
-
function
|
|
939
|
-
const e =
|
|
940
|
-
return e ? e.getConfig(
|
|
947
|
+
function Xt(n, t) {
|
|
948
|
+
const e = ct();
|
|
949
|
+
return e ? e.getConfig(n, t) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using default config (disabled)"), rt());
|
|
941
950
|
}
|
|
942
|
-
function
|
|
943
|
-
return
|
|
951
|
+
function Yt() {
|
|
952
|
+
return ct() !== null;
|
|
944
953
|
}
|
|
945
|
-
const
|
|
946
|
-
let
|
|
947
|
-
function
|
|
948
|
-
if (typeof
|
|
954
|
+
const Zt = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], He = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], en = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], tn = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
|
|
955
|
+
let xe = !1;
|
|
956
|
+
function nn(n) {
|
|
957
|
+
if (typeof n != "string") return !1;
|
|
949
958
|
const t = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
950
|
-
if (t &&
|
|
959
|
+
if (t && n.includes(t)) return !0;
|
|
951
960
|
const e = process.env.SF_WORKER_POOL_JSONL_FILE;
|
|
952
|
-
return !(!e || !
|
|
961
|
+
return !(!e || !n.includes(e));
|
|
953
962
|
}
|
|
954
|
-
let
|
|
955
|
-
function
|
|
956
|
-
if (typeof
|
|
957
|
-
if (
|
|
963
|
+
let je = !1;
|
|
964
|
+
function Ke(n) {
|
|
965
|
+
if (typeof n != "string") return !1;
|
|
966
|
+
if (n === "localhost" || n === "127.0.0.1" || n === "::1") return !0;
|
|
958
967
|
try {
|
|
959
968
|
const t = process.env.API_GRAPHQL_ENDPOINT;
|
|
960
|
-
if (t &&
|
|
969
|
+
if (t && n === new URL(t).hostname)
|
|
961
970
|
return !0;
|
|
962
971
|
} catch {
|
|
963
972
|
}
|
|
964
973
|
return !1;
|
|
965
974
|
}
|
|
966
|
-
function
|
|
967
|
-
if (!
|
|
968
|
-
let
|
|
975
|
+
function rn() {
|
|
976
|
+
if (!je) try {
|
|
977
|
+
let n;
|
|
969
978
|
if (typeof require > "u") return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Skipping dns patching in pure ESM environment (require unavailable)"));
|
|
970
979
|
try {
|
|
971
|
-
|
|
980
|
+
n = require("node:dns");
|
|
972
981
|
} catch (t) {
|
|
973
982
|
return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Failed to require dns module:", t));
|
|
974
983
|
}
|
|
975
|
-
if (
|
|
976
|
-
Object.defineProperty(
|
|
977
|
-
for (const t of
|
|
978
|
-
const e =
|
|
979
|
-
|
|
980
|
-
return
|
|
981
|
-
}, Object.defineProperty(
|
|
984
|
+
if (n.__sf_worker_pool_patched__) return;
|
|
985
|
+
Object.defineProperty(n, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
986
|
+
for (const t of He) if (typeof n[t] == "function") {
|
|
987
|
+
const e = n[t];
|
|
988
|
+
n[t] = function(...o) {
|
|
989
|
+
return Te() ? e.apply(this, o) : Ke(o[0]) ? e.apply(this, o) : typeof o[o.length - 1] == "function" ? ie("dns", t, e, o, this) : e.apply(this, o);
|
|
990
|
+
}, Object.defineProperty(n[t], "name", { value: t, writable: !1 });
|
|
982
991
|
}
|
|
983
992
|
(function(t) {
|
|
984
993
|
if (!t.promises) return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises not available, skipping"));
|
|
985
994
|
if (!t.promises.__sf_worker_pool_patched__) {
|
|
986
995
|
Object.defineProperty(t.promises, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
987
|
-
for (const e of
|
|
988
|
-
const
|
|
989
|
-
t.promises[e] = function(...
|
|
990
|
-
return
|
|
996
|
+
for (const e of He) if (typeof t.promises[e] == "function") {
|
|
997
|
+
const o = t.promises[e];
|
|
998
|
+
t.promises[e] = function(...r) {
|
|
999
|
+
return Te() ? o.apply(this, r) : Ke(r[0]) ? o.apply(this, r) : kt("dns", e, o, r, this);
|
|
991
1000
|
}, Object.defineProperty(t.promises[e], "name", { value: e, writable: !1 });
|
|
992
1001
|
}
|
|
993
1002
|
process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises module patched successfully");
|
|
994
1003
|
}
|
|
995
|
-
})(
|
|
996
|
-
} catch (
|
|
997
|
-
console.error("[WorkerPool] Error patching dns module:",
|
|
1004
|
+
})(n), je = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
|
|
1005
|
+
} catch (n) {
|
|
1006
|
+
console.error("[WorkerPool] Error patching dns module:", n);
|
|
998
1007
|
}
|
|
999
1008
|
}
|
|
1000
|
-
let
|
|
1001
|
-
function
|
|
1002
|
-
if (
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
if (!
|
|
1009
|
+
let Qe = !1, Je = !1, $e = !1;
|
|
1010
|
+
function on() {
|
|
1011
|
+
if ($e) return;
|
|
1012
|
+
const n = process.env.SF_DEBUG === "true";
|
|
1013
|
+
n && console.log("[WorkerPool] Initializing worker pool patching..."), ne("fs") && (n && console.log("[WorkerPool] Patching fs module..."), (function() {
|
|
1014
|
+
if (!xe) try {
|
|
1006
1015
|
const t = require("node:fs");
|
|
1007
1016
|
if (t.__sf_worker_pool_patched__) return;
|
|
1008
1017
|
Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
1009
|
-
for (const e of
|
|
1010
|
-
const
|
|
1011
|
-
t[e] = function(...
|
|
1012
|
-
return
|
|
1018
|
+
for (const e of Zt) if (typeof t[e] == "function") {
|
|
1019
|
+
const o = t[e];
|
|
1020
|
+
t[e] = function(...r) {
|
|
1021
|
+
return nn(r[0]) ? o.apply(this, r) : typeof r[r.length - 1] == "function" ? ie("fs", e, o, r, this) : o.apply(this, r);
|
|
1013
1022
|
}, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
|
|
1014
1023
|
}
|
|
1015
|
-
|
|
1024
|
+
xe = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
|
|
1016
1025
|
} catch (t) {
|
|
1017
1026
|
console.error("[WorkerPool] Error patching fs module:", t);
|
|
1018
1027
|
}
|
|
1019
|
-
})()),
|
|
1020
|
-
if (!
|
|
1028
|
+
})()), ne("dns") && (n && console.log("[WorkerPool] Patching dns module..."), rn()), ne("crypto") && (n && console.log("[WorkerPool] Patching crypto module..."), (function() {
|
|
1029
|
+
if (!Qe) try {
|
|
1021
1030
|
const t = require("node:crypto");
|
|
1022
1031
|
if (t.__sf_worker_pool_patched__) return;
|
|
1023
1032
|
Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
1024
|
-
for (const e of
|
|
1025
|
-
const
|
|
1026
|
-
t[e] = function(...
|
|
1027
|
-
return typeof
|
|
1033
|
+
for (const e of en) if (typeof t[e] == "function") {
|
|
1034
|
+
const o = t[e];
|
|
1035
|
+
t[e] = function(...r) {
|
|
1036
|
+
return typeof r[r.length - 1] == "function" ? ie("crypto", e, o, r, this) : o.apply(this, r);
|
|
1028
1037
|
}, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
|
|
1029
1038
|
}
|
|
1030
|
-
|
|
1039
|
+
Qe = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
|
|
1031
1040
|
} catch (t) {
|
|
1032
1041
|
console.error("[WorkerPool] Error patching crypto module:", t);
|
|
1033
1042
|
}
|
|
1034
|
-
})()),
|
|
1035
|
-
if (!
|
|
1043
|
+
})()), ne("zlib") && (n && console.log("[WorkerPool] Patching zlib module..."), (function() {
|
|
1044
|
+
if (!Je) try {
|
|
1036
1045
|
const t = require("node:zlib");
|
|
1037
1046
|
if (t.__sf_worker_pool_patched__) return;
|
|
1038
1047
|
Object.defineProperty(t, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
1039
|
-
for (const e of
|
|
1040
|
-
const
|
|
1041
|
-
t[e] = function(...
|
|
1042
|
-
return typeof
|
|
1048
|
+
for (const e of tn) if (typeof t[e] == "function") {
|
|
1049
|
+
const o = t[e];
|
|
1050
|
+
t[e] = function(...r) {
|
|
1051
|
+
return typeof r[r.length - 1] == "function" ? ie("zlib", e, o, r, this) : o.apply(this, r);
|
|
1043
1052
|
}, Object.defineProperty(t[e], "name", { value: e, writable: !1 });
|
|
1044
1053
|
}
|
|
1045
|
-
|
|
1054
|
+
Je = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
|
|
1046
1055
|
} catch (t) {
|
|
1047
1056
|
console.error("[WorkerPool] Error patching zlib module:", t);
|
|
1048
1057
|
}
|
|
1049
|
-
})()),
|
|
1058
|
+
})()), $e = !0, n && console.log("[WorkerPool] Worker pool patching initialized");
|
|
1059
|
+
}
|
|
1060
|
+
function sn() {
|
|
1061
|
+
return $e;
|
|
1062
|
+
}
|
|
1063
|
+
const We = Y.toLowerCase();
|
|
1064
|
+
function W(n) {
|
|
1065
|
+
if (n != null) {
|
|
1066
|
+
if (Array.isArray(n)) {
|
|
1067
|
+
for (const t of n)
|
|
1068
|
+
if (!(!t || typeof t != "object") && Ge(t.key) === We)
|
|
1069
|
+
return t.value;
|
|
1070
|
+
} else if (typeof n == "object") {
|
|
1071
|
+
for (const [t, e] of Object.entries(n)) if (Ge(t) === We)
|
|
1072
|
+
return Array.isArray(e) ? e.length === 0 ? void 0 : e[0] : e;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1050
1075
|
}
|
|
1076
|
+
function Ge(n) {
|
|
1077
|
+
if (typeof n == "string") return n.toLowerCase();
|
|
1078
|
+
if (Buffer.isBuffer(n)) try {
|
|
1079
|
+
return n.toString("utf8").toLowerCase();
|
|
1080
|
+
} catch {
|
|
1081
|
+
return null;
|
|
1082
|
+
}
|
|
1083
|
+
if (n instanceof Uint8Array) try {
|
|
1084
|
+
return Buffer.from(n).toString("utf8").toLowerCase();
|
|
1085
|
+
} catch {
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
return null;
|
|
1089
|
+
}
|
|
1090
|
+
let ge = null;
|
|
1051
1091
|
function ut() {
|
|
1052
|
-
return
|
|
1092
|
+
return ge || (ge = new it()), ge;
|
|
1093
|
+
}
|
|
1094
|
+
function lt(n) {
|
|
1095
|
+
if (!n) return null;
|
|
1096
|
+
const t = n.split("/").filter(Boolean);
|
|
1097
|
+
return t.length < 3 ? null : { sessionId: t[0], pageVisitId: t[1], requestId: t[t.length - 1] };
|
|
1098
|
+
}
|
|
1099
|
+
const an = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
1100
|
+
function z(n) {
|
|
1101
|
+
if (typeof n != "string" || n.length === 0 || n.length > 1024) return !1;
|
|
1102
|
+
const t = n.split("/").filter(Boolean);
|
|
1103
|
+
if (t.length < 3 || t.length > 6) return !1;
|
|
1104
|
+
for (const e of t) if (!an.test(e)) return !1;
|
|
1105
|
+
return !0;
|
|
1106
|
+
}
|
|
1107
|
+
function V(n) {
|
|
1108
|
+
const t = n.split("/");
|
|
1109
|
+
return t.length >= 3 ? (t[t.length - 1] = G(), t.join("/")) : `${n}/${G()}`;
|
|
1110
|
+
}
|
|
1111
|
+
function cn(n) {
|
|
1112
|
+
if (n == null) return null;
|
|
1113
|
+
if (typeof n == "string") return n;
|
|
1114
|
+
if (Buffer.isBuffer(n)) try {
|
|
1115
|
+
return n.toString("utf8");
|
|
1116
|
+
} catch {
|
|
1117
|
+
return null;
|
|
1118
|
+
}
|
|
1119
|
+
try {
|
|
1120
|
+
return JSON.stringify(Ee(n));
|
|
1121
|
+
} catch {
|
|
1122
|
+
return null;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
function Ee(n, t = 0) {
|
|
1126
|
+
if (t > 10) return "[truncated-depth]";
|
|
1127
|
+
if (n == null) return n;
|
|
1128
|
+
const e = typeof n;
|
|
1129
|
+
if (e === "string" || e === "number" || e === "boolean") return n;
|
|
1130
|
+
if (e === "bigint") return n.toString();
|
|
1131
|
+
if (e !== "object") return;
|
|
1132
|
+
if (Buffer.isBuffer(n)) return `[Buffer ${n.length}b]`;
|
|
1133
|
+
if (ArrayBuffer.isView(n)) {
|
|
1134
|
+
const r = n;
|
|
1135
|
+
return `[${r.constructor?.name ?? "TypedArray"} ${r.byteLength}b]`;
|
|
1136
|
+
}
|
|
1137
|
+
if (n instanceof Date) try {
|
|
1138
|
+
return n.toISOString();
|
|
1139
|
+
} catch {
|
|
1140
|
+
return "[Date]";
|
|
1141
|
+
}
|
|
1142
|
+
if (n instanceof Map) return `[Map size=${n.size}]`;
|
|
1143
|
+
if (n instanceof Set) return `[Set size=${n.size}]`;
|
|
1144
|
+
if (Array.isArray(n)) return n.map((r) => Ee(r, t + 1));
|
|
1145
|
+
const o = {};
|
|
1146
|
+
for (const r of Object.getOwnPropertyNames(n)) {
|
|
1147
|
+
const i = Object.getOwnPropertyDescriptor(n, r);
|
|
1148
|
+
i && typeof i.get != "function" && typeof i.set != "function" && (o[r] = Ee(i.value, t + 1));
|
|
1149
|
+
}
|
|
1150
|
+
return o;
|
|
1151
|
+
}
|
|
1152
|
+
function dt(n) {
|
|
1153
|
+
if (!n) return null;
|
|
1154
|
+
try {
|
|
1155
|
+
const t = n.message;
|
|
1156
|
+
if (typeof t == "string" && t.length > 0) return t;
|
|
1157
|
+
} catch {
|
|
1158
|
+
}
|
|
1159
|
+
try {
|
|
1160
|
+
const t = String(n);
|
|
1161
|
+
if (typeof t == "string" && t.length > 0) return t;
|
|
1162
|
+
} catch {
|
|
1163
|
+
}
|
|
1164
|
+
try {
|
|
1165
|
+
const t = n.name;
|
|
1166
|
+
if (typeof t == "string" && t.length > 0) return t;
|
|
1167
|
+
} catch {
|
|
1168
|
+
}
|
|
1169
|
+
return "[unstringifiable error]";
|
|
1170
|
+
}
|
|
1171
|
+
function P(n) {
|
|
1172
|
+
const t = x.getInstance().getOrSetSfTraceId(), e = V(t), o = lt(e), r = Date.now(), i = m(), d = n.queueUri, l = n.method ?? "ENQUEUE", a = pt(n.messagePayload, i);
|
|
1173
|
+
return { traceId: e, hopEnd: (s) => {
|
|
1174
|
+
try {
|
|
1175
|
+
if (!o) return;
|
|
1176
|
+
const u = Date.now();
|
|
1177
|
+
let c = null;
|
|
1178
|
+
try {
|
|
1179
|
+
c = H() ?? null;
|
|
1180
|
+
} catch {
|
|
1181
|
+
}
|
|
1182
|
+
const p = { apiKey: i.apiKey, requestId: o.requestId, pageVisitId: o.pageVisitId, recordingSessionId: o.sessionId, serviceUuid: i.serviceUUID ?? null, timestampStart: r.toString(), timestampEnd: u.toString(), responseCode: s ? 500 : 0, success: !s, error: dt(s), url: d, method: l, parentSpanId: c };
|
|
1183
|
+
a !== null && (p.requestBody = a), ft(p);
|
|
1184
|
+
try {
|
|
1185
|
+
ut().doSend(p);
|
|
1186
|
+
} catch (h) {
|
|
1187
|
+
i.sfDebug && console.warn("[asyncQueues] producer hop transmit failed:", h);
|
|
1188
|
+
}
|
|
1189
|
+
} catch {
|
|
1190
|
+
}
|
|
1191
|
+
} };
|
|
1192
|
+
}
|
|
1193
|
+
function pt(n, t) {
|
|
1194
|
+
if (!t.captureRequestBody || n === void 0) return null;
|
|
1195
|
+
const e = cn(n);
|
|
1196
|
+
return e ? (function(o, r) {
|
|
1197
|
+
return !r || r <= 0 ? o : o.length > r ? o.substring(0, r) + "...[truncated]" : o;
|
|
1198
|
+
})(e, t.requestBodyLimitBytes) : null;
|
|
1199
|
+
}
|
|
1200
|
+
function R(n, t) {
|
|
1201
|
+
if (ze.getStore() === !0) return Promise.resolve(t());
|
|
1202
|
+
const e = x.getInstance(), o = m(), r = n.incomingTraceId !== void 0 && z(n.incomingTraceId) ? n.incomingTraceId : `${It}-v3/${o.apiKey}/${G()}`, i = n.queueUri, d = n.method, l = n.library, a = pt(n.messagePayload, o);
|
|
1203
|
+
return ze.run(!0, () => e.runScoped({ traceId: r }, async () => {
|
|
1204
|
+
const s = Date.now();
|
|
1205
|
+
let u = null;
|
|
1206
|
+
try {
|
|
1207
|
+
const c = await Promise.resolve(t());
|
|
1208
|
+
return await (function(p) {
|
|
1209
|
+
return p !== null && typeof p == "object" && typeof p.subscribe == "function" ? new Promise((h, g) => {
|
|
1210
|
+
let f, y = !1;
|
|
1211
|
+
try {
|
|
1212
|
+
p.subscribe({ next: (S) => {
|
|
1213
|
+
f = S, y = !0;
|
|
1214
|
+
}, error: (S) => g(S), complete: () => h(y ? f : void 0) });
|
|
1215
|
+
} catch (S) {
|
|
1216
|
+
g(S);
|
|
1217
|
+
}
|
|
1218
|
+
}) : p;
|
|
1219
|
+
})(c);
|
|
1220
|
+
} catch (c) {
|
|
1221
|
+
throw u = c instanceof Error ? c : new Error(String(c)), c;
|
|
1222
|
+
} finally {
|
|
1223
|
+
(function(c, p, h, g, f, y) {
|
|
1224
|
+
try {
|
|
1225
|
+
const S = lt(h);
|
|
1226
|
+
if (!S) return;
|
|
1227
|
+
const v = m(), { graceful: I, tag: _ } = (function(M) {
|
|
1228
|
+
if (!M) return { graceful: !0, tag: null };
|
|
1229
|
+
let K;
|
|
1230
|
+
try {
|
|
1231
|
+
K = M.name;
|
|
1232
|
+
} catch {
|
|
1233
|
+
return { graceful: !1, tag: null };
|
|
1234
|
+
}
|
|
1235
|
+
return K === "AbortError" ? { graceful: !0, tag: "CONSUME_CANCELLED" } : K === "DelayedError" ? { graceful: !0, tag: "CONSUME_RESCHEDULED" } : K === "WaitingChildrenError" ? { graceful: !0, tag: "CONSUME_WAITING_CHILDREN" } : { graceful: !1, tag: null };
|
|
1236
|
+
})(y), $ = !y && c.method ? c.method : _ ?? c.method ?? "CONSUME", k = !y || I, q = y && !I ? 500 : 0, E = y && !I ? dt(y) : null;
|
|
1237
|
+
let F = null;
|
|
1238
|
+
try {
|
|
1239
|
+
F = H() ?? null;
|
|
1240
|
+
} catch {
|
|
1241
|
+
}
|
|
1242
|
+
const N = { apiKey: v.apiKey, requestId: S.requestId, pageVisitId: S.pageVisitId, recordingSessionId: S.sessionId, serviceUuid: v.serviceUUID ?? null, timestampStart: g.toString(), timestampEnd: f.toString(), responseCode: q, success: k, error: E, url: c.queueUri, method: $, parentSpanId: F };
|
|
1243
|
+
p !== null && (N.requestBody = p), ft(N);
|
|
1244
|
+
try {
|
|
1245
|
+
ut().doSend(N);
|
|
1246
|
+
} catch (M) {
|
|
1247
|
+
v.sfDebug && console.warn("[asyncQueues] consumer hop transmit failed:", M);
|
|
1248
|
+
}
|
|
1249
|
+
} catch {
|
|
1250
|
+
}
|
|
1251
|
+
})({ library: l, queueUri: i, method: d }, a, r, s, Date.now(), u);
|
|
1252
|
+
}
|
|
1253
|
+
}));
|
|
1254
|
+
}
|
|
1255
|
+
const ze = new Mt();
|
|
1256
|
+
let _e = null;
|
|
1257
|
+
function Nn(n) {
|
|
1258
|
+
_e = n;
|
|
1259
|
+
}
|
|
1260
|
+
function ft(n) {
|
|
1261
|
+
if (_e !== null) try {
|
|
1262
|
+
_e(n);
|
|
1263
|
+
} catch {
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
const b = Symbol.for("sailfish.async-queues.patched"), w = Symbol.for("sailfish.async-queues.instance-wrapped"), we = [];
|
|
1267
|
+
function U(n, t, e) {
|
|
1268
|
+
if (we.some((r) => r.proto === n && r.key === t)) return !1;
|
|
1269
|
+
const o = typeof n?.[t] == "function" ? n[t] : void 0;
|
|
1270
|
+
try {
|
|
1271
|
+
return n[t] = e, we.push({ proto: n, key: t, original: o }), !0;
|
|
1272
|
+
} catch (r) {
|
|
1273
|
+
if (m().sfDebug) {
|
|
1274
|
+
const i = n?.constructor?.name ?? "<unknown>";
|
|
1275
|
+
console.warn(`[asyncQueues] could not install patch on ${i}.prototype.${t} (frozen / non-writable?):`, r);
|
|
1276
|
+
}
|
|
1277
|
+
return !1;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
function T(n, t) {
|
|
1281
|
+
try {
|
|
1282
|
+
return n();
|
|
1283
|
+
} catch (e) {
|
|
1284
|
+
return m().sfDebug && console.warn(`[asyncQueues] instrumentation rewrite threw in ${t} — falling back to original args, no hop emitted:`, e), null;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
function C(n, t) {
|
|
1288
|
+
let e = n || "unknown";
|
|
1289
|
+
if (typeof e == "string") {
|
|
1290
|
+
e.startsWith("bull:") && (e = e.slice(5));
|
|
1291
|
+
const o = /^\{([^}]+)\}:(.+)$/.exec(e);
|
|
1292
|
+
o && (e = `${o[1]}/${o[2]}`);
|
|
1293
|
+
}
|
|
1294
|
+
return `bullmq://redis/${e}/${t || "unknown"}`;
|
|
1295
|
+
}
|
|
1296
|
+
function ce(n) {
|
|
1297
|
+
return n?.queueQualifiedName ?? n?.queueName ?? n?.queue?.name ?? void 0;
|
|
1298
|
+
}
|
|
1299
|
+
function L(n, t) {
|
|
1300
|
+
const e = n ? { ...n } : {}, o = e.sf && typeof e.sf == "object" ? e.sf : {};
|
|
1301
|
+
return e.sf = { ...o, rid: t }, e;
|
|
1302
|
+
}
|
|
1303
|
+
function un(n) {
|
|
1304
|
+
let t = n;
|
|
1305
|
+
if (!t) try {
|
|
1306
|
+
t = require("bullmq");
|
|
1307
|
+
} catch {
|
|
1308
|
+
return "not-installed";
|
|
1309
|
+
}
|
|
1310
|
+
(function(a) {
|
|
1311
|
+
try {
|
|
1312
|
+
const s = a?.version ?? a?.Queue?.version;
|
|
1313
|
+
if (typeof s != "string") return;
|
|
1314
|
+
parseInt(s.split(".")[0] ?? "0", 10) < 3 && m().sfDebug && console.warn(`[sf-veritas] BullMQ ${s} detected. Async-queue tracing is best-supported on BullMQ ≥ 3.0. Some APIs (FlowProducer, upsertJobScheduler, Job.promote) may be missing on older versions and will be skipped silently.`);
|
|
1315
|
+
} catch {
|
|
1316
|
+
}
|
|
1317
|
+
})(t);
|
|
1318
|
+
const e = t.Queue, o = t.Worker;
|
|
1319
|
+
if (!e?.prototype || !o?.prototype) return m().sfDebug && console.warn("[asyncQueues][bullmq] Expected Queue/Worker classes not found on module — skipping patch."), "failed";
|
|
1320
|
+
(function(a) {
|
|
1321
|
+
const s = a.prototype.add;
|
|
1322
|
+
if (typeof s != "function" || s[b]) return;
|
|
1323
|
+
const u = async function(c, p, h) {
|
|
1324
|
+
if (h?.sf?.rid) return s.call(this, c, p, h);
|
|
1325
|
+
const g = T(() => {
|
|
1326
|
+
const y = P({ library: "bullmq", queueUri: C(this?.name, c), messagePayload: p });
|
|
1327
|
+
return { handle: y, nextOpts: L(h, y.traceId) };
|
|
1328
|
+
}, "bullmq.Queue.add");
|
|
1329
|
+
if (g === null) return s.call(this, c, p, h);
|
|
1330
|
+
let f = null;
|
|
1331
|
+
try {
|
|
1332
|
+
return await s.call(this, c, p, g.nextOpts);
|
|
1333
|
+
} catch (y) {
|
|
1334
|
+
throw f = y instanceof Error ? y : new Error(String(y)), y;
|
|
1335
|
+
} finally {
|
|
1336
|
+
g.handle.hopEnd(f);
|
|
1337
|
+
}
|
|
1338
|
+
};
|
|
1339
|
+
u[b] = !0, U(a.prototype, "add", u);
|
|
1340
|
+
})(e), (function(a) {
|
|
1341
|
+
const s = a.prototype.addBulk;
|
|
1342
|
+
if (typeof s != "function" || s[b]) return;
|
|
1343
|
+
const u = async function(c) {
|
|
1344
|
+
if (!Array.isArray(c) || c.length === 0) return s.call(this, c);
|
|
1345
|
+
if (c.every((f) => f?.opts?.sf?.rid)) return s.call(this, c);
|
|
1346
|
+
const p = m().bullmqBulkAggregateMode, h = T(() => {
|
|
1347
|
+
if (p) {
|
|
1348
|
+
const S = P({ library: "bullmq", queueUri: C(this?.name, `__bulk_${c.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: c.length } }), v = c.map((I) => ({ ...I, opts: L(I?.opts, S.traceId) }));
|
|
1349
|
+
return { handles: [S], out: v };
|
|
1350
|
+
}
|
|
1351
|
+
const f = c.map((S) => P({ library: "bullmq", queueUri: C(this?.name, S?.name), messagePayload: S?.data })), y = c.map((S, v) => ({ ...S, opts: L(S?.opts, f[v].traceId) }));
|
|
1352
|
+
return { handles: f, out: y };
|
|
1353
|
+
}, "bullmq.Queue.addBulk");
|
|
1354
|
+
if (h === null) return s.call(this, c);
|
|
1355
|
+
let g = null;
|
|
1356
|
+
try {
|
|
1357
|
+
return await s.call(this, h.out);
|
|
1358
|
+
} catch (f) {
|
|
1359
|
+
throw g = f instanceof Error ? f : new Error(String(f)), f;
|
|
1360
|
+
} finally {
|
|
1361
|
+
for (const f of h.handles) f.hopEnd(g);
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
u[b] = !0, U(a.prototype, "addBulk", u);
|
|
1365
|
+
})(e), (function(a) {
|
|
1366
|
+
const s = a.prototype.upsertJobScheduler;
|
|
1367
|
+
if (typeof s != "function" || s[b]) return;
|
|
1368
|
+
const u = async function(c, p, h) {
|
|
1369
|
+
const g = T(() => {
|
|
1370
|
+
const y = P({ library: "bullmq", queueUri: C(this?.name, h?.name ?? c), method: "ENQUEUE" });
|
|
1371
|
+
let S;
|
|
1372
|
+
if (h !== void 0) {
|
|
1373
|
+
const v = { ...h, opts: L(h.opts, y.traceId) };
|
|
1374
|
+
S = [c, p, v];
|
|
1375
|
+
} else S = [c, p];
|
|
1376
|
+
return { handle: y, callArgs: S };
|
|
1377
|
+
}, "bullmq.Queue.upsertJobScheduler");
|
|
1378
|
+
if (g === null) {
|
|
1379
|
+
const y = h !== void 0 ? [c, p, h] : [c, p];
|
|
1380
|
+
return s.call(this, ...y);
|
|
1381
|
+
}
|
|
1382
|
+
let f = null;
|
|
1383
|
+
try {
|
|
1384
|
+
return await s.call(this, ...g.callArgs);
|
|
1385
|
+
} catch (y) {
|
|
1386
|
+
throw f = y instanceof Error ? y : new Error(String(y)), y;
|
|
1387
|
+
} finally {
|
|
1388
|
+
g.handle.hopEnd(f);
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
u[b] = !0, U(a.prototype, "upsertJobScheduler", u);
|
|
1392
|
+
})(e), (function(a) {
|
|
1393
|
+
const s = a.prototype.getNextJob;
|
|
1394
|
+
if (typeof s != "function" || s[b]) return;
|
|
1395
|
+
const u = async function(...c) {
|
|
1396
|
+
const p = await s.apply(this, c);
|
|
1397
|
+
if (p && z(p.opts?.sf?.rid)) try {
|
|
1398
|
+
x.getInstance().setTraceId(p.opts.sf.rid);
|
|
1399
|
+
} catch {
|
|
1400
|
+
}
|
|
1401
|
+
return p;
|
|
1402
|
+
};
|
|
1403
|
+
u[b] = !0, U(a.prototype, "getNextJob", u);
|
|
1404
|
+
})(e), (function(a) {
|
|
1405
|
+
const s = a.prototype.getJob;
|
|
1406
|
+
if (typeof s != "function" || s[b]) return;
|
|
1407
|
+
const u = async function(...c) {
|
|
1408
|
+
const p = await s.apply(this, c);
|
|
1409
|
+
if (p && z(p.opts?.sf?.rid)) try {
|
|
1410
|
+
const g = x.getInstance();
|
|
1411
|
+
(!(h = g.getTraceId()) || h.startsWith("nonsession-applogs-v3/")) && g.setTraceId(p.opts.sf.rid);
|
|
1412
|
+
} catch {
|
|
1413
|
+
}
|
|
1414
|
+
var h;
|
|
1415
|
+
return p;
|
|
1416
|
+
};
|
|
1417
|
+
u[b] = !0, U(a.prototype, "getJob", u);
|
|
1418
|
+
})(e), (function(a) {
|
|
1419
|
+
const s = a.prototype.processJob;
|
|
1420
|
+
if (typeof s != "function" || s[b]) return;
|
|
1421
|
+
const u = function(c, ...p) {
|
|
1422
|
+
const h = c?.opts?.sf?.rid, g = typeof c?.attemptsMade == "number" ? c.attemptsMade : 0, f = typeof c?.stalledCounter == "number" ? c.stalledCounter : 0, y = c?.repeatJobKey != null || c?.opts?.repeat != null, S = h && (g > 0 || f > 0 || y) ? V(h) : h;
|
|
1423
|
+
let v;
|
|
1424
|
+
return f > 0 ? v = "CONSUME_STALLED" : y && g === 0 && (v = "CONSUME_SCHEDULED"), R({ library: "bullmq", queueUri: C(ce(c) ?? this?.name, c?.name), incomingTraceId: S, messagePayload: c?.data, method: v }, () => s.call(this, c, ...p));
|
|
1425
|
+
};
|
|
1426
|
+
u[b] = !0, U(a.prototype, "processJob", u);
|
|
1427
|
+
})(o);
|
|
1428
|
+
const r = t.Job;
|
|
1429
|
+
r?.prototype && (function(a) {
|
|
1430
|
+
const s = ["retry", "moveToDelayed", "promote"];
|
|
1431
|
+
for (const u of s) {
|
|
1432
|
+
const c = a.prototype[u];
|
|
1433
|
+
if (typeof c != "function" || c[b]) continue;
|
|
1434
|
+
const p = u === "promote" ? "PROMOTE" : u === "moveToDelayed" ? "RESCHEDULE" : "ENQUEUE_RETRY", h = async function(...g) {
|
|
1435
|
+
const f = this?.opts?.sf?.rid;
|
|
1436
|
+
let y;
|
|
1437
|
+
if (f) y = V(f);
|
|
1438
|
+
else {
|
|
1439
|
+
const I = P({ queueUri: C(ce(this) ?? this?.name, this?.name), method: p });
|
|
1440
|
+
let _ = null;
|
|
1441
|
+
try {
|
|
1442
|
+
return await c.apply(this, g);
|
|
1443
|
+
} catch ($) {
|
|
1444
|
+
throw _ = $ instanceof Error ? $ : new Error(String($)), $;
|
|
1445
|
+
} finally {
|
|
1446
|
+
I.hopEnd(_);
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
this.opts && (this.opts = { ...this.opts, sf: { ...this.opts.sf || {}, rid: y } });
|
|
1450
|
+
const S = P({ queueUri: C(ce(this) ?? this?.name, this?.name), method: p });
|
|
1451
|
+
let v = null;
|
|
1452
|
+
try {
|
|
1453
|
+
return await c.apply(this, g);
|
|
1454
|
+
} catch (I) {
|
|
1455
|
+
throw v = I instanceof Error ? I : new Error(String(I)), I;
|
|
1456
|
+
} finally {
|
|
1457
|
+
S.hopEnd(v);
|
|
1458
|
+
}
|
|
1459
|
+
};
|
|
1460
|
+
h[b] = !0, U(a.prototype, u, h);
|
|
1461
|
+
}
|
|
1462
|
+
})(r);
|
|
1463
|
+
const i = t.QueueEvents;
|
|
1464
|
+
i?.prototype && (i.prototype[b] = !1);
|
|
1465
|
+
const d = t.FlowProducer;
|
|
1466
|
+
return d?.prototype && ((function(a) {
|
|
1467
|
+
const s = a.prototype.add;
|
|
1468
|
+
if (typeof s != "function" || s[b]) return;
|
|
1469
|
+
const u = async function(c, ...p) {
|
|
1470
|
+
if (!c || typeof c != "object") return s.call(this, c, ...p);
|
|
1471
|
+
if (c?.opts?.sf?.rid) return s.call(this, c, ...p);
|
|
1472
|
+
const h = T(() => {
|
|
1473
|
+
const f = [];
|
|
1474
|
+
return { hops: f, out: ke(c, f) };
|
|
1475
|
+
}, "bullmq.FlowProducer.add");
|
|
1476
|
+
if (h === null) return s.call(this, c, ...p);
|
|
1477
|
+
let g = null;
|
|
1478
|
+
try {
|
|
1479
|
+
return await s.call(this, h.out, ...p);
|
|
1480
|
+
} catch (f) {
|
|
1481
|
+
throw g = f instanceof Error ? f : new Error(String(f)), f;
|
|
1482
|
+
} finally {
|
|
1483
|
+
for (const f of h.hops) f.hopEnd(g);
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
u[b] = !0, U(a.prototype, "add", u);
|
|
1487
|
+
})(d), (function(a) {
|
|
1488
|
+
const s = a.prototype.addBulk;
|
|
1489
|
+
if (typeof s != "function" || s[b]) return;
|
|
1490
|
+
const u = async function(c) {
|
|
1491
|
+
if (!Array.isArray(c) || c.length === 0) return s.call(this, c);
|
|
1492
|
+
if (c.every((f) => f?.opts?.sf?.rid)) return s.call(this, c);
|
|
1493
|
+
const p = m().bullmqBulkAggregateMode, h = T(() => {
|
|
1494
|
+
if (p) {
|
|
1495
|
+
const S = ($) => {
|
|
1496
|
+
let k = 1;
|
|
1497
|
+
if (Array.isArray($?.children)) for (const q of $.children) k += S(q);
|
|
1498
|
+
return k;
|
|
1499
|
+
}, v = c.reduce(($, k) => $ + S(k), 0), I = P({ library: "bullmq-flow", queueUri: C(c[0]?.queueName, `__flow_bulk_${c.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: c.length, totalNodes: v } }), _ = c.map(($) => ht($, I.traceId));
|
|
1500
|
+
return { hops: [I], out: _ };
|
|
1501
|
+
}
|
|
1502
|
+
const f = [], y = c.map((S) => ke(S, f));
|
|
1503
|
+
return { hops: f, out: y };
|
|
1504
|
+
}, "bullmq.FlowProducer.addBulk");
|
|
1505
|
+
if (h === null) return s.call(this, c);
|
|
1506
|
+
let g = null;
|
|
1507
|
+
try {
|
|
1508
|
+
return await s.call(this, h.out);
|
|
1509
|
+
} catch (f) {
|
|
1510
|
+
throw g = f instanceof Error ? f : new Error(String(f)), f;
|
|
1511
|
+
} finally {
|
|
1512
|
+
for (const f of h.hops) f.hopEnd(g);
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
u[b] = !0, U(a.prototype, "addBulk", u);
|
|
1516
|
+
})(d)), t.QueueScheduler?.prototype && m().sfDebug && console.log("[sf-veritas] BullMQ QueueScheduler detected (v4 API). No direct instrumentation needed — delayed/repeatable jobs are traced when the Worker picks them up via the Worker.processJob wrap."), "installed";
|
|
1517
|
+
}
|
|
1518
|
+
function ke(n, t) {
|
|
1519
|
+
const e = P({ queueUri: C(n?.queueName, n?.name), messagePayload: n?.data });
|
|
1520
|
+
t.push(e);
|
|
1521
|
+
const o = { ...n, opts: L(n?.opts, e.traceId) };
|
|
1522
|
+
return Array.isArray(n?.children) && n.children.length > 0 && (o.children = n.children.map((r) => ke(r, t))), o;
|
|
1523
|
+
}
|
|
1524
|
+
function ht(n, t) {
|
|
1525
|
+
const e = { ...n, opts: L(n?.opts, t) };
|
|
1526
|
+
return Array.isArray(n?.children) && n.children.length > 0 && (e.children = n.children.map((o) => ht(o, t))), e;
|
|
1527
|
+
}
|
|
1528
|
+
function ln(n) {
|
|
1529
|
+
let t = n;
|
|
1530
|
+
if (!t) try {
|
|
1531
|
+
t = require("@taskforcesh/bullmq-pro");
|
|
1532
|
+
} catch {
|
|
1533
|
+
return "not-installed";
|
|
1534
|
+
}
|
|
1535
|
+
const e = t.QueuePro, o = t.WorkerPro;
|
|
1536
|
+
t.JobPro;
|
|
1537
|
+
const r = t.FlowProducerPro;
|
|
1538
|
+
return e?.prototype || o?.prototype ? (e?.prototype && ((function(i) {
|
|
1539
|
+
const d = i.prototype.add;
|
|
1540
|
+
if (typeof d != "function" || d[b]) return;
|
|
1541
|
+
const l = async function(a, s, u) {
|
|
1542
|
+
if (u?.sf?.rid) return d.call(this, a, s, u);
|
|
1543
|
+
const c = T(() => {
|
|
1544
|
+
const h = P({ library: "bullmq-pro", queueUri: C(this?.name, a), messagePayload: s });
|
|
1545
|
+
return { handle: h, nextOpts: L(u, h.traceId) };
|
|
1546
|
+
}, "bullmq-pro.QueuePro.add");
|
|
1547
|
+
if (c === null) return d.call(this, a, s, u);
|
|
1548
|
+
let p = null;
|
|
1549
|
+
try {
|
|
1550
|
+
return await d.call(this, a, s, c.nextOpts);
|
|
1551
|
+
} catch (h) {
|
|
1552
|
+
throw p = h instanceof Error ? h : new Error(String(h)), h;
|
|
1553
|
+
} finally {
|
|
1554
|
+
c.handle.hopEnd(p);
|
|
1555
|
+
}
|
|
1556
|
+
};
|
|
1557
|
+
l[b] = !0, U(i.prototype, "add", l);
|
|
1558
|
+
})(e), (function(i) {
|
|
1559
|
+
const d = i.prototype.addBulk;
|
|
1560
|
+
if (typeof d != "function" || d[b]) return;
|
|
1561
|
+
const l = async function(a) {
|
|
1562
|
+
if (!Array.isArray(a) || a.length === 0) return d.call(this, a);
|
|
1563
|
+
if (a.every((p) => p?.opts?.sf?.rid)) return d.call(this, a);
|
|
1564
|
+
const s = m().bullmqBulkAggregateMode, u = T(() => {
|
|
1565
|
+
if (s) {
|
|
1566
|
+
const g = P({ library: "bullmq-pro", queueUri: C(this?.name, `__bulk_${a.length}`), method: "ENQUEUE_BULK", messagePayload: { batchSize: a.length } }), f = a.map((y) => ({ ...y, opts: L(y?.opts, g.traceId) }));
|
|
1567
|
+
return { handles: [g], out: f };
|
|
1568
|
+
}
|
|
1569
|
+
const p = a.map((g) => P({ library: "bullmq-pro", queueUri: C(this?.name, g?.name), messagePayload: g?.data })), h = a.map((g, f) => ({ ...g, opts: L(g?.opts, p[f].traceId) }));
|
|
1570
|
+
return { handles: p, out: h };
|
|
1571
|
+
}, "bullmq-pro.QueuePro.addBulk");
|
|
1572
|
+
if (u === null) return d.call(this, a);
|
|
1573
|
+
let c = null;
|
|
1574
|
+
try {
|
|
1575
|
+
return await d.call(this, u.out);
|
|
1576
|
+
} catch (p) {
|
|
1577
|
+
throw c = p instanceof Error ? p : new Error(String(p)), p;
|
|
1578
|
+
} finally {
|
|
1579
|
+
for (const p of u.handles) p.hopEnd(c);
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
l[b] = !0, U(i.prototype, "addBulk", l);
|
|
1583
|
+
})(e)), o?.prototype && ((function(i) {
|
|
1584
|
+
const d = i.prototype.processJob;
|
|
1585
|
+
typeof d != "function" || d[b] || Ve(i, "processJob", d);
|
|
1586
|
+
})(o), (function(i) {
|
|
1587
|
+
const d = i.prototype.getNextJob;
|
|
1588
|
+
if (typeof d != "function" || d[b]) return;
|
|
1589
|
+
const l = async function(...a) {
|
|
1590
|
+
const s = await d.apply(this, a);
|
|
1591
|
+
if (s && z(s.opts?.sf?.rid)) try {
|
|
1592
|
+
const c = x.getInstance();
|
|
1593
|
+
(!(u = c.getTraceId()) || u.startsWith("nonsession-applogs-v3/")) && c.setTraceId(s.opts.sf.rid);
|
|
1594
|
+
} catch {
|
|
1595
|
+
}
|
|
1596
|
+
var u;
|
|
1597
|
+
return s;
|
|
1598
|
+
};
|
|
1599
|
+
l[b] = !0, U(i.prototype, "getNextJob", l);
|
|
1600
|
+
})(o), typeof o.prototype.callProcessJob == "function" && (function(i) {
|
|
1601
|
+
const d = i.prototype.callProcessJob;
|
|
1602
|
+
typeof d != "function" || d[b] || Ve(i, "callProcessJob", d);
|
|
1603
|
+
})(o)), r?.prototype && (function(i) {
|
|
1604
|
+
const d = i.prototype.add;
|
|
1605
|
+
if (typeof d != "function" || d[b]) return;
|
|
1606
|
+
const l = async function(a, ...s) {
|
|
1607
|
+
if (!a || typeof a != "object") return d.call(this, a, ...s);
|
|
1608
|
+
if (a?.opts?.sf?.rid) return d.call(this, a, ...s);
|
|
1609
|
+
const u = T(() => {
|
|
1610
|
+
const p = [];
|
|
1611
|
+
return { hops: p, out: yt(a, p) };
|
|
1612
|
+
}, "bullmq-pro.FlowProducerPro.add");
|
|
1613
|
+
if (u === null) return d.call(this, a, ...s);
|
|
1614
|
+
let c = null;
|
|
1615
|
+
try {
|
|
1616
|
+
return await d.call(this, u.out, ...s);
|
|
1617
|
+
} catch (p) {
|
|
1618
|
+
throw c = p instanceof Error ? p : new Error(String(p)), p;
|
|
1619
|
+
} finally {
|
|
1620
|
+
for (const p of u.hops) p.hopEnd(c);
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
l[b] = !0, U(i.prototype, "add", l);
|
|
1624
|
+
})(r), "installed") : (m().sfDebug && console.warn("[asyncQueues][bullmq-pro] No QueuePro/WorkerPro found — patch no-op."), "failed");
|
|
1625
|
+
}
|
|
1626
|
+
function Ve(n, t, e) {
|
|
1627
|
+
const o = function(r, ...i) {
|
|
1628
|
+
const d = r?.opts?.sf?.rid, l = typeof r?.attemptsMade == "number" ? r.attemptsMade : 0, a = typeof r?.stalledCounter == "number" ? r.stalledCounter : 0, s = r?.repeatJobKey != null || r?.opts?.repeat != null, u = z(d) && (l > 0 || a > 0 || s) ? V(d) : z(d) ? d : void 0;
|
|
1629
|
+
let c;
|
|
1630
|
+
return a > 0 ? c = "CONSUME_STALLED" : s && l === 0 && (c = "CONSUME_SCHEDULED"), R({ library: "bullmq-pro", queueUri: C(ce(r) ?? this?.name, r?.name), incomingTraceId: u, messagePayload: r?.data, method: c }, () => e.call(this, r, ...i));
|
|
1631
|
+
};
|
|
1632
|
+
o[b] = !0, U(n.prototype, t, o);
|
|
1633
|
+
}
|
|
1634
|
+
function yt(n, t, e = 0) {
|
|
1635
|
+
if (e > 100) return n;
|
|
1636
|
+
const o = P({ queueUri: C(n?.queueName, n?.name), messagePayload: n?.data });
|
|
1637
|
+
t.push(o);
|
|
1638
|
+
const r = { ...n, opts: L(n?.opts, o.traceId) };
|
|
1639
|
+
return Array.isArray(n?.children) && n.children.length > 0 && (r.children = n.children.map((i) => yt(i, t, e + 1))), r;
|
|
1640
|
+
}
|
|
1641
|
+
const Ue = Y.toLowerCase();
|
|
1642
|
+
function J(n) {
|
|
1643
|
+
if (n != null) {
|
|
1644
|
+
if (typeof n == "string") return n;
|
|
1645
|
+
if (Buffer.isBuffer(n)) try {
|
|
1646
|
+
return n.toString("utf8");
|
|
1647
|
+
} catch {
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
if (n instanceof Uint8Array) try {
|
|
1651
|
+
return Buffer.from(n).toString("utf8");
|
|
1652
|
+
} catch {
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
return String(n);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
function O(n, t = "broker") {
|
|
1659
|
+
return `kafka://${t}/${n ?? "unknown"}`;
|
|
1660
|
+
}
|
|
1661
|
+
function Z(n) {
|
|
1662
|
+
if (Array.isArray(n)) for (const t of n) {
|
|
1663
|
+
if (!t || typeof t != "object") continue;
|
|
1664
|
+
const e = t.key;
|
|
1665
|
+
if (typeof e == "string" && e.toLowerCase() === Ue) return J(t.value);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
function gt(n, t) {
|
|
1669
|
+
const e = [];
|
|
1670
|
+
if (Array.isArray(n)) {
|
|
1671
|
+
for (const o of n) if (o && typeof o == "object") {
|
|
1672
|
+
const r = o.key, i = o.value;
|
|
1673
|
+
typeof r == "string" && r.toLowerCase() === Ue || e.push({ key: String(r), value: Buffer.isBuffer(i) ? i : Buffer.from(String(i ?? "")) });
|
|
1674
|
+
}
|
|
1675
|
+
} else if (n && typeof n == "object") for (const [o, r] of Object.entries(n)) o.toLowerCase() !== Ue && e.push({ key: o, value: Buffer.isBuffer(r) ? r : Buffer.from(String(r ?? "")) });
|
|
1676
|
+
return e.push({ key: Y, value: Buffer.from(t) }), e;
|
|
1677
|
+
}
|
|
1678
|
+
function dn(n) {
|
|
1679
|
+
let t = n;
|
|
1680
|
+
if (!t) try {
|
|
1681
|
+
t = require("@confluentinc/kafka-javascript");
|
|
1682
|
+
} catch {
|
|
1683
|
+
return "not-installed";
|
|
1684
|
+
}
|
|
1685
|
+
let e = !1;
|
|
1686
|
+
t.KafkaProducer?.prototype && ((function(r) {
|
|
1687
|
+
const i = r.prototype.produce;
|
|
1688
|
+
if (typeof i != "function" || i[b]) return;
|
|
1689
|
+
const d = function(...l) {
|
|
1690
|
+
return l.length === 1 && l[0] && typeof l[0] == "object" && Array.isArray(l[0].messages) ? pn.call(this, i, l[0]) : fn.call(this, i, l);
|
|
1691
|
+
};
|
|
1692
|
+
d[b] = !0, U(r.prototype, "produce", d);
|
|
1693
|
+
})(t.KafkaProducer), e = !0), t.KafkaConsumer?.prototype && ((function(r) {
|
|
1694
|
+
const i = r.prototype.on;
|
|
1695
|
+
if (typeof i != "function" || i[b]) return;
|
|
1696
|
+
const d = function(l, a) {
|
|
1697
|
+
if (l !== "data" || typeof a != "function") return i.call(this, l, a);
|
|
1698
|
+
const s = function(u) {
|
|
1699
|
+
const c = Z(u?.headers), p = u?.topic, h = J(u?.value) ?? u?.value;
|
|
1700
|
+
return R({ library: "confluent-kafka-js", queueUri: O(p), incomingTraceId: c, messagePayload: h }, () => a.call(this, u));
|
|
1701
|
+
};
|
|
1702
|
+
return i.call(this, l, s);
|
|
1703
|
+
};
|
|
1704
|
+
d[b] = !0, U(r.prototype, "on", d);
|
|
1705
|
+
})(t.KafkaConsumer), e = !0);
|
|
1706
|
+
const o = t.KafkaJS ?? t;
|
|
1707
|
+
return o?.Producer?.prototype?.send && ((function(r) {
|
|
1708
|
+
const i = r.prototype.send;
|
|
1709
|
+
if (typeof i == "function" && !i[b]) {
|
|
1710
|
+
const a = De(i);
|
|
1711
|
+
a[b] = !0, U(r.prototype, "send", a);
|
|
1712
|
+
}
|
|
1713
|
+
const d = r.prototype.sendBatch;
|
|
1714
|
+
if (typeof d == "function" && !d[b]) {
|
|
1715
|
+
const a = Ne(d);
|
|
1716
|
+
a[b] = !0, U(r.prototype, "sendBatch", a);
|
|
1717
|
+
}
|
|
1718
|
+
const l = r.prototype.transaction;
|
|
1719
|
+
if (typeof l == "function" && !l[b]) {
|
|
1720
|
+
const a = Ye(l);
|
|
1721
|
+
a[b] = !0, U(r.prototype, "transaction", a);
|
|
1722
|
+
}
|
|
1723
|
+
})(o.Producer), e = !0), o?.Consumer?.prototype?.run && ((function(r) {
|
|
1724
|
+
const i = r.prototype.run;
|
|
1725
|
+
if (typeof i != "function" || i[b]) return;
|
|
1726
|
+
const d = async function(l) {
|
|
1727
|
+
if (!l || typeof l != "object") return i.call(this, l);
|
|
1728
|
+
const a = { ...l };
|
|
1729
|
+
if (typeof l.eachMessage == "function") {
|
|
1730
|
+
const s = l.eachMessage;
|
|
1731
|
+
a.eachMessage = (u) => {
|
|
1732
|
+
const c = J(W(u?.message?.headers)) ?? Z(u?.message?.headers), p = typeof u?.attempt == "number" ? u.attempt : 0, h = c && p > 0 ? V(c) : c;
|
|
1733
|
+
return R({ library: "confluent-kafka-js", queueUri: O(u?.topic), incomingTraceId: h }, () => s(u));
|
|
1734
|
+
};
|
|
1735
|
+
}
|
|
1736
|
+
if (typeof l.eachBatch == "function") {
|
|
1737
|
+
const s = l.eachBatch;
|
|
1738
|
+
a.eachBatch = (u) => {
|
|
1739
|
+
let c = !1;
|
|
1740
|
+
try {
|
|
1741
|
+
typeof u?.isStale == "function" && (c = !!u.isStale());
|
|
1742
|
+
} catch {
|
|
1743
|
+
}
|
|
1744
|
+
if (c) return s(u);
|
|
1745
|
+
const p = Array.isArray(u?.batch?.messages) ? u.batch.messages[0] : void 0, h = J(W(p?.headers)) ?? Z(p?.headers);
|
|
1746
|
+
return R({ library: "confluent-kafka-js", queueUri: O(u?.batch?.topic), incomingTraceId: h }, () => s(u));
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
return i.call(this, a);
|
|
1750
|
+
};
|
|
1751
|
+
d[b] = !0, U(r.prototype, "run", d);
|
|
1752
|
+
})(o.Consumer), e = !0), typeof o?.Kafka == "function" && o.Kafka.prototype && ((function(r) {
|
|
1753
|
+
const i = r.prototype.producer;
|
|
1754
|
+
if (typeof i == "function" && !i[b]) {
|
|
1755
|
+
const l = function(...a) {
|
|
1756
|
+
const s = i.apply(this, a);
|
|
1757
|
+
return s && typeof s.send == "function" && !s.send[w] && (s.send = De(s.send.bind(s)), s.send[w] = !0), s && typeof s.sendBatch == "function" && !s.sendBatch[w] && (s.sendBatch = Ne(s.sendBatch.bind(s)), s.sendBatch[w] = !0), s && typeof s.transaction == "function" && !s.transaction[w] && (s.transaction = Ye(s.transaction.bind(s)), s.transaction[w] = !0), s;
|
|
1758
|
+
};
|
|
1759
|
+
l[b] = !0, U(r.prototype, "producer", l);
|
|
1760
|
+
}
|
|
1761
|
+
const d = r.prototype.consumer;
|
|
1762
|
+
if (typeof d == "function" && !d[b]) {
|
|
1763
|
+
const l = function(...a) {
|
|
1764
|
+
const s = d.apply(this, a);
|
|
1765
|
+
if (s && typeof s.run == "function" && !s.run[w]) {
|
|
1766
|
+
const u = s.run.bind(s);
|
|
1767
|
+
s.run = async function(c) {
|
|
1768
|
+
if (!c || typeof c != "object") return u(c);
|
|
1769
|
+
const p = { ...c };
|
|
1770
|
+
if (typeof c.eachMessage == "function") {
|
|
1771
|
+
const h = c.eachMessage;
|
|
1772
|
+
p.eachMessage = (g) => {
|
|
1773
|
+
const f = J(W(g?.message?.headers)) ?? Z(g?.message?.headers);
|
|
1774
|
+
return R({ library: "confluent-kafka-js", queueUri: O(g?.topic), incomingTraceId: f }, () => h(g));
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
if (typeof c.eachBatch == "function") {
|
|
1778
|
+
const h = c.eachBatch;
|
|
1779
|
+
p.eachBatch = (g) => {
|
|
1780
|
+
let f = !1;
|
|
1781
|
+
try {
|
|
1782
|
+
typeof g?.isStale == "function" && (f = !!g.isStale());
|
|
1783
|
+
} catch {
|
|
1784
|
+
}
|
|
1785
|
+
if (f) return h(g);
|
|
1786
|
+
const y = Array.isArray(g?.batch?.messages) ? g.batch.messages[0] : void 0, S = J(W(y?.headers)) ?? Z(y?.headers);
|
|
1787
|
+
return R({ library: "confluent-kafka-js", queueUri: O(g?.batch?.topic), incomingTraceId: S }, () => h(g));
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
return u(p);
|
|
1791
|
+
}, s.run[w] = !0;
|
|
1792
|
+
}
|
|
1793
|
+
return s;
|
|
1794
|
+
};
|
|
1795
|
+
l[b] = !0, U(r.prototype, "consumer", l);
|
|
1796
|
+
}
|
|
1797
|
+
})(o.Kafka), e = !0), e ? "installed" : (m().sfDebug && console.warn("[asyncQueues][confluentKafkaJs] No recognizable Producer/Consumer/Kafka class — patch no-op."), "failed");
|
|
1798
|
+
}
|
|
1799
|
+
function pn(n, t) {
|
|
1800
|
+
const e = T(() => {
|
|
1801
|
+
const r = t?.topic, i = t.messages.map(() => P({ library: "confluent-kafka-js", queueUri: O(r), method: "ENQUEUE_BUFFERED" })), d = t.messages.map((l, a) => ({ ...l, headers: gt(l?.headers, i[a].traceId) }));
|
|
1802
|
+
return { handles: i, outOptions: { ...t, messages: d } };
|
|
1803
|
+
}, "confluentKafkaJs.KafkaProducer.produce(object)");
|
|
1804
|
+
if (e === null) return n.call(this, t);
|
|
1805
|
+
let o = null;
|
|
1806
|
+
try {
|
|
1807
|
+
return n.call(this, e.outOptions);
|
|
1808
|
+
} catch (r) {
|
|
1809
|
+
throw o = r instanceof Error ? r : new Error(String(r)), r;
|
|
1810
|
+
} finally {
|
|
1811
|
+
for (const r of e.handles) r.hopEnd(o);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
function fn(n, t) {
|
|
1815
|
+
const [e, o, r, i, d, l, a] = t, s = T(() => {
|
|
1816
|
+
const c = P({ library: "confluent-kafka-js", queueUri: O(typeof e == "string" ? e : void 0), method: "ENQUEUE_BUFFERED" });
|
|
1817
|
+
return { handle: c, injectedHeaders: gt(a, c.traceId) };
|
|
1818
|
+
}, "confluentKafkaJs.KafkaProducer.produce(positional)");
|
|
1819
|
+
if (s === null) return n.call(this, e, o, r, i, d, l, a);
|
|
1820
|
+
let u = null;
|
|
1821
|
+
try {
|
|
1822
|
+
return n.call(this, e, o, r, i, d, l, s.injectedHeaders);
|
|
1823
|
+
} catch (c) {
|
|
1824
|
+
throw u = c instanceof Error ? c : new Error(String(c)), c;
|
|
1825
|
+
} finally {
|
|
1826
|
+
s.handle.hopEnd(u);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
function De(n, t = {}) {
|
|
1830
|
+
const e = t.method ?? "ENQUEUE", o = t.library ?? "confluent-kafka-js";
|
|
1831
|
+
return async function(r) {
|
|
1832
|
+
if (!r || !Array.isArray(r.messages)) return n.call(this, r);
|
|
1833
|
+
const i = T(() => {
|
|
1834
|
+
const l = r.messages.map(() => P({ library: o, queueUri: O(r.topic), method: e })), a = r.messages.map((s, u) => ({ ...s, headers: { ...s?.headers || {}, [Y]: Buffer.from(l[u].traceId) } }));
|
|
1835
|
+
return { handles: l, outPayload: { ...r, messages: a } };
|
|
1836
|
+
}, `confluentKafkaJs.Producer.${e}`);
|
|
1837
|
+
if (i === null) return n.call(this, r);
|
|
1838
|
+
let d = null;
|
|
1839
|
+
try {
|
|
1840
|
+
return await n.call(this, i.outPayload);
|
|
1841
|
+
} catch (l) {
|
|
1842
|
+
throw d = l instanceof Error ? l : new Error(String(l)), l;
|
|
1843
|
+
} finally {
|
|
1844
|
+
for (const l of i.handles) l.hopEnd(d);
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
}
|
|
1848
|
+
function Ne(n, t = {}) {
|
|
1849
|
+
const e = t.method ?? "ENQUEUE", o = t.library ?? "confluent-kafka-js";
|
|
1850
|
+
return async function(r) {
|
|
1851
|
+
if (!r || !Array.isArray(r.topicMessages)) return n.call(this, r);
|
|
1852
|
+
const i = T(() => {
|
|
1853
|
+
const l = [], a = r.topicMessages.map((s) => {
|
|
1854
|
+
const u = (Array.isArray(s?.messages) ? s.messages : []).map((c) => {
|
|
1855
|
+
const p = P({ library: o, queueUri: O(s?.topic), method: e });
|
|
1856
|
+
return l.push(p), { ...c, headers: { ...c?.headers || {}, [Y]: Buffer.from(p.traceId) } };
|
|
1857
|
+
});
|
|
1858
|
+
return { ...s, messages: u };
|
|
1859
|
+
});
|
|
1860
|
+
return { handles: l, outPayload: { ...r, topicMessages: a } };
|
|
1861
|
+
}, `confluentKafkaJs.Producer.sendBatch[${e}]`);
|
|
1862
|
+
if (i === null) return n.call(this, r);
|
|
1863
|
+
let d = null;
|
|
1864
|
+
try {
|
|
1865
|
+
return await n.call(this, i.outPayload);
|
|
1866
|
+
} catch (l) {
|
|
1867
|
+
throw d = l instanceof Error ? l : new Error(String(l)), l;
|
|
1868
|
+
} finally {
|
|
1869
|
+
for (const l of i.handles) l.hopEnd(d);
|
|
1870
|
+
}
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
function Xe(n, t) {
|
|
1874
|
+
return async function(...e) {
|
|
1875
|
+
const o = P({ queueUri: "kafka://broker/_tx", method: t });
|
|
1876
|
+
let r = null;
|
|
1877
|
+
try {
|
|
1878
|
+
return await n.apply(this, e);
|
|
1879
|
+
} catch (i) {
|
|
1880
|
+
throw r = i instanceof Error ? i : new Error(String(i)), i;
|
|
1881
|
+
} finally {
|
|
1882
|
+
o.hopEnd(r);
|
|
1883
|
+
}
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
function Ye(n) {
|
|
1887
|
+
return async function(...t) {
|
|
1888
|
+
const e = await n.apply(this, t);
|
|
1889
|
+
return e && typeof e.send == "function" && !e.send[w] && (e.send = De(e.send.bind(e), { method: "ENQUEUE_TX", library: "confluent-kafka-js-tx" }), e.send[w] = !0), e && typeof e.sendBatch == "function" && !e.sendBatch[w] && (e.sendBatch = Ne(e.sendBatch.bind(e), { method: "ENQUEUE_TX", library: "confluent-kafka-js-tx" }), e.sendBatch[w] = !0), e && typeof e.commit == "function" && !e.commit[w] && (e.commit = Xe(e.commit.bind(e), "COMMIT_TX"), e.commit[w] = !0), e && typeof e.abort == "function" && !e.abort[w] && (e.abort = Xe(e.abort.bind(e), "ABORT_TX"), e.abort[w] = !0), e;
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
function me(n) {
|
|
1893
|
+
if (n != null) {
|
|
1894
|
+
if (typeof n == "string") return n;
|
|
1895
|
+
if (Buffer.isBuffer(n)) try {
|
|
1896
|
+
return n.toString("utf8");
|
|
1897
|
+
} catch {
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
if (n instanceof Uint8Array) try {
|
|
1901
|
+
return Buffer.from(n).toString("utf8");
|
|
1902
|
+
} catch {
|
|
1903
|
+
return;
|
|
1904
|
+
}
|
|
1905
|
+
return String(n);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
function ue(n, t) {
|
|
1909
|
+
return `kafka://broker/${n ?? "unknown"}`;
|
|
1910
|
+
}
|
|
1911
|
+
function hn(n) {
|
|
1912
|
+
let t = n;
|
|
1913
|
+
if (!t) try {
|
|
1914
|
+
t = require("kafkajs");
|
|
1915
|
+
} catch {
|
|
1916
|
+
return "not-installed";
|
|
1917
|
+
}
|
|
1918
|
+
const e = t.Producer, o = t.Consumer;
|
|
1919
|
+
e?.prototype && typeof e.prototype.send == "function" && (function(i) {
|
|
1920
|
+
const d = i.prototype.send;
|
|
1921
|
+
if (typeof d == "function" && !d[b]) {
|
|
1922
|
+
const s = Pe(d);
|
|
1923
|
+
s[b] = !0, U(i.prototype, "send", s);
|
|
1924
|
+
}
|
|
1925
|
+
const l = i.prototype.sendBatch;
|
|
1926
|
+
if (typeof l == "function" && !l[b]) {
|
|
1927
|
+
const s = Fe(l);
|
|
1928
|
+
s[b] = !0, U(i.prototype, "sendBatch", s);
|
|
1929
|
+
}
|
|
1930
|
+
const a = i.prototype.transaction;
|
|
1931
|
+
if (typeof a == "function" && !a[b]) {
|
|
1932
|
+
const s = et(a);
|
|
1933
|
+
s[b] = !0, U(i.prototype, "transaction", s);
|
|
1934
|
+
}
|
|
1935
|
+
})(e), o?.prototype && typeof o.prototype.run == "function" && (function(i) {
|
|
1936
|
+
const d = i.prototype.run;
|
|
1937
|
+
if (typeof d != "function" || d[b]) return;
|
|
1938
|
+
const l = tt(d);
|
|
1939
|
+
l[b] = !0, U(i.prototype, "run", l);
|
|
1940
|
+
})(o);
|
|
1941
|
+
const r = t.Kafka;
|
|
1942
|
+
if (typeof r == "function" && r.prototype) (function(i) {
|
|
1943
|
+
const d = i.prototype.producer;
|
|
1944
|
+
if (typeof d == "function" && !d[b]) {
|
|
1945
|
+
const a = function(...s) {
|
|
1946
|
+
const u = d.apply(this, s);
|
|
1947
|
+
return u && typeof u.send == "function" && !u.send[w] && (u.send = Pe(u.send.bind(u)), u.send[w] = !0), u && typeof u.sendBatch == "function" && !u.sendBatch[w] && (u.sendBatch = Fe(u.sendBatch.bind(u)), u.sendBatch[w] = !0), u && typeof u.transaction == "function" && !u.transaction[w] && (u.transaction = et(u.transaction.bind(u)), u.transaction[w] = !0), u;
|
|
1948
|
+
};
|
|
1949
|
+
a[b] = !0, U(i.prototype, "producer", a);
|
|
1950
|
+
}
|
|
1951
|
+
const l = i.prototype.consumer;
|
|
1952
|
+
if (typeof l == "function" && !l[b]) {
|
|
1953
|
+
const a = function(...s) {
|
|
1954
|
+
const u = l.apply(this, s);
|
|
1955
|
+
return u && typeof u.run == "function" && !u.run[w] && (u.run = tt(u.run.bind(u)), u.run[w] = !0), u;
|
|
1956
|
+
};
|
|
1957
|
+
a[b] = !0, U(i.prototype, "consumer", a);
|
|
1958
|
+
}
|
|
1959
|
+
})(r);
|
|
1960
|
+
else if (!e?.prototype && !o?.prototype) return m().sfDebug && console.warn("[asyncQueues][kafkajs] No Kafka/Producer/Consumer class found — patch no-op."), "failed";
|
|
1961
|
+
return "installed";
|
|
1962
|
+
}
|
|
1963
|
+
function Pe(n, t = {}) {
|
|
1964
|
+
const e = t.method ?? "ENQUEUE", o = t.library ?? "kafkajs";
|
|
1965
|
+
return async function(r) {
|
|
1966
|
+
if (!r || !Array.isArray(r.messages)) return n.call(this, r);
|
|
1967
|
+
const i = T(() => {
|
|
1968
|
+
const l = r.topic, a = r.messages.map(() => P({ library: o, queueUri: ue(l), method: e })), s = r.messages.map((c, p) => mt(c, a[p].traceId)), u = { ...r, messages: s };
|
|
1969
|
+
return { handles: a, outPayload: u };
|
|
1970
|
+
}, `kafkajs.Producer.${e}`);
|
|
1971
|
+
if (i === null) return n.call(this, r);
|
|
1972
|
+
let d = null;
|
|
1973
|
+
try {
|
|
1974
|
+
return await n.call(this, i.outPayload);
|
|
1975
|
+
} catch (l) {
|
|
1976
|
+
throw d = l instanceof Error ? l : new Error(String(l)), l;
|
|
1977
|
+
} finally {
|
|
1978
|
+
for (const l of i.handles) l.hopEnd(d);
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
function Fe(n, t = {}) {
|
|
1983
|
+
const e = t.method ?? "ENQUEUE", o = t.library ?? "kafkajs";
|
|
1984
|
+
return async function(r) {
|
|
1985
|
+
if (!r || !Array.isArray(r.topicMessages)) return n.call(this, r);
|
|
1986
|
+
const i = T(() => {
|
|
1987
|
+
const l = [], a = r.topicMessages.map((u) => {
|
|
1988
|
+
const c = u?.topic, p = (Array.isArray(u?.messages) ? u.messages : []).map((h) => {
|
|
1989
|
+
const g = P({ library: o, queueUri: ue(c), method: e });
|
|
1990
|
+
return l.push(g), mt(h, g.traceId);
|
|
1991
|
+
});
|
|
1992
|
+
return { ...u, messages: p };
|
|
1993
|
+
}), s = { ...r, topicMessages: a };
|
|
1994
|
+
return { handles: l, outPayload: s };
|
|
1995
|
+
}, `kafkajs.Producer.sendBatch[${e}]`);
|
|
1996
|
+
if (i === null) return n.call(this, r);
|
|
1997
|
+
let d = null;
|
|
1998
|
+
try {
|
|
1999
|
+
return await n.call(this, i.outPayload);
|
|
2000
|
+
} catch (l) {
|
|
2001
|
+
throw d = l instanceof Error ? l : new Error(String(l)), l;
|
|
2002
|
+
} finally {
|
|
2003
|
+
for (const l of i.handles) l.hopEnd(d);
|
|
2004
|
+
}
|
|
2005
|
+
};
|
|
2006
|
+
}
|
|
2007
|
+
function Ze(n, t) {
|
|
2008
|
+
return async function(...e) {
|
|
2009
|
+
const o = P({ queueUri: "kafka://broker/_tx", method: t });
|
|
2010
|
+
let r = null;
|
|
2011
|
+
try {
|
|
2012
|
+
return await n.apply(this, e);
|
|
2013
|
+
} catch (i) {
|
|
2014
|
+
throw r = i instanceof Error ? i : new Error(String(i)), i;
|
|
2015
|
+
} finally {
|
|
2016
|
+
o.hopEnd(r);
|
|
2017
|
+
}
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
function et(n) {
|
|
2021
|
+
return async function(...t) {
|
|
2022
|
+
const e = await n.apply(this, t);
|
|
2023
|
+
return e && typeof e.send == "function" && !e.send[w] && (e.send = Pe(e.send.bind(e), { method: "ENQUEUE_TX", library: "kafkajs-tx" }), e.send[w] = !0), e && typeof e.sendBatch == "function" && !e.sendBatch[w] && (e.sendBatch = Fe(e.sendBatch.bind(e), { method: "ENQUEUE_TX", library: "kafkajs-tx" }), e.sendBatch[w] = !0), e && typeof e.commit == "function" && !e.commit[w] && (e.commit = Ze(e.commit.bind(e), "COMMIT_TX"), e.commit[w] = !0), e && typeof e.abort == "function" && !e.abort[w] && (e.abort = Ze(e.abort.bind(e), "ABORT_TX"), e.abort[w] = !0), e;
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
function mt(n, t) {
|
|
2027
|
+
const e = { ...n?.headers || {} };
|
|
2028
|
+
return e[Y] = Buffer.from(t), { ...n, headers: e };
|
|
1053
2029
|
}
|
|
1054
|
-
|
|
1055
|
-
function
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
2030
|
+
function tt(n) {
|
|
2031
|
+
return async function(t) {
|
|
2032
|
+
if (!t || typeof t != "object") return n.call(this, t);
|
|
2033
|
+
const e = { ...t };
|
|
2034
|
+
if (typeof t.eachMessage == "function") {
|
|
2035
|
+
const o = t.eachMessage;
|
|
2036
|
+
e.eachMessage = (r) => (async function(i, d) {
|
|
2037
|
+
const l = i?.topic, a = i?.message, s = me(W(a?.headers)), u = typeof i?.attempt == "number" ? i.attempt : 0, c = s && u > 0 ? V(s) : s, p = me(a?.value) ?? a?.value;
|
|
2038
|
+
return R({ library: "kafkajs", queueUri: ue(l), incomingTraceId: c, messagePayload: p }, () => d(i));
|
|
2039
|
+
})(r, o);
|
|
2040
|
+
}
|
|
2041
|
+
if (typeof t.eachBatch == "function") {
|
|
2042
|
+
const o = t.eachBatch;
|
|
2043
|
+
e.eachBatch = (r) => (async function(i, d) {
|
|
2044
|
+
let l = !1;
|
|
2045
|
+
try {
|
|
2046
|
+
typeof i?.isStale == "function" && (l = !!i.isStale());
|
|
2047
|
+
} catch {
|
|
2048
|
+
}
|
|
2049
|
+
if (l) return d(i);
|
|
2050
|
+
const a = i?.batch?.topic, s = Array.isArray(i?.batch?.messages) ? i.batch.messages[0] : void 0, u = me(W(s?.headers));
|
|
2051
|
+
return R({ library: "kafkajs", queueUri: ue(a), incomingTraceId: u }, () => d(i));
|
|
2052
|
+
})(r, o);
|
|
2053
|
+
}
|
|
2054
|
+
return n.call(this, e);
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
function yn(n) {
|
|
2058
|
+
return process.env[n] === "true";
|
|
2059
|
+
}
|
|
2060
|
+
const gn = [{ name: "bullmq", envDisableKey: "SF_DISABLE_BULLMQ", install: () => un() }, { name: "@taskforcesh/bullmq-pro", envDisableKey: "SF_DISABLE_BULLMQ_PRO", install: () => ln() }, { name: "kafkajs", envDisableKey: "SF_DISABLE_KAFKAJS", install: () => hn() }, { name: "@confluentinc/kafka-javascript", envDisableKey: "SF_DISABLE_CONFLUENT_KAFKA_JS", install: () => dn() }];
|
|
2061
|
+
let le = !1;
|
|
2062
|
+
function Pn() {
|
|
2063
|
+
return le;
|
|
2064
|
+
}
|
|
2065
|
+
function Fn() {
|
|
2066
|
+
const n = (function() {
|
|
2067
|
+
let t = 0;
|
|
2068
|
+
for (const { proto: e, key: o, original: r } of we.splice(0)) try {
|
|
2069
|
+
r === void 0 ? delete e[o] : e[o] = r, t += 1;
|
|
2070
|
+
} catch {
|
|
2071
|
+
}
|
|
2072
|
+
return t;
|
|
2073
|
+
})();
|
|
2074
|
+
return le = !1, n;
|
|
2075
|
+
}
|
|
2076
|
+
let qe = !1, Se = !1;
|
|
2077
|
+
function qn(n) {
|
|
2078
|
+
if (Se) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
|
|
2079
|
+
else if (!qe) {
|
|
2080
|
+
Se = !0, Ut();
|
|
1059
2081
|
try {
|
|
1060
2082
|
let t, e;
|
|
1061
|
-
const
|
|
1062
|
-
if (
|
|
1063
|
-
const
|
|
1064
|
-
`)[2] || "",
|
|
1065
|
-
|
|
2083
|
+
const o = ot(new Error().stack);
|
|
2084
|
+
if (o) {
|
|
2085
|
+
const l = o.split(`
|
|
2086
|
+
`)[2] || "", a = l.match(/\((.+):(\d+):\d+\)/) || l.match(/at (.+):(\d+):\d+/);
|
|
2087
|
+
a && (t = a[1], e = parseInt(a[2], 10));
|
|
1066
2088
|
}
|
|
1067
|
-
if (!
|
|
1068
|
-
const
|
|
1069
|
-
console.error(
|
|
2089
|
+
if (!n || !n.apiKey) {
|
|
2090
|
+
const l = `The required API Key is not provided: ${JSON.stringify(n)}`;
|
|
2091
|
+
console.error(l);
|
|
1070
2092
|
}
|
|
1071
|
-
const { config:
|
|
1072
|
-
if (
|
|
1073
|
-
}), t && (
|
|
1074
|
-
const
|
|
1075
|
-
throw console.error(
|
|
2093
|
+
const { config: r } = $t(n);
|
|
2094
|
+
if (Et(r).catch(() => {
|
|
2095
|
+
}), t && (r.setupInterceptorsFile = t), e && (r.setupInterceptorsLine = e), r.sfDebug && console.log("Updated configuration after applying options:", r), !r.apiKey || !r.apiGraphqlEndpoint) {
|
|
2096
|
+
const l = `The required config is not provided: ${JSON.stringify(r)}`;
|
|
2097
|
+
throw console.error(l), new Error(l);
|
|
1076
2098
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
}), process.env.SF_WORKER_POOL_DISABLED === "true" ?
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
const
|
|
1083
|
-
new
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1086
|
-
})(
|
|
1087
|
-
const
|
|
1088
|
-
|
|
2099
|
+
Yt() || Vt(void 0, r.sfDebug).catch((l) => {
|
|
2100
|
+
r.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", l);
|
|
2101
|
+
}), process.env.SF_WORKER_POOL_DISABLED === "true" ? r.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : sn() || (on(), r.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
|
|
2102
|
+
const i = new Ce();
|
|
2103
|
+
i.setServiceUUID(r.serviceUUID), qt(i), (function(l = []) {
|
|
2104
|
+
const a = new Wt(l);
|
|
2105
|
+
new Qt().doSend(a.getExcludedDomains());
|
|
2106
|
+
const s = new Jt(), u = new it();
|
|
2107
|
+
a.patchFetch(s, u), a.patchHttp(s, u);
|
|
2108
|
+
})(r.domainsToNotPropagateHeadersTo);
|
|
2109
|
+
const d = new xt();
|
|
2110
|
+
d.setServiceUUID(r.serviceUUID), Ct(d), Kt(), new Gt().send(), (function() {
|
|
2111
|
+
if (le) return;
|
|
2112
|
+
if (le = !0, process.env.SF_DISABLE_QUEUE_PATCHES === "true") return void (m().sfDebug && console.log("[sf-veritas] Async queue tracing DISABLED via SF_DISABLE_QUEUE_PATCHES=true"));
|
|
2113
|
+
const l = m(), a = [], s = [], u = [], c = [];
|
|
2114
|
+
for (const { name: h, envDisableKey: g, install: f } of gn) {
|
|
2115
|
+
if (yn(g)) {
|
|
2116
|
+
u.push(h);
|
|
2117
|
+
continue;
|
|
2118
|
+
}
|
|
2119
|
+
let y = "failed";
|
|
2120
|
+
try {
|
|
2121
|
+
y = f();
|
|
2122
|
+
} catch (S) {
|
|
2123
|
+
l.sfDebug && console.warn(`[asyncQueues] Failed to install ${h} patch:`, S), c.push(h);
|
|
2124
|
+
continue;
|
|
2125
|
+
}
|
|
2126
|
+
y === "installed" ? a.push(h) : y === "not-installed" ? s.push(h) : c.push(h);
|
|
2127
|
+
}
|
|
2128
|
+
const p = [`active: ${a.length ? a.join(", ") : "(none)"}`];
|
|
2129
|
+
s.length && p.push(`skipped (not installed): ${s.join(", ")}`), u.length && p.push(`disabled by env: ${u.join(", ")}`), c.length && p.push(`failed: ${c.join(", ")}`), (l.sfDebug || c.length > 0) && console.log(`[sf-veritas] Async queue tracing — ${p.join("; ")}`);
|
|
2130
|
+
})(), qe = !0, r.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
|
|
1089
2131
|
} finally {
|
|
1090
|
-
|
|
2132
|
+
Se = !1;
|
|
1091
2133
|
}
|
|
1092
2134
|
}
|
|
1093
2135
|
}
|
|
1094
|
-
function
|
|
1095
|
-
return
|
|
2136
|
+
function Cn() {
|
|
2137
|
+
return qe;
|
|
1096
2138
|
}
|
|
1097
|
-
function
|
|
1098
|
-
const
|
|
1099
|
-
new
|
|
2139
|
+
function Tn(n, t, e, o = !1) {
|
|
2140
|
+
const r = m();
|
|
2141
|
+
new st(r.apiKey).identify(n, t, e, o);
|
|
1100
2142
|
}
|
|
1101
|
-
function
|
|
1102
|
-
const
|
|
1103
|
-
new
|
|
2143
|
+
function An(n, t = {}, e, o = !1) {
|
|
2144
|
+
const r = m();
|
|
2145
|
+
new st(r.apiKey).addOrUpdateMetadata(n, t, e, o);
|
|
1104
2146
|
}
|
|
1105
|
-
let
|
|
1106
|
-
function
|
|
1107
|
-
const
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
const
|
|
1111
|
-
const
|
|
1112
|
-
if (
|
|
1113
|
-
const
|
|
1114
|
-
if (
|
|
2147
|
+
let be = null;
|
|
2148
|
+
function Bn(n, t, e, o) {
|
|
2149
|
+
const r = function(...i) {
|
|
2150
|
+
const d = nt(), l = d?.sfDebug || !1;
|
|
2151
|
+
l && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${e}::${t}`);
|
|
2152
|
+
const a = (function(f, y) {
|
|
2153
|
+
const S = ve();
|
|
2154
|
+
if (S) {
|
|
2155
|
+
const v = Ie(S);
|
|
2156
|
+
if (v) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${f}::${y}`), v;
|
|
1115
2157
|
}
|
|
1116
2158
|
try {
|
|
1117
|
-
return
|
|
2159
|
+
return Xt(f, y);
|
|
1118
2160
|
} catch {
|
|
1119
2161
|
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 };
|
|
1120
2162
|
}
|
|
1121
2163
|
})(e, t);
|
|
1122
|
-
if (
|
|
1123
|
-
if (
|
|
1124
|
-
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
const
|
|
1128
|
-
let
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
}),
|
|
2164
|
+
if (l && console.log(`[FuncSpan] Config for ${e}::${t}:`, a), a.enable_sampling && a.sample_rate < 1 && Math.random() > a.sample_rate) return l && console.log(`[FuncSpan] Skipping ${t} due to sampling`), n.apply(this, i);
|
|
2165
|
+
if (a.sample_rate === 0) return l && console.log(`[FuncSpan] Skipping ${t} - sample_rate is 0.0`), n.apply(this, i);
|
|
2166
|
+
l && console.log(`[FuncSpan] Capturing function span for ${t}`);
|
|
2167
|
+
const s = x.getInstance(), u = s.getCurrentFunctionSpanId(), c = G();
|
|
2168
|
+
s.setCurrentFunctionSpanId(c);
|
|
2169
|
+
const p = process.hrtime.bigint(), h = Date.now();
|
|
2170
|
+
let g = null;
|
|
2171
|
+
a.capture_arguments && (g = {}, o.paramNames.forEach((f, y) => {
|
|
2172
|
+
y < i.length && (g[f] = i[y]);
|
|
2173
|
+
}), g && a.arg_limit_mb > 0 && (g = de(g, a.arg_limit_mb)));
|
|
1132
2174
|
try {
|
|
1133
|
-
const
|
|
1134
|
-
if (
|
|
1135
|
-
const
|
|
1136
|
-
let
|
|
1137
|
-
return
|
|
1138
|
-
}, (
|
|
1139
|
-
const
|
|
1140
|
-
throw
|
|
2175
|
+
const f = n.apply(this, i);
|
|
2176
|
+
if (f && typeof f.then == "function") return u ? s.setCurrentFunctionSpanId(u) : s.clearCurrentFunctionSpanId(), f.then((_) => {
|
|
2177
|
+
const $ = process.hrtime.bigint(), k = Date.now(), q = Number($ - p);
|
|
2178
|
+
let E = null;
|
|
2179
|
+
return a.capture_return_value && a.return_limit_mb > 0 && (E = de(_, a.return_limit_mb)), se({ functionName: t, filePath: e, metadata: o, args: g, result: E, error: null, duration: k - h, durationNs: q, startTimeNs: p.toString(), async: !0, spanId: c, parentSpanId: u, pid: process.pid, threadId: oe }), _;
|
|
2180
|
+
}, (_) => {
|
|
2181
|
+
const $ = process.hrtime.bigint(), k = Date.now(), q = Number($ - p);
|
|
2182
|
+
throw se({ functionName: t, filePath: e, metadata: o, args: g, result: null, error: _?.message || String(_), duration: k - h, durationNs: q, startTimeNs: p.toString(), async: !0, spanId: c, parentSpanId: u, pid: process.pid, threadId: oe }), _;
|
|
1141
2183
|
});
|
|
1142
|
-
const
|
|
1143
|
-
let
|
|
1144
|
-
return
|
|
1145
|
-
} catch (
|
|
1146
|
-
const
|
|
1147
|
-
throw
|
|
2184
|
+
const y = process.hrtime.bigint(), S = Date.now(), v = Number(y - p);
|
|
2185
|
+
let I = null;
|
|
2186
|
+
return a.capture_return_value && a.return_limit_mb > 0 && (I = de(f, a.return_limit_mb)), se({ functionName: t, filePath: e, metadata: o, args: g, result: I, error: null, duration: S - h, durationNs: v, startTimeNs: p.toString(), async: !1, spanId: c, parentSpanId: u, pid: process.pid, threadId: oe }), u ? s.setCurrentFunctionSpanId(u) : s.clearCurrentFunctionSpanId(), f;
|
|
2187
|
+
} catch (f) {
|
|
2188
|
+
const y = process.hrtime.bigint(), S = Date.now(), v = Number(y - p);
|
|
2189
|
+
throw se({ functionName: t, filePath: e, metadata: o, args: g, result: null, error: f?.message || String(f), duration: S - h, durationNs: v, startTimeNs: p.toString(), async: !1, spanId: c, parentSpanId: u, pid: process.pid, threadId: oe }), u ? s.setCurrentFunctionSpanId(u) : s.clearCurrentFunctionSpanId(), f;
|
|
1148
2190
|
}
|
|
1149
2191
|
};
|
|
1150
|
-
Object.defineProperty(
|
|
1151
|
-
for (const
|
|
1152
|
-
return
|
|
1153
|
-
}
|
|
1154
|
-
function
|
|
1155
|
-
const t =
|
|
1156
|
-
e && console.log("[FuncSpan] captureSpanData called for:", { function:
|
|
1157
|
-
const
|
|
2192
|
+
Object.defineProperty(r, "name", { value: t, writable: !1 });
|
|
2193
|
+
for (const i in n) n.hasOwnProperty(i) && (r[i] = n[i]);
|
|
2194
|
+
return r;
|
|
2195
|
+
}
|
|
2196
|
+
function se(n) {
|
|
2197
|
+
const t = nt(), e = t?.sfDebug || !1;
|
|
2198
|
+
e && console.log("[FuncSpan] captureSpanData called for:", { function: n.functionName, file: n.filePath, duration: `${n.duration}ms`, async: n.async, error: n.error, spanId: n.spanId });
|
|
2199
|
+
const o = { functionName: n.functionName, filePath: n.filePath, metadata: n.metadata, args: n.args, result: n.result, error: n.error, duration: n.duration, durationNs: n.durationNs, async: n.async, spanId: n.spanId, parentSpanId: n.parentSpanId };
|
|
1158
2200
|
process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true" && console.log(`
|
|
1159
|
-
📊 Function Span:`, { function: `${
|
|
1160
|
-
const
|
|
1161
|
-
if (
|
|
1162
|
-
const
|
|
2201
|
+
📊 Function Span:`, { function: `${n.functionName} (${n.filePath}:${n.metadata.line}:${n.metadata.column})`, duration: `${n.duration.toFixed(2)}ms`, arguments: n.args, result: n.error ? `Error: ${n.error}` : n.result, spanId: n.spanId, parentSpanId: n.parentSpanId || "none" });
|
|
2202
|
+
const r = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
2203
|
+
if (r) try {
|
|
2204
|
+
const i = r === "true" || r === "1" ? "funcspans.jsonl" : r, d = Date.now(), l = process.hrtime.bigint(), a = BigInt(n.startTimeNs), s = Number(l - a) / 1e6, u = new Date(d - s).toISOString(), c = JSON.stringify({ timestamp: u, functionName: n.functionName, filePath: n.filePath, line: n.metadata.line, column: n.metadata.column, duration: n.duration, durationNs: n.durationNs, startTimeNs: n.startTimeNs, arguments: n.args, returnValue: n.error ? { error: String(n.error) } : n.result, spanId: n.spanId, parentSpanId: n.parentSpanId, async: n.async, pid: n.pid, threadId: n.threadId }) + `
|
|
1163
2205
|
`;
|
|
1164
|
-
|
|
1165
|
-
} catch (
|
|
1166
|
-
console.error("[FuncSpan] Error writing to JSONL file:",
|
|
2206
|
+
Lt(i, c, "utf-8");
|
|
2207
|
+
} catch (i) {
|
|
2208
|
+
console.error("[FuncSpan] Error writing to JSONL file:", i);
|
|
1167
2209
|
}
|
|
1168
|
-
if (e && console.log("[FuncSpan] Sending function span to transmitter:",
|
|
1169
|
-
(
|
|
1170
|
-
} catch (
|
|
1171
|
-
e && console.error("[FuncSpan] Error sending function span:",
|
|
2210
|
+
if (e && console.log("[FuncSpan] Sending function span to transmitter:", o), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
|
|
2211
|
+
(be || (be = new Dt()), be).send([o]), e && console.log("[FuncSpan] Function span sent successfully");
|
|
2212
|
+
} catch (i) {
|
|
2213
|
+
e && console.error("[FuncSpan] Error sending function span:", i);
|
|
1172
2214
|
}
|
|
1173
2215
|
}
|
|
1174
|
-
function
|
|
1175
|
-
return !!
|
|
2216
|
+
function Ln(n) {
|
|
2217
|
+
return !!n.includes("captureFunctionSpan(") || !!n.includes("@sailfish-ai/sf-veritas") || !(!n.includes("/* @sailfish-instrumented */") && !n.includes("// @sailfish-instrumented"));
|
|
1176
2218
|
}
|
|
1177
2219
|
export {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
2220
|
+
x as ContextManager,
|
|
2221
|
+
Nn as _setAsyncQueueHopSpy,
|
|
2222
|
+
An as addOrUpdateMetadata,
|
|
2223
|
+
Bn as captureFunctionSpan,
|
|
2224
|
+
xn as clearFuncspanOverride,
|
|
2225
|
+
H as getCurrentFunctionSpanId,
|
|
2226
|
+
rt as getDefaultConfig,
|
|
2227
|
+
wt as getEnvConfig,
|
|
2228
|
+
ve as getFuncspanOverride,
|
|
2229
|
+
Xt as getGlobalConfig,
|
|
2230
|
+
Tn as identify,
|
|
2231
|
+
Vt as initializeConfigLoader,
|
|
2232
|
+
on as initializeWorkerPoolPatching,
|
|
2233
|
+
Ln as isAlreadyInstrumented,
|
|
2234
|
+
Pn as isAsyncQueuePatchesInstalled,
|
|
2235
|
+
Yt as isConfigLoaderInitialized,
|
|
2236
|
+
Qn as isProductionEnvironment,
|
|
2237
|
+
Jn as isRuntimeModeEnabled,
|
|
2238
|
+
Cn as isSetupInterceptorsInitialized,
|
|
2239
|
+
sn as isWorkerPoolInitialized,
|
|
2240
|
+
Ie as parseHeaderOverride,
|
|
2241
|
+
Mn as runWithContext,
|
|
2242
|
+
jn as setFuncspanOverride,
|
|
2243
|
+
zn as setSkipTypeScriptPlugin,
|
|
2244
|
+
qn as setupInterceptors,
|
|
2245
|
+
Wn as shouldEnableRuntimeHooks,
|
|
2246
|
+
Vn as transformFunctionSpans,
|
|
2247
|
+
Xn as transformFunctionSpansSync,
|
|
2248
|
+
Fn as uninstallAsyncQueuePatches
|
|
1204
2249
|
};
|