@brizz/sdk 0.1.60 → 0.2.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/CHANGELOG.md +430 -0
- package/LICENSE +194 -20
- package/README.md +36 -1
- package/dist/{chunk-B5IY6O4N.js → chunk-6OYS2GR3.js} +1 -1
- package/dist/{chunk-WC573FCI.cjs → chunk-C5OT6GAQ.cjs} +10 -2
- package/dist/{chunk-Y4HNUX3Q.js → chunk-CZDPIJTO.js} +8 -0
- package/dist/{chunk-MPSJSXD3.js → chunk-GITAPIVL.js} +10 -10
- package/dist/{chunk-NF52RMLW.cjs → chunk-IWSFMCHH.cjs} +5 -1
- package/dist/{chunk-GISL4K6Z.js → chunk-JMX23OHO.js} +4 -0
- package/dist/{chunk-MW6L2BZN.js → chunk-KJSZPKSN.js} +5 -5
- package/dist/{chunk-RD4XCYKT.cjs → chunk-P5OONZTF.cjs} +3 -3
- package/dist/{chunk-WCUBTLL5.cjs → chunk-QXHGMS5A.cjs} +13 -13
- package/dist/{chunk-Y7UFS5CA.cjs → chunk-UF4GMVEY.cjs} +145 -145
- package/dist/eve.cjs +2 -3
- package/dist/eve.js +1 -2
- package/dist/google-genai-6S5E7GZ4.cjs +10 -0
- package/dist/{google-genai-3ERJNC7Q.js → google-genai-H6TMOKRX.js} +2 -3
- package/dist/google-genai.cjs +3 -4
- package/dist/google-genai.js +2 -3
- package/dist/index.cjs +592 -301
- package/dist/index.js +373 -82
- package/dist/{mcp-2AURUXLD.cjs → mcp-6LNVYVJQ.cjs} +39 -40
- package/dist/{mcp-IB3UO2FY.js → mcp-YTBE75NP.js} +5 -6
- package/dist/session.cjs +5 -6
- package/dist/session.js +4 -5
- package/dist/types/cjs/index.d.ts +1 -1
- package/dist/types/cjs/internal/instrumentation/auto-init.d.ts +0 -7
- package/dist/types/cjs/internal/instrumentation/registry.d.ts +2 -0
- package/dist/types/cjs/internal/instrumentation/vercel-ai/index.d.ts +28 -0
- package/dist/types/cjs/internal/instrumentation/vercel-ai/model-call-end.d.ts +1 -0
- package/dist/types/cjs/internal/log/emit.d.ts +2 -2
- package/dist/types/cjs/internal/log/logging.d.ts +2 -2
- package/dist/types/cjs/internal/sdk.d.ts +1 -0
- package/dist/types/cjs/internal/semantic-conventions.d.ts +2 -0
- package/dist/types/cjs/internal/trace/session.d.ts +1 -2
- package/dist/types/cjs/session.d.ts +1 -1
- package/dist/types/esm/index.d.ts +1 -1
- package/dist/types/esm/internal/instrumentation/auto-init.d.ts +0 -7
- package/dist/types/esm/internal/instrumentation/registry.d.ts +2 -0
- package/dist/types/esm/internal/instrumentation/vercel-ai/index.d.ts +28 -0
- package/dist/types/esm/internal/instrumentation/vercel-ai/model-call-end.d.ts +1 -0
- package/dist/types/esm/internal/log/emit.d.ts +2 -2
- package/dist/types/esm/internal/log/logging.d.ts +2 -2
- package/dist/types/esm/internal/sdk.d.ts +1 -0
- package/dist/types/esm/internal/semantic-conventions.d.ts +2 -0
- package/dist/types/esm/internal/trace/session.d.ts +1 -2
- package/dist/types/esm/session.d.ts +1 -1
- package/package.json +31 -27
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-6QXPHZEO.cjs +0 -130
- package/dist/chunk-GABRGNAU.js +0 -130
- package/dist/chunk-OBGZSXTJ.cjs +0 -10
- package/dist/google-genai-GVCKSJMR.cjs +0 -11
- package/dist/interrupt-36U5562Z.cjs +0 -12
- package/dist/interrupt-6BSXUK3O.js +0 -12
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
@@ -39,11 +39,11 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
var
|
|
42
|
+
var _chunkUF4GMVEYcjs = require('./chunk-UF4GMVEY.cjs');
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _chunkQXHGMS5Acjs = require('./chunk-QXHGMS5A.cjs');
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
@@ -51,7 +51,6 @@ var _chunkWCUBTLL5cjs = require('./chunk-WCUBTLL5.cjs');
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
var _chunkDC2MFO65cjs = require('./chunk-DC2MFO65.cjs');
|
|
55
54
|
|
|
56
55
|
|
|
57
56
|
|
|
@@ -59,10 +58,8 @@ var _chunkDC2MFO65cjs = require('./chunk-DC2MFO65.cjs');
|
|
|
59
58
|
|
|
60
59
|
|
|
61
60
|
|
|
62
|
-
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
63
61
|
|
|
64
62
|
|
|
65
|
-
var _chunk6QXPHZEOcjs = require('./chunk-6QXPHZEO.cjs');
|
|
66
63
|
|
|
67
64
|
|
|
68
65
|
|
|
@@ -73,6 +70,7 @@ var _chunk6QXPHZEOcjs = require('./chunk-6QXPHZEO.cjs');
|
|
|
73
70
|
|
|
74
71
|
|
|
75
72
|
|
|
73
|
+
var _chunkIWSFMCHHcjs = require('./chunk-IWSFMCHH.cjs');
|
|
76
74
|
|
|
77
75
|
|
|
78
76
|
|
|
@@ -80,16 +78,16 @@ var _chunk6QXPHZEOcjs = require('./chunk-6QXPHZEO.cjs');
|
|
|
80
78
|
|
|
81
79
|
|
|
82
80
|
|
|
81
|
+
var _chunkDC2MFO65cjs = require('./chunk-DC2MFO65.cjs');
|
|
83
82
|
|
|
84
83
|
|
|
85
84
|
|
|
86
85
|
|
|
87
86
|
|
|
88
87
|
|
|
89
|
-
var _chunkNF52RMLWcjs = require('./chunk-NF52RMLW.cjs');
|
|
90
88
|
|
|
91
89
|
|
|
92
|
-
var
|
|
90
|
+
var _chunkC5OT6GAQcjs = require('./chunk-C5OT6GAQ.cjs');
|
|
93
91
|
|
|
94
92
|
// src/internal/instrumentation/auto-init.ts
|
|
95
93
|
var _instrumentation = require('@opentelemetry/instrumentation');
|
|
@@ -112,7 +110,7 @@ var _api = require('@opentelemetry/api');
|
|
|
112
110
|
|
|
113
111
|
// src/internal/instrumentation/langgraph/attributes.ts
|
|
114
112
|
var INSTRUMENTATION_NAME = "@brizz/sdk/langgraph";
|
|
115
|
-
var INSTRUMENTATION_VERSION =
|
|
113
|
+
var INSTRUMENTATION_VERSION = _chunkQXHGMS5Acjs.getSDKVersion.call(void 0, );
|
|
116
114
|
var MODULE_NAME = "@langchain/langgraph";
|
|
117
115
|
var SUPPORTED_VERSIONS = [">=0.2.0 <2"];
|
|
118
116
|
function isSupportedVersion(version) {
|
|
@@ -212,11 +210,11 @@ var LangGraphInstrumentation = class extends _instrumentation.InstrumentationBas
|
|
|
212
210
|
applyPatch(moduleExports) {
|
|
213
211
|
const proto = resolvePregelPrototype(moduleExports);
|
|
214
212
|
if (!proto) {
|
|
215
|
-
|
|
213
|
+
_chunkC5OT6GAQcjs.logger.debug("Brizz LangGraph: module does not expose a Pregel prototype \u2014 skipping patch");
|
|
216
214
|
return;
|
|
217
215
|
}
|
|
218
216
|
if (patchPregelStream(proto, () => this.tracer)) {
|
|
219
|
-
|
|
217
|
+
_chunkC5OT6GAQcjs.logger.debug("Brizz LangGraph: patched Pregel.stream for checkpoint spans");
|
|
220
218
|
}
|
|
221
219
|
}
|
|
222
220
|
};
|
|
@@ -227,18 +225,18 @@ function patchInstalledLangGraph() {
|
|
|
227
225
|
requireFromSdk = _module.createRequire.call(void 0, __filename);
|
|
228
226
|
version = requireFromSdk(`${MODULE_NAME}/package.json`).version;
|
|
229
227
|
} catch (error) {
|
|
230
|
-
|
|
228
|
+
_chunkC5OT6GAQcjs.logger.debug(`LangGraph not resolved, not patched: ${String(error)}`);
|
|
231
229
|
return;
|
|
232
230
|
}
|
|
233
231
|
if (!isSupportedVersion(version)) {
|
|
234
|
-
|
|
232
|
+
_chunkC5OT6GAQcjs.logger.debug(`LangGraph ${version} is outside ${SUPPORTED_VERSIONS.join(" ")}, not patched`);
|
|
235
233
|
return;
|
|
236
234
|
}
|
|
237
235
|
let instrumentation;
|
|
238
236
|
try {
|
|
239
237
|
instrumentation = new LangGraphInstrumentation({ enabled: false });
|
|
240
238
|
} catch (error) {
|
|
241
|
-
|
|
239
|
+
_chunkC5OT6GAQcjs.logger.debug(`LangGraph instrumentation not constructed: ${String(error)}`);
|
|
242
240
|
return;
|
|
243
241
|
}
|
|
244
242
|
try {
|
|
@@ -247,13 +245,13 @@ function patchInstalledLangGraph() {
|
|
|
247
245
|
instrumentation.manuallyInstrument(loaded.exports);
|
|
248
246
|
}
|
|
249
247
|
} catch (error) {
|
|
250
|
-
|
|
248
|
+
_chunkC5OT6GAQcjs.logger.debug(`LangGraph CJS build not patched: ${String(error)}`);
|
|
251
249
|
}
|
|
252
250
|
void (async () => {
|
|
253
251
|
try {
|
|
254
252
|
instrumentation.manuallyInstrument(await Promise.resolve().then(() => _interopRequireWildcard(require("@langchain/langgraph"))));
|
|
255
253
|
} catch (error) {
|
|
256
|
-
|
|
254
|
+
_chunkC5OT6GAQcjs.logger.debug(`LangGraph not patched: ${String(error)}`);
|
|
257
255
|
}
|
|
258
256
|
})();
|
|
259
257
|
}
|
|
@@ -291,7 +289,7 @@ function patchSaver(checkpointer) {
|
|
|
291
289
|
patchedSavers.add(proto);
|
|
292
290
|
const originalPut = proto.put;
|
|
293
291
|
if (typeof originalPut !== "function") {
|
|
294
|
-
|
|
292
|
+
_chunkC5OT6GAQcjs.logger.debug("Brizz LangGraph: checkpointer exposes no put \u2014 checkpoint ids unavailable");
|
|
295
293
|
return;
|
|
296
294
|
}
|
|
297
295
|
const patchedPut = function brizzPut(config, checkpoint, ...rest) {
|
|
@@ -318,7 +316,7 @@ function recordCheckpoint(config, checkpoint) {
|
|
|
318
316
|
setIfKnown(span, ATTR_CHECKPOINT_THREAD_ID, readThreadId(config));
|
|
319
317
|
setIfKnown(span, ATTR_CHECKPOINT_NS, readCheckpointNs(config));
|
|
320
318
|
} catch (error) {
|
|
321
|
-
|
|
319
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz LangGraph: could not record a checkpoint write: ${String(error)}`);
|
|
322
320
|
}
|
|
323
321
|
}
|
|
324
322
|
function setIfKnown(span, key, value) {
|
|
@@ -342,7 +340,7 @@ function beginRun(graph, options, getTracer) {
|
|
|
342
340
|
runContext: _api.trace.setSpan(_api.context.active(), span).setValue(CHECKPOINT_SPAN_KEY, span)
|
|
343
341
|
};
|
|
344
342
|
} catch (error) {
|
|
345
|
-
|
|
343
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz LangGraph: could not start checkpoint span: ${String(error)}`);
|
|
346
344
|
return void 0;
|
|
347
345
|
}
|
|
348
346
|
}
|
|
@@ -366,7 +364,7 @@ function endRun(run, error) {
|
|
|
366
364
|
run.span.setStatus({ code: _api.SpanStatusCode.ERROR });
|
|
367
365
|
}
|
|
368
366
|
} catch (spanError) {
|
|
369
|
-
|
|
367
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz LangGraph: could not finish checkpoint span: ${String(spanError)}`);
|
|
370
368
|
} finally {
|
|
371
369
|
run.span.end();
|
|
372
370
|
}
|
|
@@ -464,7 +462,7 @@ function toJson(value) {
|
|
|
464
462
|
try {
|
|
465
463
|
return JSON.stringify(value);
|
|
466
464
|
} catch (error) {
|
|
467
|
-
|
|
465
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz: value is not JSON-serializable: ${String(error)}`);
|
|
468
466
|
return void 0;
|
|
469
467
|
}
|
|
470
468
|
}
|
|
@@ -483,7 +481,7 @@ var ATTR_ANSWERS = "typesafe.answers";
|
|
|
483
481
|
var PATCHED_FLAG2 = /* @__PURE__ */ Symbol.for("brizz.typesafe.patched");
|
|
484
482
|
var TypeSafeInstrumentation = class extends _instrumentation.InstrumentationBase {
|
|
485
483
|
constructor(config = {}) {
|
|
486
|
-
super(INSTRUMENTATION_NAME2,
|
|
484
|
+
super(INSTRUMENTATION_NAME2, _chunkQXHGMS5Acjs.getSDKVersion.call(void 0, ), config);
|
|
487
485
|
this.setTracerProvider(_chunkDC2MFO65cjs.brizzTracerProvider);
|
|
488
486
|
}
|
|
489
487
|
init() {
|
|
@@ -508,11 +506,11 @@ var TypeSafeInstrumentation = class extends _instrumentation.InstrumentationBase
|
|
|
508
506
|
manuallyInstrument(moduleExports) {
|
|
509
507
|
const client = _optionalChain([moduleExports, 'optionalAccess', _21 => _21.TypeSafeClient]);
|
|
510
508
|
if (typeof client !== "function" || !client.prototype) {
|
|
511
|
-
|
|
509
|
+
_chunkC5OT6GAQcjs.logger.debug("Brizz TypeSafe: module does not expose TypeSafeClient \u2014 skipping patch");
|
|
512
510
|
return;
|
|
513
511
|
}
|
|
514
512
|
if (patchSystemOne(client.prototype, () => this.tracer)) {
|
|
515
|
-
|
|
513
|
+
_chunkC5OT6GAQcjs.logger.debug("Brizz TypeSafe: patched TypeSafeClient.systemOne");
|
|
516
514
|
}
|
|
517
515
|
}
|
|
518
516
|
};
|
|
@@ -523,18 +521,18 @@ function patchInstalledTypeSafe() {
|
|
|
523
521
|
requireFromSdk = _module.createRequire.call(void 0, __filename);
|
|
524
522
|
version = requireFromSdk(`${MODULE_NAME2}/package.json`).version;
|
|
525
523
|
} catch (error) {
|
|
526
|
-
|
|
524
|
+
_chunkC5OT6GAQcjs.logger.debug(`TypeSafe not resolved, not patched: ${String(error)}`);
|
|
527
525
|
return;
|
|
528
526
|
}
|
|
529
527
|
if (!isSupportedVersion2(version)) {
|
|
530
|
-
|
|
528
|
+
_chunkC5OT6GAQcjs.logger.debug(`TypeSafe ${version} is outside ${SUPPORTED_VERSIONS2.join(" ")}, not patched`);
|
|
531
529
|
return;
|
|
532
530
|
}
|
|
533
531
|
let instrumentation;
|
|
534
532
|
try {
|
|
535
533
|
instrumentation = new TypeSafeInstrumentation({ enabled: false });
|
|
536
534
|
} catch (error) {
|
|
537
|
-
|
|
535
|
+
_chunkC5OT6GAQcjs.logger.debug(`TypeSafe instrumentation not constructed: ${String(error)}`);
|
|
538
536
|
return;
|
|
539
537
|
}
|
|
540
538
|
try {
|
|
@@ -543,13 +541,13 @@ function patchInstalledTypeSafe() {
|
|
|
543
541
|
instrumentation.manuallyInstrument(loaded.exports);
|
|
544
542
|
}
|
|
545
543
|
} catch (error) {
|
|
546
|
-
|
|
544
|
+
_chunkC5OT6GAQcjs.logger.debug(`TypeSafe CJS build not patched: ${String(error)}`);
|
|
547
545
|
}
|
|
548
546
|
void (async () => {
|
|
549
547
|
try {
|
|
550
548
|
instrumentation.manuallyInstrument(await Promise.resolve().then(() => _interopRequireWildcard(require("@typesafe-ai/sdk"))));
|
|
551
549
|
} catch (error) {
|
|
552
|
-
|
|
550
|
+
_chunkC5OT6GAQcjs.logger.debug(`TypeSafe not patched: ${String(error)}`);
|
|
553
551
|
}
|
|
554
552
|
})();
|
|
555
553
|
}
|
|
@@ -610,7 +608,7 @@ function observe(pending, span) {
|
|
|
610
608
|
return pending;
|
|
611
609
|
}
|
|
612
610
|
} catch (error) {
|
|
613
|
-
|
|
611
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz TypeSafe: could not observe the call: ${String(error)}`);
|
|
614
612
|
}
|
|
615
613
|
endSpan(span);
|
|
616
614
|
return pending;
|
|
@@ -619,21 +617,21 @@ function startSpan(getTracer, request) {
|
|
|
619
617
|
try {
|
|
620
618
|
const model = typeof _optionalChain([request, 'optionalAccess', _25 => _25.model]) === "string" && request.model !== "" ? request.model : void 0;
|
|
621
619
|
const attributes = {
|
|
622
|
-
[
|
|
623
|
-
[
|
|
624
|
-
[
|
|
620
|
+
[_chunkIWSFMCHHcjs.GEN_AI_OPERATION_NAME]: _chunkIWSFMCHHcjs.GEN_AI_OPERATION_CLASSIFY,
|
|
621
|
+
[_chunkIWSFMCHHcjs.GEN_AI_PROVIDER_NAME]: PROVIDER_NAME,
|
|
622
|
+
[_chunkIWSFMCHHcjs.GEN_AI_INPUT_MESSAGES]: JSON.stringify([
|
|
625
623
|
{ role: "user", parts: [{ type: "text", content: text(_optionalChain([request, 'optionalAccess', _26 => _26.state])) }] }
|
|
626
624
|
])
|
|
627
625
|
};
|
|
628
626
|
if (model) {
|
|
629
|
-
attributes[
|
|
627
|
+
attributes[_chunkIWSFMCHHcjs.GEN_AI_REQUEST_MODEL] = model;
|
|
630
628
|
}
|
|
631
629
|
if (_optionalChain([request, 'optionalAccess', _27 => _27.questions]) !== void 0) {
|
|
632
630
|
attributes[ATTR_QUESTIONS] = JSON.stringify(request.questions);
|
|
633
631
|
}
|
|
634
632
|
return getTracer().startSpan(SPAN_NAME, { kind: _api.SpanKind.CLIENT, attributes });
|
|
635
633
|
} catch (error) {
|
|
636
|
-
|
|
634
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz TypeSafe: could not start span: ${String(error)}`);
|
|
637
635
|
return void 0;
|
|
638
636
|
}
|
|
639
637
|
}
|
|
@@ -641,19 +639,19 @@ function recordResult(span, result) {
|
|
|
641
639
|
try {
|
|
642
640
|
const { model, usage, answers } = _nullishCoalesce(result, () => ( {}));
|
|
643
641
|
if (typeof model === "string" && model) {
|
|
644
|
-
span.setAttribute(
|
|
642
|
+
span.setAttribute(_chunkIWSFMCHHcjs.GEN_AI_RESPONSE_MODEL, model);
|
|
645
643
|
}
|
|
646
644
|
if (typeof _optionalChain([usage, 'optionalAccess', _28 => _28.input_tokens]) === "number") {
|
|
647
|
-
span.setAttribute(
|
|
645
|
+
span.setAttribute(_chunkIWSFMCHHcjs.GEN_AI_USAGE_INPUT_TOKENS, usage.input_tokens);
|
|
648
646
|
}
|
|
649
647
|
if (typeof _optionalChain([usage, 'optionalAccess', _29 => _29.output_tokens]) === "number") {
|
|
650
|
-
span.setAttribute(
|
|
648
|
+
span.setAttribute(_chunkIWSFMCHHcjs.GEN_AI_USAGE_OUTPUT_TOKENS, usage.output_tokens);
|
|
651
649
|
}
|
|
652
650
|
if (answers !== void 0) {
|
|
653
651
|
span.setAttribute(ATTR_ANSWERS, JSON.stringify(answers));
|
|
654
652
|
}
|
|
655
653
|
} catch (error) {
|
|
656
|
-
|
|
654
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz TypeSafe: could not record the answers: ${String(error)}`);
|
|
657
655
|
}
|
|
658
656
|
}
|
|
659
657
|
function endSpan(span, error) {
|
|
@@ -663,22 +661,22 @@ function endSpan(span, error) {
|
|
|
663
661
|
if (error !== void 0) {
|
|
664
662
|
span.recordException(error instanceof Error ? error : new Error(String(error)));
|
|
665
663
|
span.setStatus({ code: _api.SpanStatusCode.ERROR, message: String(error) });
|
|
666
|
-
span.setAttribute(
|
|
664
|
+
span.setAttribute(_chunkIWSFMCHHcjs.ERROR_TYPE, errorType(error));
|
|
667
665
|
}
|
|
668
666
|
span.end();
|
|
669
667
|
}
|
|
670
668
|
|
|
671
669
|
// src/internal/instrumentation/auto-init.ts
|
|
672
670
|
var exceptionLogger = (error) => {
|
|
673
|
-
|
|
671
|
+
_chunkC5OT6GAQcjs.logger.error(`Exception in instrumentation: ${String(error)}`);
|
|
674
672
|
};
|
|
675
673
|
function loadGenAIInstrumentations() {
|
|
676
674
|
const instrumentations = [];
|
|
677
675
|
try {
|
|
678
676
|
instrumentations.push(new BrizzOpenAIInstrumentation());
|
|
679
|
-
|
|
677
|
+
_chunkC5OT6GAQcjs.logger.debug("Auto-loaded OpenAI instrumentation");
|
|
680
678
|
} catch (error) {
|
|
681
|
-
|
|
679
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to auto-load OpenAI instrumentation: ${String(error)}`);
|
|
682
680
|
}
|
|
683
681
|
const genAIInstrumentationClasses = [
|
|
684
682
|
{ class: _instrumentationanthropic.AnthropicInstrumentation, name: "Anthropic" },
|
|
@@ -694,28 +692,28 @@ function loadGenAIInstrumentations() {
|
|
|
694
692
|
try {
|
|
695
693
|
const instrumentation = new config.class({ exceptionLogger });
|
|
696
694
|
instrumentations.push(instrumentation);
|
|
697
|
-
|
|
695
|
+
_chunkC5OT6GAQcjs.logger.debug(`Auto-loaded ${config.name} instrumentation`);
|
|
698
696
|
} catch (error) {
|
|
699
|
-
|
|
697
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to auto-load ${config.name} instrumentation: ${String(error)}`);
|
|
700
698
|
}
|
|
701
699
|
}
|
|
702
700
|
try {
|
|
703
701
|
_instrumentation.registerInstrumentations.call(void 0, { instrumentations, tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider });
|
|
704
|
-
|
|
702
|
+
_chunkC5OT6GAQcjs.logger.info(`Auto-registered ${instrumentations.length} GenAI instrumentations`);
|
|
705
703
|
} catch (error) {
|
|
706
|
-
|
|
704
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to register GenAI instrumentations: ${String(error)}`);
|
|
707
705
|
}
|
|
708
706
|
return instrumentations;
|
|
709
707
|
}
|
|
710
708
|
function loadMCPInstrumentation() {
|
|
711
709
|
void (async () => {
|
|
712
710
|
try {
|
|
713
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
711
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-6LNVYVJQ.cjs")));
|
|
714
712
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
715
713
|
_instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp], tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider });
|
|
716
|
-
|
|
714
|
+
_chunkC5OT6GAQcjs.logger.debug("Auto-loaded MCP instrumentation");
|
|
717
715
|
} catch (error) {
|
|
718
|
-
|
|
716
|
+
_chunkC5OT6GAQcjs.logger.debug(
|
|
719
717
|
`MCP instrumentation not loaded (install @modelcontextprotocol/sdk and @arizeai/openinference-instrumentation-mcp if you want MCP support): ${String(error)}`
|
|
720
718
|
);
|
|
721
719
|
}
|
|
@@ -727,9 +725,9 @@ function loadLangGraphInstrumentation() {
|
|
|
727
725
|
instrumentations: [new LangGraphInstrumentation()],
|
|
728
726
|
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
729
727
|
});
|
|
730
|
-
|
|
728
|
+
_chunkC5OT6GAQcjs.logger.debug("Auto-loaded LangGraph instrumentation");
|
|
731
729
|
} catch (error) {
|
|
732
|
-
|
|
730
|
+
_chunkC5OT6GAQcjs.logger.debug(`LangGraph instrumentation not loaded: ${String(error)}`);
|
|
733
731
|
}
|
|
734
732
|
}
|
|
735
733
|
function loadTypeSafeInstrumentation() {
|
|
@@ -738,9 +736,9 @@ function loadTypeSafeInstrumentation() {
|
|
|
738
736
|
instrumentations: [new TypeSafeInstrumentation()],
|
|
739
737
|
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
740
738
|
});
|
|
741
|
-
|
|
739
|
+
_chunkC5OT6GAQcjs.logger.debug("Auto-loaded TypeSafe instrumentation");
|
|
742
740
|
} catch (error) {
|
|
743
|
-
|
|
741
|
+
_chunkC5OT6GAQcjs.logger.debug(`TypeSafe instrumentation not loaded: ${String(error)}`);
|
|
744
742
|
}
|
|
745
743
|
}
|
|
746
744
|
function loadVertexAIInstrumentation() {
|
|
@@ -752,9 +750,9 @@ function loadVertexAIInstrumentation() {
|
|
|
752
750
|
instrumentations: [vertexAI],
|
|
753
751
|
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
754
752
|
});
|
|
755
|
-
|
|
753
|
+
_chunkC5OT6GAQcjs.logger.debug("Auto-loaded Vertex AI instrumentation");
|
|
756
754
|
} catch (error) {
|
|
757
|
-
|
|
755
|
+
_chunkC5OT6GAQcjs.logger.debug(
|
|
758
756
|
`Vertex AI instrumentation not loaded (install @traceloop/instrumentation-vertexai if you want Vertex AI support): ${String(error)}`
|
|
759
757
|
);
|
|
760
758
|
}
|
|
@@ -763,67 +761,20 @@ function loadVertexAIInstrumentation() {
|
|
|
763
761
|
function loadGoogleGenAIInstrumentation() {
|
|
764
762
|
void (async () => {
|
|
765
763
|
try {
|
|
766
|
-
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-
|
|
764
|
+
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-6S5E7GZ4.cjs")));
|
|
767
765
|
const googleGenAI = new GoogleGenAIInstrumentation({ exceptionLogger });
|
|
768
766
|
_instrumentation.registerInstrumentations.call(void 0, {
|
|
769
767
|
instrumentations: [googleGenAI],
|
|
770
768
|
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
771
769
|
});
|
|
772
|
-
|
|
770
|
+
_chunkC5OT6GAQcjs.logger.debug("Auto-loaded Google GenAI instrumentation");
|
|
773
771
|
} catch (error) {
|
|
774
|
-
|
|
772
|
+
_chunkC5OT6GAQcjs.logger.debug(
|
|
775
773
|
`Google GenAI instrumentation not loaded (install @traceloop/instrumentation-google-generativeai if you want Gemini support): ${String(error)}`
|
|
776
774
|
);
|
|
777
775
|
}
|
|
778
776
|
})();
|
|
779
777
|
}
|
|
780
|
-
function selectTelemetryRegister(ai) {
|
|
781
|
-
const register = _nullishCoalesce(ai.registerTelemetry, () => ( ai.registerTelemetryIntegration));
|
|
782
|
-
return typeof register === "function" ? register : void 0;
|
|
783
|
-
}
|
|
784
|
-
function loadVercelAITelemetry() {
|
|
785
|
-
void (async () => {
|
|
786
|
-
try {
|
|
787
|
-
const ai = await Promise.resolve().then(() => _interopRequireWildcard(require("ai")));
|
|
788
|
-
const register = selectTelemetryRegister(ai);
|
|
789
|
-
if (!register) {
|
|
790
|
-
_chunkWC573FCIcjs.logger.debug(
|
|
791
|
-
"AI SDK present but lacks a telemetry-registration hook (needs ai@>=6); skipping"
|
|
792
|
-
);
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
const isV7 = typeof ai.registerTelemetry === "function";
|
|
796
|
-
const integrations = [];
|
|
797
|
-
const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-36U5562Z.cjs")));
|
|
798
|
-
integrations.push(createInterruptIntegration());
|
|
799
|
-
let otelCollectorLoaded = false;
|
|
800
|
-
try {
|
|
801
|
-
const otel = await Promise.resolve().then(() => _interopRequireWildcard(require("@ai-sdk/otel")));
|
|
802
|
-
if (typeof otel.LegacyOpenTelemetry === "function") {
|
|
803
|
-
integrations.push(
|
|
804
|
-
new otel.LegacyOpenTelemetry({ tracer: _chunkDC2MFO65cjs.brizzTracerProvider.getTracer("ai") })
|
|
805
|
-
);
|
|
806
|
-
otelCollectorLoaded = true;
|
|
807
|
-
}
|
|
808
|
-
} catch (e) {
|
|
809
|
-
}
|
|
810
|
-
if (!otelCollectorLoaded) {
|
|
811
|
-
const message = "AI SDK present but @ai-sdk/otel is missing or unusable; install it (npm install @ai-sdk/otel) to capture AI SDK spans on ai@>=7";
|
|
812
|
-
if (isV7) {
|
|
813
|
-
_chunkWC573FCIcjs.logger.warn(message);
|
|
814
|
-
} else {
|
|
815
|
-
_chunkWC573FCIcjs.logger.debug(message);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
register(...integrations);
|
|
819
|
-
_chunkWC573FCIcjs.logger.debug("Auto-loaded Vercel AI telemetry");
|
|
820
|
-
} catch (error) {
|
|
821
|
-
_chunkWC573FCIcjs.logger.debug(
|
|
822
|
-
`Vercel AI telemetry not loaded (install ai@>=6 to capture AI SDK telemetry): ${String(error)}`
|
|
823
|
-
);
|
|
824
|
-
}
|
|
825
|
-
})();
|
|
826
|
-
}
|
|
827
778
|
function autoInitializeInstrumentations() {
|
|
828
779
|
try {
|
|
829
780
|
const genAIInstrumentations = loadGenAIInstrumentations();
|
|
@@ -832,13 +783,12 @@ function autoInitializeInstrumentations() {
|
|
|
832
783
|
loadTypeSafeInstrumentation();
|
|
833
784
|
loadVertexAIInstrumentation();
|
|
834
785
|
loadGoogleGenAIInstrumentation();
|
|
835
|
-
|
|
836
|
-
_chunkWC573FCIcjs.logger.info(
|
|
786
|
+
_chunkC5OT6GAQcjs.logger.info(
|
|
837
787
|
`Auto-initialization complete: ${genAIInstrumentations.length} GenAI instrumentations`
|
|
838
788
|
);
|
|
839
789
|
return true;
|
|
840
790
|
} catch (error) {
|
|
841
|
-
|
|
791
|
+
_chunkC5OT6GAQcjs.logger.error(`Auto-initialization failed: ${String(error)}`);
|
|
842
792
|
return false;
|
|
843
793
|
}
|
|
844
794
|
}
|
|
@@ -869,20 +819,20 @@ function parseBoolEnv(name) {
|
|
|
869
819
|
if (value === "true" || value === "false") {
|
|
870
820
|
return value === "true";
|
|
871
821
|
}
|
|
872
|
-
|
|
822
|
+
_chunkC5OT6GAQcjs.logger.warn(`Brizz: ignoring ${name}=${raw}; expected true or false.`);
|
|
873
823
|
return void 0;
|
|
874
824
|
}
|
|
875
825
|
function resolveConfig(options) {
|
|
876
|
-
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access', _30 => _30.logLevel, 'optionalAccess', _31 => _31.toString, 'call', _32 => _32()]) ||
|
|
826
|
+
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access', _30 => _30.logLevel, 'optionalAccess', _31 => _31.toString, 'call', _32 => _32()]) || _chunkC5OT6GAQcjs.DEFAULT_LOG_LEVEL.toString();
|
|
877
827
|
let resolvedLogLevel;
|
|
878
828
|
if (envLogLevel) {
|
|
879
|
-
resolvedLogLevel =
|
|
829
|
+
resolvedLogLevel = _chunkC5OT6GAQcjs.parseLogLevel.call(void 0, envLogLevel);
|
|
880
830
|
} else if (typeof options.logLevel === "string") {
|
|
881
|
-
resolvedLogLevel =
|
|
831
|
+
resolvedLogLevel = _chunkC5OT6GAQcjs.parseLogLevel.call(void 0, options.logLevel);
|
|
882
832
|
} else {
|
|
883
|
-
resolvedLogLevel = options.logLevel ||
|
|
833
|
+
resolvedLogLevel = options.logLevel || _chunkC5OT6GAQcjs.DEFAULT_LOG_LEVEL;
|
|
884
834
|
}
|
|
885
|
-
|
|
835
|
+
_chunkC5OT6GAQcjs.setLogLevel.call(void 0, resolvedLogLevel);
|
|
886
836
|
let maskingStatus;
|
|
887
837
|
if (options.masking === true) {
|
|
888
838
|
maskingStatus = "enabled";
|
|
@@ -893,7 +843,7 @@ function resolveConfig(options) {
|
|
|
893
843
|
} else {
|
|
894
844
|
maskingStatus = "default-disabled";
|
|
895
845
|
}
|
|
896
|
-
|
|
846
|
+
_chunkC5OT6GAQcjs.logger.debug("Starting configuration resolution", {
|
|
897
847
|
appName: options.appName,
|
|
898
848
|
baseUrl: options.baseUrl,
|
|
899
849
|
hasApiKey: !!options.apiKey,
|
|
@@ -948,7 +898,7 @@ function resolveConfig(options) {
|
|
|
948
898
|
(name) => process.env[name] !== void 0
|
|
949
899
|
);
|
|
950
900
|
if (envConflicts.length > 0) {
|
|
951
|
-
|
|
901
|
+
_chunkC5OT6GAQcjs.logger.warn(
|
|
952
902
|
`Ignoring ${envConflicts.join(", ")} \u2014 dsn / BRIZZ_DSN takes precedence.`
|
|
953
903
|
);
|
|
954
904
|
}
|
|
@@ -968,11 +918,11 @@ function resolveConfig(options) {
|
|
|
968
918
|
try {
|
|
969
919
|
const envHeaders = JSON.parse(process.env["BRIZZ_HEADERS"]);
|
|
970
920
|
Object.assign(resolvedConfig.headers, envHeaders);
|
|
971
|
-
|
|
921
|
+
_chunkC5OT6GAQcjs.logger.debug("Added headers from environment variable", {
|
|
972
922
|
headers: Object.keys(envHeaders)
|
|
973
923
|
});
|
|
974
924
|
} catch (error) {
|
|
975
|
-
|
|
925
|
+
_chunkC5OT6GAQcjs.logger.error("Failed to parse BRIZZ_HEADERS environment variable", { error });
|
|
976
926
|
throw new Error("Invalid JSON in BRIZZ_HEADERS environment variable", { cause: error });
|
|
977
927
|
}
|
|
978
928
|
}
|
|
@@ -988,7 +938,7 @@ function resolveConfig(options) {
|
|
|
988
938
|
resolvedConfig.headers[_chunkUNLNNKZ7cjs.SERVICE_NAME_HEADER] = parsedDSN.service;
|
|
989
939
|
}
|
|
990
940
|
}
|
|
991
|
-
|
|
941
|
+
_chunkC5OT6GAQcjs.logger.debug("Configuration resolved with environment variables", {
|
|
992
942
|
appName: resolvedConfig.appName,
|
|
993
943
|
baseUrl: resolvedConfig.baseUrl,
|
|
994
944
|
hasApiKey: !!resolvedConfig.apiKey,
|
|
@@ -1029,23 +979,23 @@ var PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.callbackManager
|
|
|
1029
979
|
var TRACER_PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.tracerPatched");
|
|
1030
980
|
var runContexts = /* @__PURE__ */ new WeakMap();
|
|
1031
981
|
var OMITTED_KEYS = /* @__PURE__ */ new Set([
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
982
|
+
_chunkIWSFMCHHcjs.USER_EMAIL,
|
|
983
|
+
_chunkIWSFMCHHcjs.USER_NAME,
|
|
984
|
+
_chunkIWSFMCHHcjs.ORGANIZATION_NAME,
|
|
985
|
+
_chunkIWSFMCHHcjs.ORGANIZATION_DOMAIN
|
|
1036
986
|
]);
|
|
1037
987
|
var TOOL_CALL_ID_METADATA_KEY = "brizz_tool_call_id";
|
|
1038
988
|
var TOOL_ID = "tool.id";
|
|
1039
989
|
var TOOL_CALL_ID_ARG = 7;
|
|
1040
990
|
function runMetadataFromContext() {
|
|
1041
|
-
const bag = _api.context.active().getValue(
|
|
991
|
+
const bag = _api.context.active().getValue(_chunkIWSFMCHHcjs.PROPERTIES_CONTEXT_KEY);
|
|
1042
992
|
if (!bag) {
|
|
1043
993
|
return void 0;
|
|
1044
994
|
}
|
|
1045
995
|
const metadata = {};
|
|
1046
996
|
for (const [name, value] of Object.entries(bag)) {
|
|
1047
997
|
if (!OMITTED_KEYS.has(name)) {
|
|
1048
|
-
metadata[`${
|
|
998
|
+
metadata[`${_chunkIWSFMCHHcjs.BRIZZ}.${name}`] = String(value);
|
|
1049
999
|
}
|
|
1050
1000
|
}
|
|
1051
1001
|
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
@@ -1072,12 +1022,12 @@ function patchCallbackManagerModule(module2) {
|
|
|
1072
1022
|
if (manager && metadata) {
|
|
1073
1023
|
manager.addMetadata(metadata);
|
|
1074
1024
|
}
|
|
1075
|
-
} catch (
|
|
1025
|
+
} catch (e) {
|
|
1076
1026
|
}
|
|
1077
1027
|
_optionalChain([manager, 'optionalAccess', _34 => _34.handlers, 'optionalAccess', _35 => _35.forEach, 'call', _36 => _36((handler) => {
|
|
1078
1028
|
try {
|
|
1079
1029
|
patchTracer(handler);
|
|
1080
|
-
} catch (
|
|
1030
|
+
} catch (e2) {
|
|
1081
1031
|
}
|
|
1082
1032
|
})]);
|
|
1083
1033
|
return manager;
|
|
@@ -1132,7 +1082,7 @@ function patchToolStart(prototype) {
|
|
|
1132
1082
|
delete rest[TOOL_CALL_ID_METADATA_KEY];
|
|
1133
1083
|
this.metadata = rest;
|
|
1134
1084
|
}
|
|
1135
|
-
} catch (
|
|
1085
|
+
} catch (e3) {
|
|
1136
1086
|
}
|
|
1137
1087
|
return handleToolStart.apply(this, args);
|
|
1138
1088
|
};
|
|
@@ -1142,13 +1092,13 @@ function patchInstalledCallbackManager() {
|
|
|
1142
1092
|
try {
|
|
1143
1093
|
patchCallbackManagerModule(await Promise.resolve().then(() => _interopRequireWildcard(require("@langchain/core/callbacks/manager"))));
|
|
1144
1094
|
} catch (error) {
|
|
1145
|
-
|
|
1095
|
+
_chunkC5OT6GAQcjs.logger.debug(`LangChain callback manager not patched: ${String(error)}`);
|
|
1146
1096
|
}
|
|
1147
1097
|
try {
|
|
1148
1098
|
const requireFromSdk = _module.createRequire.call(void 0, __filename);
|
|
1149
1099
|
patchCallbackManagerModule(requireFromSdk("@langchain/core/callbacks/manager"));
|
|
1150
1100
|
} catch (error) {
|
|
1151
|
-
|
|
1101
|
+
_chunkC5OT6GAQcjs.logger.debug(`LangChain CJS callback manager not patched: ${String(error)}`);
|
|
1152
1102
|
}
|
|
1153
1103
|
})();
|
|
1154
1104
|
}
|
|
@@ -1160,7 +1110,7 @@ function restampLangChainSpan(span) {
|
|
|
1160
1110
|
}
|
|
1161
1111
|
const attrs = span.attributes;
|
|
1162
1112
|
const metadata = attrs["metadata"];
|
|
1163
|
-
if (typeof metadata !== "string" || !metadata.includes(`"${
|
|
1113
|
+
if (typeof metadata !== "string" || !metadata.includes(`"${_chunkIWSFMCHHcjs.BRIZZ}.`) && !metadata.includes(`"${TOOL_CALL_ID_METADATA_KEY}"`)) {
|
|
1164
1114
|
return;
|
|
1165
1115
|
}
|
|
1166
1116
|
const parsed = JSON.parse(metadata);
|
|
@@ -1169,7 +1119,7 @@ function restampLangChainSpan(span) {
|
|
|
1169
1119
|
}
|
|
1170
1120
|
const entries = parsed;
|
|
1171
1121
|
for (const [key, value] of Object.entries(entries)) {
|
|
1172
|
-
if (key.startsWith(`${
|
|
1122
|
+
if (key.startsWith(`${_chunkIWSFMCHHcjs.BRIZZ}.`) && value !== null && value !== void 0) {
|
|
1173
1123
|
attrs[key] = String(value);
|
|
1174
1124
|
}
|
|
1175
1125
|
}
|
|
@@ -1178,7 +1128,7 @@ function restampLangChainSpan(span) {
|
|
|
1178
1128
|
attrs[TOOL_ID] = toolCallId;
|
|
1179
1129
|
}
|
|
1180
1130
|
} catch (error) {
|
|
1181
|
-
|
|
1131
|
+
_chunkC5OT6GAQcjs.logger.debug("Skipped LangChain span re-stamp", { err: error });
|
|
1182
1132
|
}
|
|
1183
1133
|
}
|
|
1184
1134
|
|
|
@@ -1199,16 +1149,16 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1199
1149
|
try {
|
|
1200
1150
|
const inst = _chunkDC2MFO65cjs.bindToBrizz.call(void 0,
|
|
1201
1151
|
new InstrumentationClass({
|
|
1202
|
-
exceptionLogger: exceptionLogger2 || ((error) =>
|
|
1152
|
+
exceptionLogger: exceptionLogger2 || ((error) => _chunkC5OT6GAQcjs.logger.error(`Exception in instrumentation: ${String(error)}`))
|
|
1203
1153
|
})
|
|
1204
1154
|
);
|
|
1205
1155
|
if (manualModule) {
|
|
1206
1156
|
inst.manuallyInstrument(manualModule);
|
|
1207
|
-
|
|
1157
|
+
_chunkC5OT6GAQcjs.logger.debug(`Manual instrumentation enabled for ${name}`);
|
|
1208
1158
|
}
|
|
1209
1159
|
return inst;
|
|
1210
1160
|
} catch (error) {
|
|
1211
|
-
|
|
1161
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to load ${name} instrumentation: ${String(error)}`);
|
|
1212
1162
|
return null;
|
|
1213
1163
|
}
|
|
1214
1164
|
}
|
|
@@ -1222,9 +1172,9 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1222
1172
|
const openAIInst = new BrizzOpenAIInstrumentation();
|
|
1223
1173
|
openAIInst.manuallyInstrument(this.manualModules.openAI);
|
|
1224
1174
|
instrumentations.push(openAIInst);
|
|
1225
|
-
|
|
1175
|
+
_chunkC5OT6GAQcjs.logger.debug("Manual instrumentation enabled for OpenAI");
|
|
1226
1176
|
} catch (error) {
|
|
1227
|
-
|
|
1177
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to load OpenAI instrumentation: ${String(error)}`);
|
|
1228
1178
|
}
|
|
1229
1179
|
}
|
|
1230
1180
|
const instrumentationConfigs = [
|
|
@@ -1263,9 +1213,9 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1263
1213
|
const lcInst = new LangChainInstrumentation({ tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider });
|
|
1264
1214
|
lcInst.manuallyInstrument(callbackManagerModule);
|
|
1265
1215
|
patchCallbackManagerModule(callbackManagerModule);
|
|
1266
|
-
|
|
1216
|
+
_chunkC5OT6GAQcjs.logger.debug("Manual instrumentation enabled for LangChain");
|
|
1267
1217
|
} catch (error) {
|
|
1268
|
-
|
|
1218
|
+
_chunkC5OT6GAQcjs.logger.error(
|
|
1269
1219
|
`Failed to load LangChain instrumentation. Ensure @langchain/core is installed: ${String(error)}`
|
|
1270
1220
|
);
|
|
1271
1221
|
}
|
|
@@ -1274,17 +1224,17 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1274
1224
|
if (_optionalChain([this, 'access', _60 => _60.manualModules, 'optionalAccess', _61 => _61.langgraph])) {
|
|
1275
1225
|
try {
|
|
1276
1226
|
new LangGraphInstrumentation().manuallyInstrument(this.manualModules.langgraph);
|
|
1277
|
-
|
|
1227
|
+
_chunkC5OT6GAQcjs.logger.debug("Manual instrumentation enabled for LangGraph");
|
|
1278
1228
|
} catch (error) {
|
|
1279
|
-
|
|
1229
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to apply LangGraph instrumentation: ${String(error)}`);
|
|
1280
1230
|
}
|
|
1281
1231
|
}
|
|
1282
1232
|
if (_optionalChain([this, 'access', _62 => _62.manualModules, 'optionalAccess', _63 => _63.typesafe])) {
|
|
1283
1233
|
try {
|
|
1284
1234
|
new TypeSafeInstrumentation().manuallyInstrument(this.manualModules.typesafe);
|
|
1285
|
-
|
|
1235
|
+
_chunkC5OT6GAQcjs.logger.debug("Manual instrumentation enabled for TypeSafe");
|
|
1286
1236
|
} catch (error) {
|
|
1287
|
-
|
|
1237
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to apply TypeSafe instrumentation: ${String(error)}`);
|
|
1288
1238
|
}
|
|
1289
1239
|
}
|
|
1290
1240
|
if (_optionalChain([this, 'access', _64 => _64.manualModules, 'optionalAccess', _65 => _65.google_vertexai])) {
|
|
@@ -1294,9 +1244,9 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1294
1244
|
const { VertexAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("@traceloop/instrumentation-vertexai")));
|
|
1295
1245
|
const vertexInst = _chunkDC2MFO65cjs.bindToBrizz.call(void 0, new VertexAIInstrumentation({ exceptionLogger: exceptionLogger2 }));
|
|
1296
1246
|
vertexInst.manuallyInstrument(vertexModule);
|
|
1297
|
-
|
|
1247
|
+
_chunkC5OT6GAQcjs.logger.debug("Manual instrumentation enabled for Vertex AI");
|
|
1298
1248
|
} catch (error) {
|
|
1299
|
-
|
|
1249
|
+
_chunkC5OT6GAQcjs.logger.error(
|
|
1300
1250
|
`Failed to load Vertex AI instrumentation. Ensure @traceloop/instrumentation-vertexai is installed: ${String(error)}`
|
|
1301
1251
|
);
|
|
1302
1252
|
}
|
|
@@ -1306,12 +1256,12 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1306
1256
|
const genaiModule = this.manualModules.google_genai;
|
|
1307
1257
|
void (async () => {
|
|
1308
1258
|
try {
|
|
1309
|
-
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-
|
|
1259
|
+
const { GoogleGenAIInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./google-genai-6S5E7GZ4.cjs")));
|
|
1310
1260
|
const genaiInst = new GoogleGenAIInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
1311
1261
|
genaiInst.manuallyInstrument(genaiModule);
|
|
1312
|
-
|
|
1262
|
+
_chunkC5OT6GAQcjs.logger.debug("Manual instrumentation enabled for Google GenAI");
|
|
1313
1263
|
} catch (error) {
|
|
1314
|
-
|
|
1264
|
+
_chunkC5OT6GAQcjs.logger.error(
|
|
1315
1265
|
`Failed to apply Google GenAI instrumentation. Ensure @traceloop/instrumentation-google-generativeai is installed; on a read-only ESM module namespace use instrumentGoogleGenAI from @brizz/sdk/google-genai instead: ${String(error)}`
|
|
1316
1266
|
);
|
|
1317
1267
|
}
|
|
@@ -1321,12 +1271,12 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1321
1271
|
const mcpModules = this.manualModules.mcp;
|
|
1322
1272
|
void (async () => {
|
|
1323
1273
|
try {
|
|
1324
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
1274
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-6LNVYVJQ.cjs")));
|
|
1325
1275
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
1326
1276
|
instrumentation.manuallyInstrument(mcpModules);
|
|
1327
|
-
|
|
1277
|
+
_chunkC5OT6GAQcjs.logger.debug("Manual instrumentation enabled for MCP");
|
|
1328
1278
|
} catch (error) {
|
|
1329
|
-
|
|
1279
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to apply MCP instrumentation: ${String(error)}`);
|
|
1330
1280
|
}
|
|
1331
1281
|
})();
|
|
1332
1282
|
}
|
|
@@ -1336,7 +1286,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1336
1286
|
*/
|
|
1337
1287
|
setManualModules(modules) {
|
|
1338
1288
|
this.manualModules = modules;
|
|
1339
|
-
|
|
1289
|
+
_chunkC5OT6GAQcjs.logger.info("Manual instrumentation modules configured for Next.js/Webpack compatibility");
|
|
1340
1290
|
}
|
|
1341
1291
|
/**
|
|
1342
1292
|
* Get manual instrumentations only.
|
|
@@ -1344,21 +1294,199 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
1344
1294
|
*/
|
|
1345
1295
|
getManualInstrumentations() {
|
|
1346
1296
|
if (!this.manualModules || Object.keys(this.manualModules).length === 0) {
|
|
1347
|
-
|
|
1297
|
+
_chunkC5OT6GAQcjs.logger.debug("No manual instrumentation modules configured");
|
|
1348
1298
|
return [];
|
|
1349
1299
|
}
|
|
1350
1300
|
const instrumentations = [];
|
|
1351
1301
|
const exceptionLogger2 = (error) => {
|
|
1352
|
-
|
|
1302
|
+
_chunkC5OT6GAQcjs.logger.error(`Exception in manual instrumentation: ${String(error)}`);
|
|
1353
1303
|
};
|
|
1354
1304
|
this.loadManualInstrumentations(instrumentations, exceptionLogger2);
|
|
1355
|
-
|
|
1305
|
+
_chunkC5OT6GAQcjs.logger.info(`Loaded ${instrumentations.length} manual instrumentations`);
|
|
1356
1306
|
return instrumentations;
|
|
1357
1307
|
}
|
|
1358
1308
|
}, _class);
|
|
1359
1309
|
|
|
1310
|
+
// src/internal/instrumentation/vercel-ai/interrupt.ts
|
|
1311
|
+
|
|
1312
|
+
var INNER_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
1313
|
+
"ai.generateText.doGenerate",
|
|
1314
|
+
"ai.streamText.doStream"
|
|
1315
|
+
]);
|
|
1316
|
+
function isLegacyModelCallSpan(span) {
|
|
1317
|
+
if (INNER_OPERATION_IDS.has(span.name)) {
|
|
1318
|
+
return true;
|
|
1319
|
+
}
|
|
1320
|
+
const opId = span.attributes["ai.operationId"];
|
|
1321
|
+
return typeof opId === "string" && INNER_OPERATION_IDS.has(opId);
|
|
1322
|
+
}
|
|
1323
|
+
function isGenAIModelCallSpan(span) {
|
|
1324
|
+
return _optionalChain([span, 'access', _70 => _70.instrumentationScope, 'optionalAccess', _71 => _71.name]) === _chunkIWSFMCHHcjs.AI_SDK_OTEL_SCOPE && span.attributes["gen_ai.operation.name"] === "chat";
|
|
1325
|
+
}
|
|
1326
|
+
var MAX_PENDING_ENTRIES = 1024;
|
|
1327
|
+
var pendingByParentSpanId = /* @__PURE__ */ new Map();
|
|
1328
|
+
var needsApprovalToolNames = /* @__PURE__ */ new Set();
|
|
1329
|
+
var versionState = { sawActiveSpan: false };
|
|
1330
|
+
function setPending(parentSpanId, value) {
|
|
1331
|
+
pendingByParentSpanId.set(parentSpanId, value);
|
|
1332
|
+
evictOldest(pendingByParentSpanId);
|
|
1333
|
+
}
|
|
1334
|
+
function extractInterruptTools(tools) {
|
|
1335
|
+
if (!tools || typeof tools !== "object") {
|
|
1336
|
+
return [];
|
|
1337
|
+
}
|
|
1338
|
+
return Object.entries(tools).filter(
|
|
1339
|
+
([, t]) => !!t && typeof t === "object" && t.needsApproval
|
|
1340
|
+
).map(([name]) => name);
|
|
1341
|
+
}
|
|
1342
|
+
function parsePromptToolNames(raw) {
|
|
1343
|
+
if (!Array.isArray(raw)) {
|
|
1344
|
+
return null;
|
|
1345
|
+
}
|
|
1346
|
+
const names = [];
|
|
1347
|
+
for (const element of raw) {
|
|
1348
|
+
if (typeof element !== "string") {
|
|
1349
|
+
continue;
|
|
1350
|
+
}
|
|
1351
|
+
try {
|
|
1352
|
+
const parsed = JSON.parse(element);
|
|
1353
|
+
if (parsed && typeof parsed.name === "string") {
|
|
1354
|
+
names.push(parsed.name);
|
|
1355
|
+
}
|
|
1356
|
+
} catch (e4) {
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
return names.length > 0 ? names : null;
|
|
1360
|
+
}
|
|
1361
|
+
var verdictsByToolCallId = /* @__PURE__ */ new Map();
|
|
1362
|
+
function recordVerdicts(messages) {
|
|
1363
|
+
if (!Array.isArray(messages)) {
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
const parts = messages.flatMap((message) => {
|
|
1367
|
+
const content = _optionalChain([message, 'optionalAccess', _72 => _72.content]);
|
|
1368
|
+
return Array.isArray(content) ? content : [];
|
|
1369
|
+
});
|
|
1370
|
+
const askedOf = /* @__PURE__ */ new Map();
|
|
1371
|
+
for (const part of parts) {
|
|
1372
|
+
if (_optionalChain([part, 'optionalAccess', _73 => _73.type]) === "tool-approval-request" && part.isAutomatic !== true) {
|
|
1373
|
+
askedOf.set(part.approvalId, part.toolCallId);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
for (const part of parts) {
|
|
1377
|
+
const toolCallId = _optionalChain([part, 'optionalAccess', _74 => _74.type]) === "tool-approval-response" && askedOf.get(part.approvalId);
|
|
1378
|
+
if (typeof toolCallId === "string" && typeof part.approved === "boolean") {
|
|
1379
|
+
verdictsByToolCallId.set(toolCallId, part.approved);
|
|
1380
|
+
evictOldest(verdictsByToolCallId);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
function verdictsForRequest(inputMessages) {
|
|
1385
|
+
if (typeof inputMessages !== "string" || verdictsByToolCallId.size === 0) {
|
|
1386
|
+
return void 0;
|
|
1387
|
+
}
|
|
1388
|
+
let messages;
|
|
1389
|
+
try {
|
|
1390
|
+
messages = JSON.parse(inputMessages);
|
|
1391
|
+
} catch (e5) {
|
|
1392
|
+
return void 0;
|
|
1393
|
+
}
|
|
1394
|
+
if (!Array.isArray(messages)) {
|
|
1395
|
+
return void 0;
|
|
1396
|
+
}
|
|
1397
|
+
const verdicts = {};
|
|
1398
|
+
for (const message of [...messages].reverse()) {
|
|
1399
|
+
const { role, parts } = _nullishCoalesce(message, () => ( {}));
|
|
1400
|
+
if (role === "assistant" || role === "system") {
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
for (const part of Array.isArray(parts) ? parts : []) {
|
|
1404
|
+
const approved = _optionalChain([part, 'optionalAccess', _75 => _75.type]) === "tool_call_response" && typeof part.id === "string" ? verdictsByToolCallId.get(part.id) : void 0;
|
|
1405
|
+
if (approved !== void 0) {
|
|
1406
|
+
verdicts[part.id] = approved;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
return Object.keys(verdicts).length > 0 ? JSON.stringify(verdicts) : void 0;
|
|
1411
|
+
}
|
|
1412
|
+
function evictOldest(map) {
|
|
1413
|
+
while (map.size > MAX_PENDING_ENTRIES) {
|
|
1414
|
+
const oldest = map.keys().next().value;
|
|
1415
|
+
if (oldest === void 0) {
|
|
1416
|
+
break;
|
|
1417
|
+
}
|
|
1418
|
+
map.delete(oldest);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
function createInterruptIntegration() {
|
|
1422
|
+
const onStart = (event) => {
|
|
1423
|
+
recordVerdicts(event.messages);
|
|
1424
|
+
for (const name of extractInterruptTools(event.tools)) {
|
|
1425
|
+
needsApprovalToolNames.add(name);
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
const onStepStart = (event) => {
|
|
1429
|
+
const span = _api.trace.getActiveSpan();
|
|
1430
|
+
if (span) {
|
|
1431
|
+
versionState.sawActiveSpan = true;
|
|
1432
|
+
}
|
|
1433
|
+
const names = extractInterruptTools(event.tools);
|
|
1434
|
+
if (names.length === 0) {
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
for (const name of names) {
|
|
1438
|
+
needsApprovalToolNames.add(name);
|
|
1439
|
+
}
|
|
1440
|
+
if (!span) {
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
const value = JSON.stringify(names);
|
|
1444
|
+
span.setAttribute(_chunkIWSFMCHHcjs.INTERRUPT_TOOLS, value);
|
|
1445
|
+
setPending(span.spanContext().spanId, value);
|
|
1446
|
+
};
|
|
1447
|
+
return {
|
|
1448
|
+
onStart,
|
|
1449
|
+
onStepStart
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
var InterruptPropagator = class {
|
|
1453
|
+
onStart(span, _parentContext) {
|
|
1454
|
+
if (isGenAIModelCallSpan(span)) {
|
|
1455
|
+
const verdicts = verdictsForRequest(span.attributes["gen_ai.input.messages"]);
|
|
1456
|
+
if (verdicts) {
|
|
1457
|
+
span.setAttribute(_chunkIWSFMCHHcjs.APPROVALS, verdicts);
|
|
1458
|
+
}
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
if (!isLegacyModelCallSpan(span)) {
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
const parentSpanId = _optionalChain([span, 'access', _76 => _76.parentSpanContext, 'optionalAccess', _77 => _77.spanId]);
|
|
1465
|
+
const stashed = parentSpanId && pendingByParentSpanId.get(parentSpanId);
|
|
1466
|
+
if (stashed) {
|
|
1467
|
+
span.setAttribute(_chunkIWSFMCHHcjs.INTERRUPT_TOOLS, stashed);
|
|
1468
|
+
pendingByParentSpanId.delete(parentSpanId);
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
if (versionState.sawActiveSpan || needsApprovalToolNames.size === 0) {
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
const scoped = parsePromptToolNames(span.attributes["ai.prompt.tools"]);
|
|
1475
|
+
const names = scoped === null ? [...needsApprovalToolNames] : scoped.filter((n) => needsApprovalToolNames.has(n));
|
|
1476
|
+
if (names.length > 0) {
|
|
1477
|
+
span.setAttribute(_chunkIWSFMCHHcjs.INTERRUPT_TOOLS, JSON.stringify(names));
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
onEnd() {
|
|
1481
|
+
}
|
|
1482
|
+
async shutdown() {
|
|
1483
|
+
}
|
|
1484
|
+
async forceFlush() {
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
|
|
1360
1488
|
// src/internal/log/logging.ts
|
|
1361
|
-
|
|
1489
|
+
|
|
1362
1490
|
var _exporterlogsotlphttp = require('@opentelemetry/exporter-logs-otlp-http');
|
|
1363
1491
|
|
|
1364
1492
|
var _sdklogs = require('@opentelemetry/sdk-logs');
|
|
@@ -1619,7 +1747,7 @@ function compilePatternEntries(patternEntries) {
|
|
|
1619
1747
|
try {
|
|
1620
1748
|
patternGroups.push(getGroupedPattern(patternEntry));
|
|
1621
1749
|
} catch (error) {
|
|
1622
|
-
|
|
1750
|
+
_chunkC5OT6GAQcjs.logger.warn(`Invalid pattern '${patternEntry.name}': ${patternEntry.pattern}`, error);
|
|
1623
1751
|
continue;
|
|
1624
1752
|
}
|
|
1625
1753
|
}
|
|
@@ -1629,7 +1757,7 @@ function compilePatternEntries(patternEntries) {
|
|
|
1629
1757
|
try {
|
|
1630
1758
|
return new RegExp(patternGroups.join("|"));
|
|
1631
1759
|
} catch (error) {
|
|
1632
|
-
|
|
1760
|
+
_chunkC5OT6GAQcjs.logger.warn("Failed to compile pattern entries into regex", error);
|
|
1633
1761
|
return null;
|
|
1634
1762
|
}
|
|
1635
1763
|
}
|
|
@@ -1645,7 +1773,7 @@ function getCompiledPatternsForRule(rule) {
|
|
|
1645
1773
|
}
|
|
1646
1774
|
function getCompiledAttributeNamePattern(rule) {
|
|
1647
1775
|
if (!rule.attributePattern) {
|
|
1648
|
-
|
|
1776
|
+
_chunkC5OT6GAQcjs.logger.debug("No attribute pattern provided, using default .*");
|
|
1649
1777
|
return /.*/;
|
|
1650
1778
|
}
|
|
1651
1779
|
let compiledPatternString = rule.attributePattern;
|
|
@@ -1656,12 +1784,12 @@ function getCompiledAttributeNamePattern(rule) {
|
|
|
1656
1784
|
}
|
|
1657
1785
|
function shouldContinueExecution(startTime, iterations, timeoutMs) {
|
|
1658
1786
|
if (Date.now() - startTime > timeoutMs) {
|
|
1659
|
-
|
|
1787
|
+
_chunkC5OT6GAQcjs.logger.warn("Regex execution timed out - potential ReDoS pattern detected");
|
|
1660
1788
|
return false;
|
|
1661
1789
|
}
|
|
1662
1790
|
const maxIterations = 1e3;
|
|
1663
1791
|
if (iterations > maxIterations) {
|
|
1664
|
-
|
|
1792
|
+
_chunkC5OT6GAQcjs.logger.warn("Regex execution exceeded maximum iterations - potential ReDoS pattern detected");
|
|
1665
1793
|
return false;
|
|
1666
1794
|
}
|
|
1667
1795
|
return true;
|
|
@@ -1702,7 +1830,7 @@ function maskStringByPattern(value, pattern, mode = "full") {
|
|
|
1702
1830
|
});
|
|
1703
1831
|
}
|
|
1704
1832
|
} catch (error) {
|
|
1705
|
-
|
|
1833
|
+
_chunkC5OT6GAQcjs.logger.warn("Regex execution failed, skipping masking", error);
|
|
1706
1834
|
return value;
|
|
1707
1835
|
}
|
|
1708
1836
|
for (const matchInfo of matches.toReversed()) {
|
|
@@ -1721,7 +1849,7 @@ function maskStringByPattern(value, pattern, mode = "full") {
|
|
|
1721
1849
|
}
|
|
1722
1850
|
}
|
|
1723
1851
|
}
|
|
1724
|
-
|
|
1852
|
+
_chunkC5OT6GAQcjs.logger.info(`Masking detected: pattern '${patternName}' found match in value`);
|
|
1725
1853
|
const masked = mode === "partial" ? matchInfo.text.at(0) + "*****" : "*****";
|
|
1726
1854
|
value = value.slice(0, matchInfo.start) + masked + value.slice(matchInfo.end);
|
|
1727
1855
|
}
|
|
@@ -1730,7 +1858,7 @@ function maskStringByPattern(value, pattern, mode = "full") {
|
|
|
1730
1858
|
function maskStringByPatternBasedRule(value, rule) {
|
|
1731
1859
|
const patternEntries = convertPatternsToPatternEntries(rule.patterns);
|
|
1732
1860
|
if (patternEntries.length === 0) {
|
|
1733
|
-
|
|
1861
|
+
_chunkC5OT6GAQcjs.logger.warn("No patterns provided for masking rule, returning original value");
|
|
1734
1862
|
return value;
|
|
1735
1863
|
}
|
|
1736
1864
|
const mode = rule.mode;
|
|
@@ -1776,7 +1904,7 @@ function maskAttributes(attributes, rules, outputOriginalValue = false) {
|
|
|
1776
1904
|
const value = maskedAttributes[attribute];
|
|
1777
1905
|
if (value !== null && value !== void 0) {
|
|
1778
1906
|
if (outputOriginalValue) {
|
|
1779
|
-
|
|
1907
|
+
_chunkC5OT6GAQcjs.logger.debug(`Masking attribute '${attribute}' with original value`, { value });
|
|
1780
1908
|
}
|
|
1781
1909
|
maskedAttributes[attribute] = maskValue(value, rule);
|
|
1782
1910
|
}
|
|
@@ -1800,14 +1928,14 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
|
|
|
1800
1928
|
this.config = config;
|
|
1801
1929
|
}
|
|
1802
1930
|
onEmit(logRecord) {
|
|
1803
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
1931
|
+
const maskingConfig = _optionalChain([this, 'access', _78 => _78.config, 'access', _79 => _79.masking, 'optionalAccess', _80 => _80.eventMasking]);
|
|
1804
1932
|
if (maskingConfig) {
|
|
1805
1933
|
maskLog(logRecord, maskingConfig);
|
|
1806
1934
|
}
|
|
1807
|
-
const associationProperties = _api.context.active().getValue(
|
|
1935
|
+
const associationProperties = _api.context.active().getValue(_chunkIWSFMCHHcjs.PROPERTIES_CONTEXT_KEY);
|
|
1808
1936
|
if (associationProperties) {
|
|
1809
1937
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
1810
|
-
logRecord.setAttribute(`${
|
|
1938
|
+
logRecord.setAttribute(`${_chunkIWSFMCHHcjs.BRIZZ}.${key}`, value);
|
|
1811
1939
|
}
|
|
1812
1940
|
}
|
|
1813
1941
|
super.onEmit(logRecord);
|
|
@@ -1820,14 +1948,14 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
|
|
|
1820
1948
|
this.config = config;
|
|
1821
1949
|
}
|
|
1822
1950
|
onEmit(logRecord) {
|
|
1823
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
1951
|
+
const maskingConfig = _optionalChain([this, 'access', _81 => _81.config, 'access', _82 => _82.masking, 'optionalAccess', _83 => _83.eventMasking]);
|
|
1824
1952
|
if (maskingConfig) {
|
|
1825
1953
|
maskLog(logRecord, maskingConfig);
|
|
1826
1954
|
}
|
|
1827
|
-
const associationProperties = _api.context.active().getValue(
|
|
1955
|
+
const associationProperties = _api.context.active().getValue(_chunkIWSFMCHHcjs.PROPERTIES_CONTEXT_KEY);
|
|
1828
1956
|
if (associationProperties) {
|
|
1829
1957
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
1830
|
-
logRecord.setAttribute(`${
|
|
1958
|
+
logRecord.setAttribute(`${_chunkIWSFMCHHcjs.BRIZZ}.${key}`, value);
|
|
1831
1959
|
}
|
|
1832
1960
|
}
|
|
1833
1961
|
super.onEmit(logRecord);
|
|
@@ -1854,7 +1982,7 @@ function maskLog(logRecord, config) {
|
|
|
1854
1982
|
newAttributes[key] = value;
|
|
1855
1983
|
}
|
|
1856
1984
|
for (const [key, value] of Object.entries(logRecord.attributes)) {
|
|
1857
|
-
if (key.startsWith(
|
|
1985
|
+
if (key.startsWith(_chunkIWSFMCHHcjs.INTERNAL_EVENT_PREFIX)) {
|
|
1858
1986
|
newAttributes[key] = value;
|
|
1859
1987
|
}
|
|
1860
1988
|
}
|
|
@@ -1870,7 +1998,7 @@ function maskLog(logRecord, config) {
|
|
|
1870
1998
|
}
|
|
1871
1999
|
return logRecord;
|
|
1872
2000
|
} catch (error) {
|
|
1873
|
-
|
|
2001
|
+
_chunkC5OT6GAQcjs.logger.error("Error masking log record:", error);
|
|
1874
2002
|
return logRecord;
|
|
1875
2003
|
}
|
|
1876
2004
|
}
|
|
@@ -1896,7 +2024,7 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
1896
2024
|
*/
|
|
1897
2025
|
createLogExporter(config, serviceName) {
|
|
1898
2026
|
if (config.customLogExporter) {
|
|
1899
|
-
|
|
2027
|
+
_chunkC5OT6GAQcjs.logger.debug("Using custom log exporter");
|
|
1900
2028
|
if (serviceName === config.appName) {
|
|
1901
2029
|
return config.customLogExporter;
|
|
1902
2030
|
}
|
|
@@ -1909,7 +2037,7 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
1909
2037
|
};
|
|
1910
2038
|
}
|
|
1911
2039
|
const logsUrl = config.baseUrl.replace(/\/$/, "") + "/v1/logs";
|
|
1912
|
-
|
|
2040
|
+
_chunkC5OT6GAQcjs.logger.debug("Initializing default OTLP log exporter", { url: logsUrl, serviceName });
|
|
1913
2041
|
const headers = serviceName === config.appName ? { ...config.headers } : { ...config.headers, [_chunkUNLNNKZ7cjs.SERVICE_NAME_HEADER]: serviceName };
|
|
1914
2042
|
return new (0, _exporterlogsotlphttp.OTLPLogExporter)({ url: logsUrl, headers });
|
|
1915
2043
|
}
|
|
@@ -1918,17 +2046,17 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
1918
2046
|
* exporter and masking-aware processor.
|
|
1919
2047
|
*/
|
|
1920
2048
|
createLoggerProvider(config, serviceName) {
|
|
1921
|
-
|
|
2049
|
+
_chunkC5OT6GAQcjs.logger.debug("Creating logger provider", {
|
|
1922
2050
|
serviceName,
|
|
1923
2051
|
disableBatch: config.disableBatch,
|
|
1924
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
2052
|
+
hasMasking: !!_optionalChain([config, 'access', _84 => _84.masking, 'optionalAccess', _85 => _85.eventMasking])
|
|
1925
2053
|
});
|
|
1926
2054
|
const exporter = this.createLogExporter(config, serviceName);
|
|
1927
2055
|
const processor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(exporter, config) : new BrizzBatchLogRecordProcessor(exporter, config);
|
|
1928
2056
|
const resourceAttributes = {
|
|
1929
2057
|
...config.resourceAttributes,
|
|
1930
2058
|
"service.name": serviceName,
|
|
1931
|
-
[BRIZZ_SDK_VERSION]:
|
|
2059
|
+
[BRIZZ_SDK_VERSION]: _chunkQXHGMS5Acjs.getSDKVersion.call(void 0, ),
|
|
1932
2060
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
1933
2061
|
};
|
|
1934
2062
|
if (config.environment) {
|
|
@@ -1947,7 +2075,7 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
1947
2075
|
* `callWithServiceName`, else the configured appName.
|
|
1948
2076
|
*/
|
|
1949
2077
|
activeLoggerProvider() {
|
|
1950
|
-
const serviceName =
|
|
2078
|
+
const serviceName = _chunkUF4GMVEYcjs.resolveServiceNameFromContext.call(void 0, );
|
|
1951
2079
|
if (!serviceName || !this.config || serviceName === this.config.appName) {
|
|
1952
2080
|
return this.loggerProvider;
|
|
1953
2081
|
}
|
|
@@ -1962,22 +2090,22 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
1962
2090
|
* Initialize the logging module with the provided configuration
|
|
1963
2091
|
*/
|
|
1964
2092
|
setup(config) {
|
|
1965
|
-
|
|
2093
|
+
_chunkC5OT6GAQcjs.logger.info("Setting up logging module");
|
|
1966
2094
|
this.config = config;
|
|
1967
2095
|
if (this.loggerProvider) {
|
|
1968
|
-
|
|
2096
|
+
_chunkC5OT6GAQcjs.logger.debug("Logger provider already initialized, skipping re-initialization");
|
|
1969
2097
|
} else {
|
|
1970
2098
|
this.loggerProvider = this.createLoggerProvider(config, config.appName);
|
|
1971
2099
|
}
|
|
1972
2100
|
_LoggingModule.instance = this;
|
|
1973
|
-
|
|
1974
|
-
|
|
2101
|
+
_chunkUF4GMVEYcjs.setEventSink.call(void 0, this);
|
|
2102
|
+
_chunkC5OT6GAQcjs.logger.info("Logging module setup completed");
|
|
1975
2103
|
}
|
|
1976
2104
|
/**
|
|
1977
2105
|
* Emit a custom event to the telemetry pipeline
|
|
1978
2106
|
*/
|
|
1979
|
-
emitEvent(name, attributes, body, severityNumber =
|
|
1980
|
-
|
|
2107
|
+
emitEvent(name, attributes, body, severityNumber = _api.SeverityNumber.INFO) {
|
|
2108
|
+
_chunkC5OT6GAQcjs.logger.debug("Attempting to emit event", {
|
|
1981
2109
|
name,
|
|
1982
2110
|
hasAttributes: !!attributes,
|
|
1983
2111
|
attributesCount: attributes ? Object.keys(attributes).length : 0,
|
|
@@ -1986,17 +2114,17 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
1986
2114
|
});
|
|
1987
2115
|
const provider = this.activeLoggerProvider();
|
|
1988
2116
|
if (!provider) {
|
|
1989
|
-
|
|
2117
|
+
_chunkC5OT6GAQcjs.logger.error("Cannot emit event: Logger provider not initialized");
|
|
1990
2118
|
throw new Error("Logging module not initialized");
|
|
1991
2119
|
}
|
|
1992
2120
|
const logAttributes = { "event.name": name };
|
|
1993
2121
|
if (attributes) {
|
|
1994
2122
|
Object.assign(logAttributes, attributes);
|
|
1995
|
-
|
|
2123
|
+
_chunkC5OT6GAQcjs.logger.debug("Combined log attributes", { attributes: Object.keys(logAttributes) });
|
|
1996
2124
|
}
|
|
1997
|
-
|
|
2125
|
+
_chunkC5OT6GAQcjs.logger.debug("Getting logger instance for brizz_events");
|
|
1998
2126
|
const eventLogger = provider.getLogger("brizz.events");
|
|
1999
|
-
|
|
2127
|
+
_chunkC5OT6GAQcjs.logger.debug("Emitting log record with eventName", { eventName: name });
|
|
2000
2128
|
try {
|
|
2001
2129
|
eventLogger.emit({
|
|
2002
2130
|
eventName: name,
|
|
@@ -2004,10 +2132,10 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
2004
2132
|
severityNumber,
|
|
2005
2133
|
body
|
|
2006
2134
|
});
|
|
2007
|
-
|
|
2135
|
+
_chunkC5OT6GAQcjs.logger.debug("Event successfully emitted", { eventName: name });
|
|
2008
2136
|
} catch (error) {
|
|
2009
|
-
|
|
2010
|
-
|
|
2137
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to emit event '${name}'`, { error, eventName: name });
|
|
2138
|
+
_chunkC5OT6GAQcjs.logger.error("Log record that failed", {
|
|
2011
2139
|
eventName: name,
|
|
2012
2140
|
hasAttributes: logAttributes,
|
|
2013
2141
|
severityNumber,
|
|
@@ -2030,14 +2158,14 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
2030
2158
|
}
|
|
2031
2159
|
async forceFlush() {
|
|
2032
2160
|
await Promise.all(
|
|
2033
|
-
[...this.scopedProviders.values(), this.loggerProvider].map(async (p) => _optionalChain([p, 'optionalAccess',
|
|
2161
|
+
[...this.scopedProviders.values(), this.loggerProvider].map(async (p) => _optionalChain([p, 'optionalAccess', _86 => _86.forceFlush, 'call', _87 => _87()]))
|
|
2034
2162
|
);
|
|
2035
2163
|
}
|
|
2036
2164
|
/**
|
|
2037
2165
|
* Shutdown the logging module
|
|
2038
2166
|
*/
|
|
2039
2167
|
async shutdown() {
|
|
2040
|
-
|
|
2168
|
+
_chunkC5OT6GAQcjs.logger.debug("Shutting down logging module");
|
|
2041
2169
|
await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
|
|
2042
2170
|
this.scopedProviders.clear();
|
|
2043
2171
|
if (this.loggerProvider) {
|
|
@@ -2048,8 +2176,8 @@ var LoggingModule = (_class2 = class _LoggingModule {constructor() { _class2.pro
|
|
|
2048
2176
|
if (_LoggingModule.instance === this) {
|
|
2049
2177
|
_LoggingModule.instance = null;
|
|
2050
2178
|
}
|
|
2051
|
-
|
|
2052
|
-
|
|
2179
|
+
_chunkUF4GMVEYcjs.clearEventSink.call(void 0, this);
|
|
2180
|
+
_chunkC5OT6GAQcjs.logger.debug("Logging module shutdown completed");
|
|
2053
2181
|
}
|
|
2054
2182
|
}, _class2.__initStatic(), _class2);
|
|
2055
2183
|
|
|
@@ -2071,32 +2199,32 @@ var MetricsModule = (_class3 = class _MetricsModule {constructor() { _class3.pro
|
|
|
2071
2199
|
*/
|
|
2072
2200
|
initMetricsExporter(config) {
|
|
2073
2201
|
if (this.metricsExporter) {
|
|
2074
|
-
|
|
2202
|
+
_chunkC5OT6GAQcjs.logger.debug("Metrics exporter already initialized, skipping re-initialization");
|
|
2075
2203
|
return;
|
|
2076
2204
|
}
|
|
2077
2205
|
const metricsUrl = config.baseUrl.replace(/\/$/, "") + "/v1/metrics";
|
|
2078
|
-
|
|
2206
|
+
_chunkC5OT6GAQcjs.logger.debug("Initializing metrics exporter", { url: metricsUrl });
|
|
2079
2207
|
this.metricsExporter = new (0, _exportermetricsotlphttp.OTLPMetricExporter)({
|
|
2080
2208
|
url: metricsUrl,
|
|
2081
2209
|
headers: config.headers
|
|
2082
2210
|
});
|
|
2083
|
-
|
|
2211
|
+
_chunkC5OT6GAQcjs.logger.debug("Metrics exporter initialized successfully");
|
|
2084
2212
|
}
|
|
2085
2213
|
/**
|
|
2086
2214
|
* Initialize the metrics reader
|
|
2087
2215
|
*/
|
|
2088
2216
|
initMetricsReader(config) {
|
|
2089
2217
|
if (this.metricsReader) {
|
|
2090
|
-
|
|
2218
|
+
_chunkC5OT6GAQcjs.logger.debug("Metrics reader already initialized, skipping re-initialization");
|
|
2091
2219
|
return;
|
|
2092
2220
|
}
|
|
2093
2221
|
if (config.customMetricReader) {
|
|
2094
|
-
|
|
2222
|
+
_chunkC5OT6GAQcjs.logger.debug("Using custom metric reader");
|
|
2095
2223
|
this.metricsReader = config.customMetricReader;
|
|
2096
|
-
|
|
2224
|
+
_chunkC5OT6GAQcjs.logger.debug("Custom metric reader initialized successfully");
|
|
2097
2225
|
return;
|
|
2098
2226
|
}
|
|
2099
|
-
|
|
2227
|
+
_chunkC5OT6GAQcjs.logger.debug(
|
|
2100
2228
|
"Using default metrics flow - creating OTLP exporter and PeriodicExportingMetricReader"
|
|
2101
2229
|
);
|
|
2102
2230
|
this.initMetricsExporter(config);
|
|
@@ -2106,16 +2234,16 @@ var MetricsModule = (_class3 = class _MetricsModule {constructor() { _class3.pro
|
|
|
2106
2234
|
this.metricsReader = new (0, _sdkmetrics.PeriodicExportingMetricReader)({
|
|
2107
2235
|
exporter: this.metricsExporter
|
|
2108
2236
|
});
|
|
2109
|
-
|
|
2237
|
+
_chunkC5OT6GAQcjs.logger.debug("Default metrics reader initialized successfully");
|
|
2110
2238
|
}
|
|
2111
2239
|
/**
|
|
2112
2240
|
* Initialize the metrics module with the provided configuration
|
|
2113
2241
|
*/
|
|
2114
2242
|
setup(config) {
|
|
2115
|
-
|
|
2243
|
+
_chunkC5OT6GAQcjs.logger.info("Setting up metrics module");
|
|
2116
2244
|
this.initMetricsReader(config);
|
|
2117
2245
|
_MetricsModule.instance = this;
|
|
2118
|
-
|
|
2246
|
+
_chunkC5OT6GAQcjs.logger.info("Metrics module setup completed");
|
|
2119
2247
|
}
|
|
2120
2248
|
/**
|
|
2121
2249
|
* Get the metrics exporter
|
|
@@ -2136,19 +2264,19 @@ var MetricsModule = (_class3 = class _MetricsModule {constructor() { _class3.pro
|
|
|
2136
2264
|
return this.metricsReader;
|
|
2137
2265
|
}
|
|
2138
2266
|
async forceFlush() {
|
|
2139
|
-
await _optionalChain([this, 'access',
|
|
2267
|
+
await _optionalChain([this, 'access', _88 => _88.metricsReader, 'optionalAccess', _89 => _89.forceFlush, 'call', _90 => _90()]);
|
|
2140
2268
|
}
|
|
2141
2269
|
/**
|
|
2142
2270
|
* Shutdown the metrics module
|
|
2143
2271
|
*/
|
|
2144
2272
|
shutdown() {
|
|
2145
|
-
|
|
2273
|
+
_chunkC5OT6GAQcjs.logger.debug("Shutting down metrics module");
|
|
2146
2274
|
this.metricsReader = null;
|
|
2147
2275
|
this.metricsExporter = null;
|
|
2148
2276
|
if (_MetricsModule.instance === this) {
|
|
2149
2277
|
_MetricsModule.instance = null;
|
|
2150
2278
|
}
|
|
2151
|
-
|
|
2279
|
+
_chunkC5OT6GAQcjs.logger.debug("Metrics module shutdown completed");
|
|
2152
2280
|
}
|
|
2153
2281
|
}, _class3.__initStatic2(), _class3);
|
|
2154
2282
|
function getMetricsExporter() {
|
|
@@ -2158,6 +2286,165 @@ function getMetricsReader() {
|
|
|
2158
2286
|
return MetricsModule.getInstance().getMetricsReader();
|
|
2159
2287
|
}
|
|
2160
2288
|
|
|
2289
|
+
// src/internal/instrumentation/vercel-ai/model-call-end.ts
|
|
2290
|
+
var NO_USAGE = {
|
|
2291
|
+
inputTokens: void 0,
|
|
2292
|
+
inputTokenDetails: {
|
|
2293
|
+
noCacheTokens: void 0,
|
|
2294
|
+
cacheReadTokens: void 0,
|
|
2295
|
+
cacheWriteTokens: void 0
|
|
2296
|
+
},
|
|
2297
|
+
outputTokens: void 0,
|
|
2298
|
+
outputTokenDetails: { textTokens: void 0, reasoningTokens: void 0 },
|
|
2299
|
+
totalTokens: void 0
|
|
2300
|
+
};
|
|
2301
|
+
function endUnreportedModelCalls(collector) {
|
|
2302
|
+
const hooks = collector;
|
|
2303
|
+
if (!hasModelCallHooks(hooks)) {
|
|
2304
|
+
_chunkC5OT6GAQcjs.logger.debug("@ai-sdk/otel lacks the model-call hooks; failed streamed calls stay untraced");
|
|
2305
|
+
return collector;
|
|
2306
|
+
}
|
|
2307
|
+
const { onStepEnd, onLanguageModelCallStart, onLanguageModelCallEnd } = hooks;
|
|
2308
|
+
hooks.onStepEnd = (event) => {
|
|
2309
|
+
if (!event.durableContext) {
|
|
2310
|
+
onLanguageModelCallEnd.call(hooks, modelCallEndOf(event));
|
|
2311
|
+
}
|
|
2312
|
+
return onStepEnd.call(hooks, event);
|
|
2313
|
+
};
|
|
2314
|
+
hooks.onLanguageModelCallStart = (event) => {
|
|
2315
|
+
if (!event.durableContext) {
|
|
2316
|
+
onLanguageModelCallEnd.call(hooks, failedAttemptBefore(event));
|
|
2317
|
+
}
|
|
2318
|
+
return onLanguageModelCallStart.call(hooks, event);
|
|
2319
|
+
};
|
|
2320
|
+
return collector;
|
|
2321
|
+
}
|
|
2322
|
+
function hasModelCallHooks(hooks) {
|
|
2323
|
+
return typeof hooks.onStepEnd === "function" && typeof hooks.onLanguageModelCallStart === "function" && typeof hooks.onLanguageModelCallEnd === "function";
|
|
2324
|
+
}
|
|
2325
|
+
function modelCallEndOf(step) {
|
|
2326
|
+
return {
|
|
2327
|
+
callId: step.callId,
|
|
2328
|
+
provider: step.model.provider,
|
|
2329
|
+
modelId: step.response.modelId,
|
|
2330
|
+
finishReason: step.finishReason,
|
|
2331
|
+
usage: step.usage,
|
|
2332
|
+
content: step.content,
|
|
2333
|
+
responseId: step.response.id,
|
|
2334
|
+
providerMetadata: step.providerMetadata,
|
|
2335
|
+
request: { url: step.request.url },
|
|
2336
|
+
performance: { ...step.performance, timeToFirstOutputMs: void 0 },
|
|
2337
|
+
timestamp: step.timestamp
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2340
|
+
function failedAttemptBefore(retry) {
|
|
2341
|
+
return {
|
|
2342
|
+
callId: retry.callId,
|
|
2343
|
+
provider: retry.provider,
|
|
2344
|
+
modelId: retry.modelId,
|
|
2345
|
+
finishReason: "error",
|
|
2346
|
+
usage: NO_USAGE,
|
|
2347
|
+
content: [],
|
|
2348
|
+
responseId: "",
|
|
2349
|
+
performance: {
|
|
2350
|
+
responseTimeMs: 0,
|
|
2351
|
+
effectiveOutputTokensPerSecond: 0,
|
|
2352
|
+
outputTokensPerSecond: void 0,
|
|
2353
|
+
inputTokensPerSecond: void 0,
|
|
2354
|
+
effectiveTotalTokensPerSecond: 0,
|
|
2355
|
+
timeToFirstOutputMs: void 0
|
|
2356
|
+
},
|
|
2357
|
+
timestamp: retry.timestamp
|
|
2358
|
+
};
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
// src/internal/instrumentation/vercel-ai/index.ts
|
|
2362
|
+
var importInstalled = {
|
|
2363
|
+
ai: () => Promise.resolve().then(() => _interopRequireWildcard(require("ai"))).catch(() => void 0),
|
|
2364
|
+
otel: () => Promise.resolve().then(() => _interopRequireWildcard(require("@ai-sdk/otel"))).catch(() => void 0)
|
|
2365
|
+
};
|
|
2366
|
+
var registration = { done: false };
|
|
2367
|
+
function registerAISdkTelemetry({ collector, modules }, load = importInstalled) {
|
|
2368
|
+
if (registration.done) {
|
|
2369
|
+
return;
|
|
2370
|
+
}
|
|
2371
|
+
const ai = _optionalChain([modules, 'optionalAccess', _91 => _91.ai]);
|
|
2372
|
+
const otel = _optionalChain([modules, 'optionalAccess', _92 => _92.aiOtel]);
|
|
2373
|
+
if (ai && (otel || !collector || typeof ai.registerTelemetry !== "function")) {
|
|
2374
|
+
registerIntegrations(ai, otel, collector);
|
|
2375
|
+
return;
|
|
2376
|
+
}
|
|
2377
|
+
if (ai) {
|
|
2378
|
+
_chunkC5OT6GAQcjs.logger.debug(
|
|
2379
|
+
"instrumentModules has ai but not aiOtel; pass aiOtel too to trace a call made right after Brizz.initialize()"
|
|
2380
|
+
);
|
|
2381
|
+
}
|
|
2382
|
+
return registerInstalled(collector, load, ai, otel);
|
|
2383
|
+
}
|
|
2384
|
+
async function registerInstalled(collector, load, suppliedAi, suppliedOtel) {
|
|
2385
|
+
try {
|
|
2386
|
+
const ai = await _asyncNullishCoalesce(suppliedAi, async () => ( await load.ai()));
|
|
2387
|
+
const otel = collector && typeof _optionalChain([ai, 'optionalAccess', _93 => _93.registerTelemetry]) === "function" ? await _asyncNullishCoalesce(suppliedOtel, async () => ( await load.otel())) : void 0;
|
|
2388
|
+
registerIntegrations(ai, otel, collector);
|
|
2389
|
+
} catch (error) {
|
|
2390
|
+
_chunkC5OT6GAQcjs.logger.debug(`Vercel AI telemetry not registered: ${String(error)}`);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
function registerIntegrations(ai, otel, collector) {
|
|
2394
|
+
try {
|
|
2395
|
+
if (registration.done) {
|
|
2396
|
+
return;
|
|
2397
|
+
}
|
|
2398
|
+
if (!ai) {
|
|
2399
|
+
_chunkC5OT6GAQcjs.logger.debug("AI SDK not installed; install ai@>=6 to capture AI SDK telemetry");
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
const register = _nullishCoalesce(callable(ai.registerTelemetry), () => ( callable(ai.registerTelemetryIntegration)));
|
|
2403
|
+
if (!register) {
|
|
2404
|
+
_chunkC5OT6GAQcjs.logger.debug(
|
|
2405
|
+
"AI SDK present but lacks a telemetry-registration hook (needs ai@>=6); skipping"
|
|
2406
|
+
);
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
const integrations = [createInterruptIntegration()];
|
|
2410
|
+
if (register === ai.registerTelemetry && collector) {
|
|
2411
|
+
const openTelemetry = createCollector(_optionalChain([otel, 'optionalAccess', _94 => _94.OpenTelemetry]));
|
|
2412
|
+
if (openTelemetry) {
|
|
2413
|
+
integrations.push(openTelemetry);
|
|
2414
|
+
} else {
|
|
2415
|
+
_chunkC5OT6GAQcjs.logger.warn(
|
|
2416
|
+
"AI SDK present but @ai-sdk/otel is missing or unusable; install it (npm install @ai-sdk/otel) to capture AI SDK spans on ai@>=7"
|
|
2417
|
+
);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
register(...integrations);
|
|
2421
|
+
registration.done = true;
|
|
2422
|
+
} catch (error) {
|
|
2423
|
+
_chunkC5OT6GAQcjs.logger.debug(`Vercel AI telemetry not registered: ${String(error)}`);
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
function createCollector(OpenTelemetry) {
|
|
2427
|
+
if (typeof OpenTelemetry !== "function") {
|
|
2428
|
+
return void 0;
|
|
2429
|
+
}
|
|
2430
|
+
try {
|
|
2431
|
+
return endUnreportedModelCalls(
|
|
2432
|
+
new OpenTelemetry({
|
|
2433
|
+
tracer: _chunkDC2MFO65cjs.brizzTracerProvider.getTracer(_chunkIWSFMCHHcjs.AI_SDK_OTEL_SCOPE),
|
|
2434
|
+
// Records the model's tool-choice decisions (`ai.decision.*`).
|
|
2435
|
+
experimental_decision: true,
|
|
2436
|
+
// Carries the price the Vercel AI Gateway billed.
|
|
2437
|
+
providerMetadata: true
|
|
2438
|
+
})
|
|
2439
|
+
);
|
|
2440
|
+
} catch (e6) {
|
|
2441
|
+
return void 0;
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
function callable(hook) {
|
|
2445
|
+
return typeof hook === "function" ? hook : void 0;
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2161
2448
|
// src/internal/trace/tracing.ts
|
|
2162
2449
|
var _exportertraceotlpproto = require('@opentelemetry/exporter-trace-otlp-proto');
|
|
2163
2450
|
|
|
@@ -2179,7 +2466,7 @@ var BrizzSpanExporter = (_class4 = class {
|
|
|
2179
2466
|
const resourceAttrs = {
|
|
2180
2467
|
...config.resourceAttributes,
|
|
2181
2468
|
"service.name": config.appName,
|
|
2182
|
-
[BRIZZ_SDK_VERSION]:
|
|
2469
|
+
[BRIZZ_SDK_VERSION]: _chunkQXHGMS5Acjs.getSDKVersion.call(void 0, ),
|
|
2183
2470
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2184
2471
|
};
|
|
2185
2472
|
if (config.environment) {
|
|
@@ -2193,7 +2480,7 @@ var BrizzSpanExporter = (_class4 = class {
|
|
|
2193
2480
|
}
|
|
2194
2481
|
/** The service a span reports under: its scoped override, else the configured appName. */
|
|
2195
2482
|
_serviceNameOf(span) {
|
|
2196
|
-
const value = span.attributes[
|
|
2483
|
+
const value = span.attributes[_chunkIWSFMCHHcjs.SERVICE_NAME_ATTRIBUTE];
|
|
2197
2484
|
return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
|
|
2198
2485
|
}
|
|
2199
2486
|
_resourceFor(serviceName) {
|
|
@@ -2249,7 +2536,7 @@ var BrizzSpanExporter = (_class4 = class {
|
|
|
2249
2536
|
try {
|
|
2250
2537
|
return Promise.resolve(filter(span));
|
|
2251
2538
|
} catch (error) {
|
|
2252
|
-
|
|
2539
|
+
_chunkC5OT6GAQcjs.logger.warn("beforeSendSpan threw; span will be kept", { error });
|
|
2253
2540
|
return Promise.resolve(true);
|
|
2254
2541
|
}
|
|
2255
2542
|
});
|
|
@@ -2269,7 +2556,7 @@ var BrizzSpanExporter = (_class4 = class {
|
|
|
2269
2556
|
this._exportGroups(filtered, resultCallback);
|
|
2270
2557
|
return;
|
|
2271
2558
|
}).catch((error) => {
|
|
2272
|
-
|
|
2559
|
+
_chunkC5OT6GAQcjs.logger.warn("beforeSendSpan rejected; all spans will be kept", { error });
|
|
2273
2560
|
this._exportGroups(groups, resultCallback);
|
|
2274
2561
|
});
|
|
2275
2562
|
}
|
|
@@ -2306,8 +2593,8 @@ var BrizzSpanExporter = (_class4 = class {
|
|
|
2306
2593
|
}
|
|
2307
2594
|
async forceFlush() {
|
|
2308
2595
|
await Promise.all([
|
|
2309
|
-
_optionalChain([this, 'access',
|
|
2310
|
-
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access',
|
|
2596
|
+
_optionalChain([this, 'access', _95 => _95._delegate, 'access', _96 => _96.forceFlush, 'optionalCall', _97 => _97()]),
|
|
2597
|
+
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _98 => _98.forceFlush, 'optionalCall', _99 => _99()]))
|
|
2311
2598
|
]);
|
|
2312
2599
|
}
|
|
2313
2600
|
}, _class4);
|
|
@@ -2319,10 +2606,10 @@ var BrizzSpanExporter = (_class4 = class {
|
|
|
2319
2606
|
|
|
2320
2607
|
|
|
2321
2608
|
function applyContextAttributes(span) {
|
|
2322
|
-
const sessionProperties = _api.context.active().getValue(
|
|
2609
|
+
const sessionProperties = _api.context.active().getValue(_chunkIWSFMCHHcjs.PROPERTIES_CONTEXT_KEY);
|
|
2323
2610
|
if (sessionProperties) {
|
|
2324
2611
|
for (const [key, value] of Object.entries(sessionProperties)) {
|
|
2325
|
-
span.setAttribute(`${
|
|
2612
|
+
span.setAttribute(`${_chunkIWSFMCHHcjs.BRIZZ}.${key}`, value);
|
|
2326
2613
|
}
|
|
2327
2614
|
}
|
|
2328
2615
|
}
|
|
@@ -2365,7 +2652,7 @@ var BrizzSimpleSpanProcessor = class extends _sdktrace.SimpleSpanProcessor {
|
|
|
2365
2652
|
}
|
|
2366
2653
|
onEnd(span) {
|
|
2367
2654
|
restampLangChainSpan(span);
|
|
2368
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2655
|
+
const maskingConfig = _optionalChain([this, 'access', _100 => _100.config, 'access', _101 => _101.masking, 'optionalAccess', _102 => _102.spanMasking]);
|
|
2369
2656
|
if (maskingConfig) {
|
|
2370
2657
|
maskReadableSpan(span, maskingConfig);
|
|
2371
2658
|
}
|
|
@@ -2384,7 +2671,7 @@ var BrizzBatchSpanProcessor = class extends _sdktrace.BatchSpanProcessor {
|
|
|
2384
2671
|
}
|
|
2385
2672
|
onEnd(span) {
|
|
2386
2673
|
restampLangChainSpan(span);
|
|
2387
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2674
|
+
const maskingConfig = _optionalChain([this, 'access', _103 => _103.config, 'access', _104 => _104.masking, 'optionalAccess', _105 => _105.spanMasking]);
|
|
2388
2675
|
if (maskingConfig) {
|
|
2389
2676
|
maskReadableSpan(span, maskingConfig);
|
|
2390
2677
|
}
|
|
@@ -2401,7 +2688,7 @@ function maskReadableSpan(span, config) {
|
|
|
2401
2688
|
for (const [k, v] of Object.entries(attrs)) {
|
|
2402
2689
|
masked[k] = v;
|
|
2403
2690
|
}
|
|
2404
|
-
if (_optionalChain([config, 'access',
|
|
2691
|
+
if (_optionalChain([config, 'access', _106 => _106.rules, 'optionalAccess', _107 => _107.length])) {
|
|
2405
2692
|
masked = maskAttributes(masked, config.rules);
|
|
2406
2693
|
}
|
|
2407
2694
|
if (!config.disableDefaultRules) {
|
|
@@ -2415,7 +2702,7 @@ function maskReadableSpan(span, config) {
|
|
|
2415
2702
|
}
|
|
2416
2703
|
}
|
|
2417
2704
|
} catch (error) {
|
|
2418
|
-
|
|
2705
|
+
_chunkC5OT6GAQcjs.logger.error("Error masking span", { err: error });
|
|
2419
2706
|
}
|
|
2420
2707
|
}
|
|
2421
2708
|
|
|
@@ -2435,17 +2722,17 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
|
|
|
2435
2722
|
*/
|
|
2436
2723
|
initSpanExporter(config) {
|
|
2437
2724
|
if (this.spanExporter) {
|
|
2438
|
-
|
|
2725
|
+
_chunkC5OT6GAQcjs.logger.debug("Span exporter already initialized, skipping re-initialization");
|
|
2439
2726
|
return;
|
|
2440
2727
|
}
|
|
2441
2728
|
if (config.customSpanExporter) {
|
|
2442
|
-
|
|
2729
|
+
_chunkC5OT6GAQcjs.logger.debug("Using custom span exporter");
|
|
2443
2730
|
this.spanExporter = new BrizzSpanExporter(config.customSpanExporter, config);
|
|
2444
|
-
|
|
2731
|
+
_chunkC5OT6GAQcjs.logger.debug("Custom span exporter initialized successfully");
|
|
2445
2732
|
return;
|
|
2446
2733
|
}
|
|
2447
2734
|
const tracesUrl = config.baseUrl.replace(/\/$/, "") + "/v1/traces";
|
|
2448
|
-
|
|
2735
|
+
_chunkC5OT6GAQcjs.logger.debug("Initializing default OTLP span exporter", { url: tracesUrl });
|
|
2449
2736
|
const otlpExporter = new (0, _exportertraceotlpproto.OTLPTraceExporter)({
|
|
2450
2737
|
url: tracesUrl,
|
|
2451
2738
|
headers: config.headers
|
|
@@ -2458,34 +2745,34 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
|
|
|
2458
2745
|
headers: { ...config.headers, [_chunkUNLNNKZ7cjs.SERVICE_NAME_HEADER]: serviceName }
|
|
2459
2746
|
})
|
|
2460
2747
|
);
|
|
2461
|
-
|
|
2748
|
+
_chunkC5OT6GAQcjs.logger.debug("OTLP span exporter initialized successfully");
|
|
2462
2749
|
}
|
|
2463
2750
|
/**
|
|
2464
2751
|
* Initialize the span processor with masking support
|
|
2465
2752
|
*/
|
|
2466
2753
|
initSpanProcessor(config) {
|
|
2467
2754
|
if (this.spanProcessor) {
|
|
2468
|
-
|
|
2755
|
+
_chunkC5OT6GAQcjs.logger.debug("Span processor already initialized, skipping re-initialization");
|
|
2469
2756
|
return;
|
|
2470
2757
|
}
|
|
2471
2758
|
if (!this.spanExporter) {
|
|
2472
2759
|
throw new Error("Span exporter must be initialized before processor");
|
|
2473
2760
|
}
|
|
2474
|
-
|
|
2761
|
+
_chunkC5OT6GAQcjs.logger.debug("Initializing span processor", {
|
|
2475
2762
|
disableBatch: config.disableBatch,
|
|
2476
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
2763
|
+
hasMasking: !!_optionalChain([config, 'access', _108 => _108.masking, 'optionalAccess', _109 => _109.spanMasking])
|
|
2477
2764
|
});
|
|
2478
2765
|
const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
|
|
2479
|
-
|
|
2766
|
+
_chunkC5OT6GAQcjs.logger.debug("Span processor initialized successfully");
|
|
2480
2767
|
this.spanProcessor = spanProcessor;
|
|
2481
2768
|
}
|
|
2482
2769
|
/**
|
|
2483
2770
|
* Initialize the tracing module with the provided configuration
|
|
2484
2771
|
*/
|
|
2485
2772
|
setup(config) {
|
|
2486
|
-
|
|
2773
|
+
_chunkC5OT6GAQcjs.logger.info("Setting up tracing module");
|
|
2487
2774
|
if (config.disableSpanExporter) {
|
|
2488
|
-
|
|
2775
|
+
_chunkC5OT6GAQcjs.logger.info(
|
|
2489
2776
|
"Span exporter disabled via disableSpanExporter; skipping exporter and processor setup"
|
|
2490
2777
|
);
|
|
2491
2778
|
this.spanExporter = null;
|
|
@@ -2496,7 +2783,7 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
|
|
|
2496
2783
|
this.initSpanExporter(config);
|
|
2497
2784
|
this.initSpanProcessor(config);
|
|
2498
2785
|
_TracingModule.instance = this;
|
|
2499
|
-
|
|
2786
|
+
_chunkC5OT6GAQcjs.logger.info("Tracing module setup completed");
|
|
2500
2787
|
}
|
|
2501
2788
|
/**
|
|
2502
2789
|
* Get the span exporter
|
|
@@ -2517,10 +2804,10 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
|
|
|
2517
2804
|
return this.spanProcessor;
|
|
2518
2805
|
}
|
|
2519
2806
|
async forceFlush() {
|
|
2520
|
-
await _optionalChain([this, 'access',
|
|
2807
|
+
await _optionalChain([this, 'access', _110 => _110.spanProcessor, 'optionalAccess', _111 => _111.forceFlush, 'call', _112 => _112()]);
|
|
2521
2808
|
}
|
|
2522
2809
|
async shutdown() {
|
|
2523
|
-
|
|
2810
|
+
_chunkC5OT6GAQcjs.logger.debug("Shutting down tracing module");
|
|
2524
2811
|
if (this.spanProcessor) {
|
|
2525
2812
|
await this.spanProcessor.shutdown();
|
|
2526
2813
|
this.spanProcessor = null;
|
|
@@ -2530,7 +2817,7 @@ var TracingModule = (_class5 = class _TracingModule {constructor() { _class5.pro
|
|
|
2530
2817
|
this.spanExporter = null;
|
|
2531
2818
|
}
|
|
2532
2819
|
_TracingModule.instance = null;
|
|
2533
|
-
|
|
2820
|
+
_chunkC5OT6GAQcjs.logger.debug("Tracing module shutdown completed");
|
|
2534
2821
|
}
|
|
2535
2822
|
}, _class5.__initStatic3(), _class5);
|
|
2536
2823
|
function getSpanExporter() {
|
|
@@ -2543,7 +2830,7 @@ function getSpanProcessor() {
|
|
|
2543
2830
|
// src/internal/trace/decision-call.ts
|
|
2544
2831
|
|
|
2545
2832
|
|
|
2546
|
-
var tracer = _chunkDC2MFO65cjs.brizzTracerProvider.getTracer("@brizz/sdk/decision-call",
|
|
2833
|
+
var tracer = _chunkDC2MFO65cjs.brizzTracerProvider.getTracer("@brizz/sdk/decision-call", _chunkQXHGMS5Acjs.getSDKVersion.call(void 0, ));
|
|
2547
2834
|
function decisionCall(options, callback) {
|
|
2548
2835
|
const span = startDecisionSpan(options);
|
|
2549
2836
|
if (!span) {
|
|
@@ -2580,18 +2867,18 @@ function recordDecisionCall(record) {
|
|
|
2580
2867
|
}
|
|
2581
2868
|
span.end(record.endTime);
|
|
2582
2869
|
} catch (error) {
|
|
2583
|
-
|
|
2870
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz decision call: could not record the call: ${String(error)}`);
|
|
2584
2871
|
}
|
|
2585
2872
|
}
|
|
2586
2873
|
function startDecisionSpan(options, startTime) {
|
|
2587
2874
|
try {
|
|
2588
2875
|
const requestModel = options.requestModel || options.model;
|
|
2589
2876
|
const attributes = {
|
|
2590
|
-
[
|
|
2591
|
-
[
|
|
2592
|
-
[
|
|
2593
|
-
[
|
|
2594
|
-
[
|
|
2877
|
+
[_chunkIWSFMCHHcjs.GEN_AI_OPERATION_NAME]: _chunkIWSFMCHHcjs.GEN_AI_OPERATION_CLASSIFY,
|
|
2878
|
+
[_chunkIWSFMCHHcjs.GEN_AI_PROVIDER_NAME]: options.provider,
|
|
2879
|
+
[_chunkIWSFMCHHcjs.GEN_AI_REQUEST_MODEL]: requestModel,
|
|
2880
|
+
[_chunkIWSFMCHHcjs.GEN_AI_RESPONSE_MODEL]: options.model,
|
|
2881
|
+
[_chunkIWSFMCHHcjs.GEN_AI_OUTPUT_TYPE]: "json"
|
|
2595
2882
|
};
|
|
2596
2883
|
const inputMessages = toJson([
|
|
2597
2884
|
{
|
|
@@ -2603,25 +2890,25 @@ function startDecisionSpan(options, startTime) {
|
|
|
2603
2890
|
}
|
|
2604
2891
|
]);
|
|
2605
2892
|
if (inputMessages !== void 0) {
|
|
2606
|
-
attributes[
|
|
2893
|
+
attributes[_chunkIWSFMCHHcjs.GEN_AI_INPUT_MESSAGES] = inputMessages;
|
|
2607
2894
|
}
|
|
2608
2895
|
const sessionId = currentSessionId();
|
|
2609
2896
|
if (sessionId) {
|
|
2610
|
-
attributes[
|
|
2897
|
+
attributes[_chunkIWSFMCHHcjs.GEN_AI_CONVERSATION_ID] = sessionId;
|
|
2611
2898
|
}
|
|
2612
|
-
return tracer.startSpan(`${
|
|
2899
|
+
return tracer.startSpan(`${_chunkIWSFMCHHcjs.GEN_AI_OPERATION_CLASSIFY} ${requestModel}`, {
|
|
2613
2900
|
kind: _api.SpanKind.CLIENT,
|
|
2614
2901
|
attributes,
|
|
2615
2902
|
startTime
|
|
2616
2903
|
});
|
|
2617
2904
|
} catch (error) {
|
|
2618
|
-
|
|
2905
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz decision call: could not start span: ${String(error)}`);
|
|
2619
2906
|
return void 0;
|
|
2620
2907
|
}
|
|
2621
2908
|
}
|
|
2622
2909
|
function currentSessionId() {
|
|
2623
|
-
const properties = _api.context.active().getValue(
|
|
2624
|
-
return _optionalChain([properties, 'optionalAccess',
|
|
2910
|
+
const properties = _api.context.active().getValue(_chunkIWSFMCHHcjs.PROPERTIES_CONTEXT_KEY);
|
|
2911
|
+
return _optionalChain([properties, 'optionalAccess', _113 => _113[_chunkIWSFMCHHcjs.SESSION_ID]]);
|
|
2625
2912
|
}
|
|
2626
2913
|
function describeResultOn(span, provider) {
|
|
2627
2914
|
const set = (key, value) => {
|
|
@@ -2631,13 +2918,13 @@ function describeResultOn(span, provider) {
|
|
|
2631
2918
|
try {
|
|
2632
2919
|
span.setAttribute(key, value);
|
|
2633
2920
|
} catch (error) {
|
|
2634
|
-
|
|
2921
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz decision call: could not set ${key}: ${String(error)}`);
|
|
2635
2922
|
}
|
|
2636
2923
|
};
|
|
2637
2924
|
return {
|
|
2638
2925
|
setAnswers(answers) {
|
|
2639
2926
|
set(
|
|
2640
|
-
|
|
2927
|
+
_chunkIWSFMCHHcjs.GEN_AI_OUTPUT_MESSAGES,
|
|
2641
2928
|
toJson([
|
|
2642
2929
|
{
|
|
2643
2930
|
role: "assistant",
|
|
@@ -2648,16 +2935,16 @@ function describeResultOn(span, provider) {
|
|
|
2648
2935
|
);
|
|
2649
2936
|
},
|
|
2650
2937
|
setUsage(usage) {
|
|
2651
|
-
set(
|
|
2652
|
-
set(
|
|
2938
|
+
set(_chunkIWSFMCHHcjs.GEN_AI_USAGE_INPUT_TOKENS, finiteNumber(_optionalChain([usage, 'optionalAccess', _114 => _114.inputTokens])));
|
|
2939
|
+
set(_chunkIWSFMCHHcjs.GEN_AI_USAGE_OUTPUT_TOKENS, finiteNumber(_optionalChain([usage, 'optionalAccess', _115 => _115.outputTokens])));
|
|
2653
2940
|
},
|
|
2654
2941
|
setCost(costUsd) {
|
|
2655
|
-
set(
|
|
2942
|
+
set(_chunkIWSFMCHHcjs.GEN_AI_USAGE_COST_USD, finiteNumber(costUsd));
|
|
2656
2943
|
}
|
|
2657
2944
|
};
|
|
2658
2945
|
}
|
|
2659
2946
|
function endWhenSettled(span, result) {
|
|
2660
|
-
if (typeof _optionalChain([result, 'optionalAccess',
|
|
2947
|
+
if (typeof _optionalChain([result, 'optionalAccess', _116 => _116.then]) !== "function") {
|
|
2661
2948
|
span.end();
|
|
2662
2949
|
return result;
|
|
2663
2950
|
}
|
|
@@ -2679,9 +2966,9 @@ function endWithError(span, error) {
|
|
|
2679
2966
|
code: _api.SpanStatusCode.ERROR,
|
|
2680
2967
|
message: error instanceof Error ? error.message : String(error)
|
|
2681
2968
|
});
|
|
2682
|
-
span.setAttribute(
|
|
2969
|
+
span.setAttribute(_chunkIWSFMCHHcjs.ERROR_TYPE, errorType(error));
|
|
2683
2970
|
} catch (describeError) {
|
|
2684
|
-
|
|
2971
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz decision call: could not record the error: ${String(describeError)}`);
|
|
2685
2972
|
}
|
|
2686
2973
|
span.end();
|
|
2687
2974
|
}
|
|
@@ -2723,7 +3010,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2723
3010
|
*/
|
|
2724
3011
|
setupInstrumentation(options) {
|
|
2725
3012
|
const registry = InstrumentationRegistry.getInstance();
|
|
2726
|
-
|
|
3013
|
+
_chunkQXHGMS5Acjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
|
|
2727
3014
|
patchInstalledCallbackManager();
|
|
2728
3015
|
patchInstalledLangGraph();
|
|
2729
3016
|
patchInstalledTypeSafe();
|
|
@@ -2742,7 +3029,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2742
3029
|
if (options.disableNodeSdk) {
|
|
2743
3030
|
_chunkDC2MFO65cjs.setPrivateTracerProvider.call(void 0, null);
|
|
2744
3031
|
if (!resolvedConfig.setGlobalTracerProvider) {
|
|
2745
|
-
|
|
3032
|
+
_chunkC5OT6GAQcjs.logger.warn(
|
|
2746
3033
|
"Brizz: setGlobalTracerProvider: false has no effect with disableNodeSdk: true. Brizz creates no TracerProvider, so spans follow the provider you register with getSpanProcessor()."
|
|
2747
3034
|
);
|
|
2748
3035
|
}
|
|
@@ -2752,13 +3039,13 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2752
3039
|
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
2753
3040
|
});
|
|
2754
3041
|
}
|
|
2755
|
-
|
|
3042
|
+
_chunkC5OT6GAQcjs.logger.info("NodeSDK disabled - only telemetry modules initialized");
|
|
2756
3043
|
return;
|
|
2757
3044
|
}
|
|
2758
3045
|
const resourceAttributes = {
|
|
2759
3046
|
...resolvedConfig.resourceAttributes,
|
|
2760
3047
|
"service.name": resolvedConfig.appName,
|
|
2761
|
-
[BRIZZ_SDK_VERSION]:
|
|
3048
|
+
[BRIZZ_SDK_VERSION]: _chunkQXHGMS5Acjs.getSDKVersion.call(void 0, ),
|
|
2762
3049
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2763
3050
|
};
|
|
2764
3051
|
if (resolvedConfig.environment) {
|
|
@@ -2768,7 +3055,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2768
3055
|
resourceAttributes["service.version"] = resolvedConfig.appVersion;
|
|
2769
3056
|
}
|
|
2770
3057
|
const resource = _resources2.defaultResource.call(void 0, ).merge(_resources2.detectResources.call(void 0, { detectors: [_resources2.envDetector, _resources2.hostDetector, _resources2.processDetector] })).merge(_resources2.resourceFromAttributes.call(void 0, resourceAttributes));
|
|
2771
|
-
const spanProcessors = resolvedConfig.disableSpanExporter ? [] : [new
|
|
3058
|
+
const spanProcessors = resolvedConfig.disableSpanExporter ? [] : [new InterruptPropagator(), getSpanProcessor()];
|
|
2772
3059
|
if (resolvedConfig.setGlobalTracerProvider) {
|
|
2773
3060
|
this._tracerProvider = new (0, _sdktrace.TracerProvider)({ resource, spanProcessors });
|
|
2774
3061
|
this.registerGlobalTracerProvider(this._tracerProvider);
|
|
@@ -2779,12 +3066,12 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2779
3066
|
sampler: new (0, _sdktrace.AlwaysOnSampler)()
|
|
2780
3067
|
});
|
|
2781
3068
|
if (_chunkDC2MFO65cjs.ensureContextManager.call(void 0, ) === "failed") {
|
|
2782
|
-
|
|
3069
|
+
_chunkC5OT6GAQcjs.logger.warn(
|
|
2783
3070
|
"Brizz: no OpenTelemetry context manager is active and Brizz could not install one; span parenting and session/user propagation will not work."
|
|
2784
3071
|
);
|
|
2785
3072
|
}
|
|
2786
3073
|
_chunkDC2MFO65cjs.setPrivateTracerProvider.call(void 0, this._tracerProvider);
|
|
2787
|
-
|
|
3074
|
+
_chunkC5OT6GAQcjs.logger.info(
|
|
2788
3075
|
"Brizz: using a private TracerProvider; Brizz spans are exported to Brizz only and the global TracerProvider is left untouched."
|
|
2789
3076
|
);
|
|
2790
3077
|
}
|
|
@@ -2796,11 +3083,11 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2796
3083
|
instrumentations: manualInstrumentations,
|
|
2797
3084
|
tracerProvider: _chunkDC2MFO65cjs.brizzTracerProvider
|
|
2798
3085
|
});
|
|
2799
|
-
|
|
3086
|
+
_chunkC5OT6GAQcjs.logger.info(
|
|
2800
3087
|
`Telemetry providers started with ${manualInstrumentations.length} manual instrumentations`
|
|
2801
3088
|
);
|
|
2802
3089
|
} else {
|
|
2803
|
-
|
|
3090
|
+
_chunkC5OT6GAQcjs.logger.info(
|
|
2804
3091
|
"Telemetry providers started - using auto-instrumentations loaded at import time"
|
|
2805
3092
|
);
|
|
2806
3093
|
}
|
|
@@ -2819,10 +3106,10 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2819
3106
|
return;
|
|
2820
3107
|
}
|
|
2821
3108
|
if (Reflect.get(registered, BRIZZ_OWNED) === true) {
|
|
2822
|
-
|
|
3109
|
+
_chunkC5OT6GAQcjs.logger.debug("A TracerProvider from an earlier Brizz.initialize() is still registered");
|
|
2823
3110
|
return;
|
|
2824
3111
|
}
|
|
2825
|
-
|
|
3112
|
+
_chunkC5OT6GAQcjs.logger.warn(
|
|
2826
3113
|
"Brizz: another OpenTelemetry TracerProvider is already registered globally, so Brizz could not register its own. Spans from Brizz instrumentations will go to that provider, not to Brizz. Pass setGlobalTracerProvider: false to Brizz.initialize() (or set BRIZZ_SET_GLOBAL_TRACER_PROVIDER=false) to send them to Brizz on a separate provider."
|
|
2827
3114
|
);
|
|
2828
3115
|
}
|
|
@@ -2836,17 +3123,17 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2836
3123
|
* @private
|
|
2837
3124
|
*/
|
|
2838
3125
|
initializeModules(config) {
|
|
2839
|
-
|
|
2840
|
-
|
|
3126
|
+
_chunkC5OT6GAQcjs.logger.info("Initializing telemetry modules");
|
|
3127
|
+
_chunkC5OT6GAQcjs.logger.debug("Initializing tracing module");
|
|
2841
3128
|
const tracingModule = new TracingModule();
|
|
2842
3129
|
tracingModule.setup(config);
|
|
2843
|
-
|
|
3130
|
+
_chunkC5OT6GAQcjs.logger.debug("Initializing metrics module");
|
|
2844
3131
|
const metricsModule = new MetricsModule();
|
|
2845
3132
|
metricsModule.setup(config);
|
|
2846
|
-
|
|
3133
|
+
_chunkC5OT6GAQcjs.logger.debug("Initializing logging module");
|
|
2847
3134
|
const loggingModule = new LoggingModule();
|
|
2848
3135
|
loggingModule.setup(config);
|
|
2849
|
-
|
|
3136
|
+
_chunkC5OT6GAQcjs.logger.info("All telemetry modules initialized successfully");
|
|
2850
3137
|
}
|
|
2851
3138
|
/**
|
|
2852
3139
|
* Detect the current module system (ESM or CJS) using reliable indicators
|
|
@@ -2855,7 +3142,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2855
3142
|
* @private
|
|
2856
3143
|
*/
|
|
2857
3144
|
detectModuleSystem() {
|
|
2858
|
-
const inCJS = typeof module !== "undefined" && typeof exports !== "undefined" && typeof
|
|
3145
|
+
const inCJS = typeof module !== "undefined" && typeof exports !== "undefined" && typeof _chunkC5OT6GAQcjs.__require === "function" && typeof __filename === "string" && typeof __dirname === "string" && this === (typeof exports !== "undefined" ? exports : void 0);
|
|
2859
3146
|
return inCJS ? "CJS" : "ESM";
|
|
2860
3147
|
}
|
|
2861
3148
|
/**
|
|
@@ -2863,29 +3150,29 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2863
3150
|
* @private
|
|
2864
3151
|
*/
|
|
2865
3152
|
async shutdownModules() {
|
|
2866
|
-
|
|
3153
|
+
_chunkC5OT6GAQcjs.logger.info("Shutting down telemetry modules");
|
|
2867
3154
|
try {
|
|
2868
3155
|
try {
|
|
2869
3156
|
const tracingModule = TracingModule.getInstance();
|
|
2870
3157
|
await tracingModule.shutdown();
|
|
2871
|
-
} catch (
|
|
2872
|
-
|
|
3158
|
+
} catch (e7) {
|
|
3159
|
+
_chunkC5OT6GAQcjs.logger.debug("Tracing module already shut down or not initialized");
|
|
2873
3160
|
}
|
|
2874
3161
|
try {
|
|
2875
3162
|
const metricsModule = MetricsModule.getInstance();
|
|
2876
3163
|
metricsModule.shutdown();
|
|
2877
|
-
} catch (
|
|
2878
|
-
|
|
3164
|
+
} catch (e8) {
|
|
3165
|
+
_chunkC5OT6GAQcjs.logger.debug("Metrics module already shut down or not initialized");
|
|
2879
3166
|
}
|
|
2880
3167
|
try {
|
|
2881
3168
|
const loggingModule = LoggingModule.getInstance();
|
|
2882
3169
|
await loggingModule.shutdown();
|
|
2883
|
-
} catch (
|
|
2884
|
-
|
|
3170
|
+
} catch (e9) {
|
|
3171
|
+
_chunkC5OT6GAQcjs.logger.debug("Logging module already shut down or not initialized");
|
|
2885
3172
|
}
|
|
2886
|
-
|
|
3173
|
+
_chunkC5OT6GAQcjs.logger.info("All telemetry modules shut down successfully");
|
|
2887
3174
|
} catch (error) {
|
|
2888
|
-
|
|
3175
|
+
_chunkC5OT6GAQcjs.logger.error("Error shutting down modules", { error });
|
|
2889
3176
|
throw error;
|
|
2890
3177
|
}
|
|
2891
3178
|
}
|
|
@@ -2906,21 +3193,25 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2906
3193
|
*/
|
|
2907
3194
|
initialize(options) {
|
|
2908
3195
|
if (this._initialized) {
|
|
2909
|
-
|
|
3196
|
+
_chunkC5OT6GAQcjs.logger.warn("Brizz SDK already initialized");
|
|
2910
3197
|
return;
|
|
2911
3198
|
}
|
|
2912
|
-
|
|
3199
|
+
_chunkC5OT6GAQcjs.logger.info("Starting Brizz SDK initialization");
|
|
2913
3200
|
try {
|
|
2914
3201
|
const resolvedConfig = resolveConfig(options);
|
|
2915
3202
|
this.initializeModules(resolvedConfig);
|
|
2916
3203
|
this.setupInstrumentation(options);
|
|
2917
3204
|
this.createAndStartProviders(options, resolvedConfig);
|
|
3205
|
+
void registerAISdkTelemetry({
|
|
3206
|
+
collector: !options.disableAiSdkCollector,
|
|
3207
|
+
modules: options.instrumentModules
|
|
3208
|
+
});
|
|
2918
3209
|
this._initialized = true;
|
|
2919
|
-
|
|
3210
|
+
_chunkC5OT6GAQcjs.logger.info("Brizz SDK initialization completed successfully", {
|
|
2920
3211
|
moduleSystem: this.detectModuleSystem()
|
|
2921
3212
|
});
|
|
2922
3213
|
} catch (error) {
|
|
2923
|
-
|
|
3214
|
+
_chunkC5OT6GAQcjs.logger.error("Failed to initialize Brizz SDK", { error });
|
|
2924
3215
|
throw new Error(`Failed to initialize SDK: ${String(error)}`, { cause: error });
|
|
2925
3216
|
}
|
|
2926
3217
|
}
|
|
@@ -2943,7 +3234,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2943
3234
|
*/
|
|
2944
3235
|
async flush(timeoutMillis = 5e3) {
|
|
2945
3236
|
if (!this._initialized) {
|
|
2946
|
-
|
|
3237
|
+
_chunkC5OT6GAQcjs.logger.debug("Brizz.flush called before Brizz.initialize; nothing to flush");
|
|
2947
3238
|
return false;
|
|
2948
3239
|
}
|
|
2949
3240
|
const settle = async (name, flush) => {
|
|
@@ -2951,7 +3242,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2951
3242
|
await flush();
|
|
2952
3243
|
return true;
|
|
2953
3244
|
} catch (error) {
|
|
2954
|
-
|
|
3245
|
+
_chunkC5OT6GAQcjs.logger.debug(`Brizz.flush: flushing ${name} failed: ${String(error)}`);
|
|
2955
3246
|
return false;
|
|
2956
3247
|
}
|
|
2957
3248
|
};
|
|
@@ -2970,7 +3261,7 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2970
3261
|
try {
|
|
2971
3262
|
const result = await Promise.race([work, timedOut]);
|
|
2972
3263
|
if (result === "timeout") {
|
|
2973
|
-
|
|
3264
|
+
_chunkC5OT6GAQcjs.logger.warn(
|
|
2974
3265
|
`Brizz.flush did not finish within ${timeoutMillis}ms; telemetry still queued will be sent with the next batch.`
|
|
2975
3266
|
);
|
|
2976
3267
|
return false;
|
|
@@ -2997,25 +3288,25 @@ var _Brizz = (_class6 = class __Brizz {constructor() { _class6.prototype.__init1
|
|
|
2997
3288
|
*/
|
|
2998
3289
|
async shutdown() {
|
|
2999
3290
|
if (!this._initialized) {
|
|
3000
|
-
|
|
3291
|
+
_chunkC5OT6GAQcjs.logger.warn("Brizz SDK not initialized");
|
|
3001
3292
|
return;
|
|
3002
3293
|
}
|
|
3003
3294
|
try {
|
|
3004
3295
|
await this.shutdownModules();
|
|
3005
|
-
await _optionalChain([this, 'access',
|
|
3006
|
-
await _optionalChain([this, 'access',
|
|
3007
|
-
await _optionalChain([this, 'access',
|
|
3008
|
-
await _optionalChain([this, 'access',
|
|
3296
|
+
await _optionalChain([this, 'access', _117 => _117._tracerProvider, 'optionalAccess', _118 => _118.forceFlush, 'call', _119 => _119()]);
|
|
3297
|
+
await _optionalChain([this, 'access', _120 => _120._tracerProvider, 'optionalAccess', _121 => _121.shutdown, 'call', _122 => _122()]);
|
|
3298
|
+
await _optionalChain([this, 'access', _123 => _123._meterProvider, 'optionalAccess', _124 => _124.forceFlush, 'call', _125 => _125()]);
|
|
3299
|
+
await _optionalChain([this, 'access', _126 => _126._meterProvider, 'optionalAccess', _127 => _127.shutdown, 'call', _128 => _128()]);
|
|
3009
3300
|
this._initialized = false;
|
|
3010
3301
|
this._tracerProvider = null;
|
|
3011
3302
|
this._meterProvider = null;
|
|
3012
3303
|
__Brizz.instance = null;
|
|
3013
|
-
|
|
3304
|
+
_chunkC5OT6GAQcjs.logger.info("Brizz SDK shut down successfully");
|
|
3014
3305
|
} catch (error) {
|
|
3015
3306
|
if (error instanceof Error && error.message.includes("ENOTFOUND")) {
|
|
3016
|
-
|
|
3307
|
+
_chunkC5OT6GAQcjs.logger.debug(`Network error during shutdown (expected in tests): ${error.message}`);
|
|
3017
3308
|
} else {
|
|
3018
|
-
|
|
3309
|
+
_chunkC5OT6GAQcjs.logger.error(`Failed to shutdown Brizz SDK: ${String(error)}`);
|
|
3019
3310
|
throw error;
|
|
3020
3311
|
}
|
|
3021
3312
|
}
|
|
@@ -3075,4 +3366,4 @@ var Brizz = new _Brizz();
|
|
|
3075
3366
|
|
|
3076
3367
|
|
|
3077
3368
|
|
|
3078
|
-
exports.Brizz = Brizz; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.LogLevel =
|
|
3369
|
+
exports.Brizz = Brizz; exports.DEFAULT_PII_PATTERNS = DEFAULT_PII_PATTERNS; exports.LogLevel = _chunkC5OT6GAQcjs.LogLevel; exports.Session = _chunkUF4GMVEYcjs.Session; exports.SessionTitle = _chunkUF4GMVEYcjs.SessionTitle; exports.SeverityNumber = _api.SeverityNumber; exports.addExternalLink = _chunkUF4GMVEYcjs.addExternalLink; exports.callWithMessageId = _chunkUF4GMVEYcjs.callWithMessageId; exports.callWithMute = _chunkUF4GMVEYcjs.callWithMute; exports.callWithOrganization = _chunkUF4GMVEYcjs.callWithOrganization; exports.callWithProperties = _chunkUF4GMVEYcjs.callWithProperties; exports.callWithServiceName = _chunkUF4GMVEYcjs.callWithServiceName; exports.callWithSessionId = _chunkUF4GMVEYcjs.callWithSessionId; exports.callWithUser = _chunkUF4GMVEYcjs.callWithUser; exports.decisionCall = decisionCall; exports.emitEvent = _chunkUF4GMVEYcjs.emitEvent; exports.emitEventWithSessionId = _chunkUF4GMVEYcjs.emitEventWithSessionId; exports.getActiveSession = _chunkUF4GMVEYcjs.getActiveSession; exports.getLogLevel = _chunkC5OT6GAQcjs.getLogLevel; exports.getMetricsExporter = getMetricsExporter; exports.getMetricsReader = getMetricsReader; exports.getSpanExporter = getSpanExporter; exports.getSpanProcessor = getSpanProcessor; exports.getTracerProvider = _chunkDC2MFO65cjs.getTracerProvider; exports.logger = _chunkC5OT6GAQcjs.logger; exports.maskAttributes = maskAttributes; exports.maskValue = maskValue; exports.recordDecisionCall = recordDecisionCall; exports.recordFeedback = _chunkUF4GMVEYcjs.recordFeedback; exports.recordMetric = _chunkUF4GMVEYcjs.recordMetric; exports.setAgent = _chunkUF4GMVEYcjs.setAgent; exports.setCurrentSpanCustomProperties = _chunkUF4GMVEYcjs.setCurrentSpanCustomProperties; exports.setLogLevel = _chunkC5OT6GAQcjs.setLogLevel; exports.setMessageId = _chunkUF4GMVEYcjs.setMessageId; exports.setOrganization = _chunkUF4GMVEYcjs.setOrganization; exports.setServiceName = _chunkUF4GMVEYcjs.setServiceName; exports.setSessionId = _chunkUF4GMVEYcjs.setSessionId; exports.setUser = _chunkUF4GMVEYcjs.setUser; exports.startAgent = _chunkUF4GMVEYcjs.startAgent; exports.startSession = _chunkUF4GMVEYcjs.startSession; exports.startSessionTitle = _chunkUF4GMVEYcjs.startSessionTitle; exports.withAgent = _chunkUF4GMVEYcjs.withAgent; exports.withMessageId = _chunkUF4GMVEYcjs.withMessageId; exports.withMute = _chunkUF4GMVEYcjs.withMute; exports.withOrganization = _chunkUF4GMVEYcjs.withOrganization; exports.withProperties = _chunkUF4GMVEYcjs.withProperties; exports.withServiceName = _chunkUF4GMVEYcjs.withServiceName; exports.withSessionId = _chunkUF4GMVEYcjs.withSessionId; exports.withUser = _chunkUF4GMVEYcjs.withUser;
|