@brizz/sdk 0.1.44 → 0.1.46
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/README.md +8 -2
- package/dist/{chunk-AELIATPI.js → chunk-USYGGHMA.js} +7 -7
- package/dist/{chunk-A3HH5OUL.cjs → chunk-VFWTFL7E.cjs} +6 -6
- package/dist/index.cjs +462 -65
- package/dist/index.js +433 -36
- package/dist/{mcp-5FSUXYHM.cjs → mcp-M3WRCR7G.cjs} +11 -11
- package/dist/{mcp-7EJXVCPI.js → mcp-YHBVF7QU.js} +1 -1
- package/dist/types/cjs/internal/instrumentation/langchain.d.ts +4 -0
- package/dist/types/cjs/internal/instrumentation/langgraph/attributes.d.ts +38 -0
- package/dist/types/cjs/internal/instrumentation/langgraph/index.d.ts +1 -0
- package/dist/types/cjs/internal/instrumentation/langgraph/instrumentation.d.ts +11 -0
- package/dist/types/cjs/internal/instrumentation/registry.d.ts +1 -0
- package/dist/types/esm/internal/instrumentation/langchain.d.ts +4 -0
- package/dist/types/esm/internal/instrumentation/langgraph/attributes.d.ts +38 -0
- package/dist/types/esm/internal/instrumentation/langgraph/index.d.ts +1 -0
- package/dist/types/esm/internal/instrumentation/langgraph/instrumentation.d.ts +11 -0
- package/dist/types/esm/internal/instrumentation/registry.d.ts +1 -0
- package/package.json +40 -32
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkVFWTFL7Ecjs = require('./chunk-VFWTFL7E.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -89,6 +89,294 @@ var _instrumentationllamaindex = require('@traceloop/instrumentation-llamaindex'
|
|
|
89
89
|
var _instrumentationpinecone = require('@traceloop/instrumentation-pinecone');
|
|
90
90
|
var _instrumentationqdrant = require('@traceloop/instrumentation-qdrant');
|
|
91
91
|
var _instrumentationtogether = require('@traceloop/instrumentation-together');
|
|
92
|
+
|
|
93
|
+
// src/internal/instrumentation/langgraph/instrumentation.ts
|
|
94
|
+
var _api = require('@opentelemetry/api');
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// src/internal/instrumentation/langgraph/attributes.ts
|
|
101
|
+
var INSTRUMENTATION_NAME = "@brizz/sdk/langgraph";
|
|
102
|
+
var INSTRUMENTATION_VERSION = _chunkVFWTFL7Ecjs.getSDKVersion.call(void 0, );
|
|
103
|
+
var MODULE_NAME = "@langchain/langgraph";
|
|
104
|
+
var SUPPORTED_VERSIONS = [">=0.2.0 <2"];
|
|
105
|
+
var CHECKPOINT_SPAN_NAME = "brizz.langgraph.checkpoint";
|
|
106
|
+
var ATTR_CHECKPOINT_PARENT_ID = "brizz.checkpoint_parent_id";
|
|
107
|
+
var ATTR_CHECKPOINT_ID = "brizz.checkpoint_id";
|
|
108
|
+
var ATTR_CHECKPOINT_NS = "brizz.checkpoint_ns";
|
|
109
|
+
var ATTR_CHECKPOINT_THREAD_ID = "brizz.checkpoint_thread_id";
|
|
110
|
+
function asNonEmptyString(value) {
|
|
111
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
112
|
+
}
|
|
113
|
+
function readCheckpointId(config) {
|
|
114
|
+
return asNonEmptyString(_optionalChain([config, 'optionalAccess', _2 => _2.configurable, 'optionalAccess', _3 => _3.checkpoint_id]));
|
|
115
|
+
}
|
|
116
|
+
function readCheckpointNs(config) {
|
|
117
|
+
return asNonEmptyString(_optionalChain([config, 'optionalAccess', _4 => _4.configurable, 'optionalAccess', _5 => _5.checkpoint_ns]));
|
|
118
|
+
}
|
|
119
|
+
function readThreadId(config) {
|
|
120
|
+
return asNonEmptyString(_optionalChain([config, 'optionalAccess', _6 => _6.configurable, 'optionalAccess', _7 => _7.thread_id]));
|
|
121
|
+
}
|
|
122
|
+
function readWrittenCheckpointId(checkpoint) {
|
|
123
|
+
return asNonEmptyString(_optionalChain([checkpoint, 'optionalAccess', _8 => _8.id]));
|
|
124
|
+
}
|
|
125
|
+
function resolveCheckpointer(graph, config) {
|
|
126
|
+
const inherited = _optionalChain([config, 'optionalAccess', _9 => _9.configurable, 'optionalAccess', _10 => _10.__pregel_checkpointer]);
|
|
127
|
+
const candidate = _nullishCoalesce(inherited, () => ( graph.checkpointer));
|
|
128
|
+
return typeof candidate === "object" && candidate !== null ? candidate : void 0;
|
|
129
|
+
}
|
|
130
|
+
function resolvePregelPrototype(module2) {
|
|
131
|
+
if (typeof module2 !== "object" || module2 === null) {
|
|
132
|
+
return void 0;
|
|
133
|
+
}
|
|
134
|
+
const exports2 = module2;
|
|
135
|
+
const direct = _optionalChain([exports2, 'access', _11 => _11["Pregel"], 'optionalAccess', _12 => _12.prototype]);
|
|
136
|
+
if (isPregelPrototype(direct)) {
|
|
137
|
+
return direct;
|
|
138
|
+
}
|
|
139
|
+
for (const name of ["CompiledStateGraph", "CompiledGraph", "MessageGraph"]) {
|
|
140
|
+
let proto = _optionalChain([exports2, 'access', _13 => _13[name], 'optionalAccess', _14 => _14.prototype]);
|
|
141
|
+
while (proto && proto !== Object.prototype) {
|
|
142
|
+
if (isPregelPrototype(proto)) {
|
|
143
|
+
return proto;
|
|
144
|
+
}
|
|
145
|
+
proto = Object.getPrototypeOf(proto);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return void 0;
|
|
149
|
+
}
|
|
150
|
+
function isPregelPrototype(value) {
|
|
151
|
+
if (typeof value !== "object" || value === null) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return typeof value.stream === "function" && typeof value.getState === "function" && Object.prototype.hasOwnProperty.call(value, "stream") && Object.prototype.hasOwnProperty.call(value, "getState");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// src/internal/instrumentation/langgraph/instrumentation.ts
|
|
158
|
+
var PATCHED_FLAG = /* @__PURE__ */ Symbol.for("brizz.langgraph.patched");
|
|
159
|
+
var CHECKPOINT_SPAN_KEY = _api.createContextKey.call(void 0, "brizz.langgraph.checkpoint_span");
|
|
160
|
+
var patchedSavers = /* @__PURE__ */ new WeakSet();
|
|
161
|
+
var parentRecorded = /* @__PURE__ */ new WeakSet();
|
|
162
|
+
var LangGraphInstrumentation = class extends _instrumentation.InstrumentationBase {
|
|
163
|
+
constructor(config = {}) {
|
|
164
|
+
super(INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION, config);
|
|
165
|
+
}
|
|
166
|
+
init() {
|
|
167
|
+
return [
|
|
168
|
+
new (0, _instrumentation.InstrumentationNodeModuleDefinition)(
|
|
169
|
+
MODULE_NAME,
|
|
170
|
+
SUPPORTED_VERSIONS,
|
|
171
|
+
(moduleExports) => {
|
|
172
|
+
this.applyPatch(moduleExports);
|
|
173
|
+
return moduleExports;
|
|
174
|
+
},
|
|
175
|
+
(moduleExports) => moduleExports
|
|
176
|
+
)
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Patch a LangGraph module the caller already imported.
|
|
181
|
+
*
|
|
182
|
+
* The module-load hook above only fires for CommonJS requires, so an ESM or
|
|
183
|
+
* bundled consumer reaches the instrumentation through here — via
|
|
184
|
+
* `Brizz.initialize({ instrumentModules: { langgraph } })`. Accepts either
|
|
185
|
+
* the package root or its `pregel` subpath.
|
|
186
|
+
*/
|
|
187
|
+
manuallyInstrument(moduleExports) {
|
|
188
|
+
this.applyPatch(moduleExports);
|
|
189
|
+
}
|
|
190
|
+
applyPatch(moduleExports) {
|
|
191
|
+
const proto = resolvePregelPrototype(moduleExports);
|
|
192
|
+
if (!proto) {
|
|
193
|
+
_chunkWC573FCIcjs.logger.debug("Brizz LangGraph: module does not expose a Pregel prototype \u2014 skipping patch");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (patchPregelStream(proto, () => this.tracer)) {
|
|
197
|
+
_chunkWC573FCIcjs.logger.debug("Brizz LangGraph: patched Pregel.stream for checkpoint spans");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
function patchPregelStream(proto, getTracer) {
|
|
202
|
+
const target = proto;
|
|
203
|
+
if (target[PATCHED_FLAG]) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
const originalStream = proto.stream;
|
|
207
|
+
if (typeof originalStream !== "function") {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
proto.stream = async function patchedStream(input, options) {
|
|
211
|
+
const run = beginRun(this, options, getTracer);
|
|
212
|
+
if (!run) {
|
|
213
|
+
return await originalStream.call(this, input, options);
|
|
214
|
+
}
|
|
215
|
+
let stream;
|
|
216
|
+
try {
|
|
217
|
+
stream = await _api.context.with(run.runContext, () => originalStream.call(this, input, options));
|
|
218
|
+
} catch (error) {
|
|
219
|
+
endRun(run, error);
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
return attachRunToIteration(stream, run);
|
|
223
|
+
};
|
|
224
|
+
target[PATCHED_FLAG] = true;
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
function patchSaver(checkpointer) {
|
|
228
|
+
const proto = Object.getPrototypeOf(checkpointer);
|
|
229
|
+
if (!proto || patchedSavers.has(proto)) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
patchedSavers.add(proto);
|
|
233
|
+
const originalPut = proto.put;
|
|
234
|
+
if (typeof originalPut !== "function") {
|
|
235
|
+
_chunkWC573FCIcjs.logger.debug("Brizz LangGraph: checkpointer exposes no put \u2014 checkpoint ids unavailable");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const patchedPut = function brizzPut(config, checkpoint, ...rest) {
|
|
239
|
+
recordCheckpoint(config, checkpoint);
|
|
240
|
+
return originalPut.call(this, config, checkpoint, ...rest);
|
|
241
|
+
};
|
|
242
|
+
proto.put = patchedPut;
|
|
243
|
+
}
|
|
244
|
+
function recordCheckpoint(config, checkpoint) {
|
|
245
|
+
try {
|
|
246
|
+
const span = _api.context.active().getValue(CHECKPOINT_SPAN_KEY);
|
|
247
|
+
if (!_optionalChain([span, 'optionalAccess', _15 => _15.isRecording, 'call', _16 => _16()])) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const checkpointId = readWrittenCheckpointId(checkpoint);
|
|
251
|
+
if (checkpointId) {
|
|
252
|
+
span.setAttribute(ATTR_CHECKPOINT_ID, checkpointId);
|
|
253
|
+
}
|
|
254
|
+
if (parentRecorded.has(span)) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
parentRecorded.add(span);
|
|
258
|
+
setIfKnown(span, ATTR_CHECKPOINT_PARENT_ID, readCheckpointId(config));
|
|
259
|
+
setIfKnown(span, ATTR_CHECKPOINT_THREAD_ID, readThreadId(config));
|
|
260
|
+
setIfKnown(span, ATTR_CHECKPOINT_NS, readCheckpointNs(config));
|
|
261
|
+
} catch (error) {
|
|
262
|
+
_chunkWC573FCIcjs.logger.debug(`Brizz LangGraph: could not record a checkpoint write: ${String(error)}`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function setIfKnown(span, key, value) {
|
|
266
|
+
if (value) {
|
|
267
|
+
span.setAttribute(key, value);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function beginRun(graph, options, getTracer) {
|
|
271
|
+
try {
|
|
272
|
+
if (!_optionalChain([options, 'optionalAccess', _17 => _17.configurable])) {
|
|
273
|
+
return void 0;
|
|
274
|
+
}
|
|
275
|
+
const checkpointer = resolveCheckpointer(graph, options);
|
|
276
|
+
if (!checkpointer) {
|
|
277
|
+
return void 0;
|
|
278
|
+
}
|
|
279
|
+
patchSaver(checkpointer);
|
|
280
|
+
const span = getTracer().startSpan(CHECKPOINT_SPAN_NAME);
|
|
281
|
+
return {
|
|
282
|
+
span,
|
|
283
|
+
runContext: _api.trace.setSpan(_api.context.active(), span).setValue(CHECKPOINT_SPAN_KEY, span)
|
|
284
|
+
};
|
|
285
|
+
} catch (error) {
|
|
286
|
+
_chunkWC573FCIcjs.logger.debug(`Brizz LangGraph: could not start checkpoint span: ${String(error)}`);
|
|
287
|
+
return void 0;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
var CONTROL_FLOW_ERROR_NAMES = /* @__PURE__ */ new Set([
|
|
291
|
+
"GraphInterrupt",
|
|
292
|
+
"GraphBubbleUp",
|
|
293
|
+
"GraphDrained",
|
|
294
|
+
"NodeInterrupt",
|
|
295
|
+
"ParentCommand"
|
|
296
|
+
]);
|
|
297
|
+
function isControlFlow(error) {
|
|
298
|
+
const name = _optionalChain([error, 'optionalAccess', _18 => _18.name]);
|
|
299
|
+
return typeof name === "string" && CONTROL_FLOW_ERROR_NAMES.has(name);
|
|
300
|
+
}
|
|
301
|
+
function endRun(run, error) {
|
|
302
|
+
try {
|
|
303
|
+
if (error !== void 0 && !isControlFlow(error)) {
|
|
304
|
+
run.span.recordException(
|
|
305
|
+
error instanceof Error ? error : new Error(String(error), { cause: error })
|
|
306
|
+
);
|
|
307
|
+
run.span.setStatus({ code: _api.SpanStatusCode.ERROR });
|
|
308
|
+
}
|
|
309
|
+
} catch (spanError) {
|
|
310
|
+
_chunkWC573FCIcjs.logger.debug(`Brizz LangGraph: could not finish checkpoint span: ${String(spanError)}`);
|
|
311
|
+
} finally {
|
|
312
|
+
run.span.end();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function attachRunToIteration(stream, run) {
|
|
316
|
+
if (typeof stream !== "object" || stream === null) {
|
|
317
|
+
endRun(run);
|
|
318
|
+
return stream;
|
|
319
|
+
}
|
|
320
|
+
const iterable = stream;
|
|
321
|
+
const originalIterator = iterable[Symbol.asyncIterator];
|
|
322
|
+
if (typeof originalIterator !== "function") {
|
|
323
|
+
endRun(run);
|
|
324
|
+
return stream;
|
|
325
|
+
}
|
|
326
|
+
let settled = false;
|
|
327
|
+
const settle = (error) => {
|
|
328
|
+
if (settled) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
settled = true;
|
|
332
|
+
endRun(run, error);
|
|
333
|
+
};
|
|
334
|
+
Object.defineProperty(iterable, Symbol.asyncIterator, {
|
|
335
|
+
configurable: true,
|
|
336
|
+
writable: true,
|
|
337
|
+
value: function brizzCheckpointIterator() {
|
|
338
|
+
const inner = originalIterator.call(this);
|
|
339
|
+
return {
|
|
340
|
+
[Symbol.asyncIterator]() {
|
|
341
|
+
return this;
|
|
342
|
+
},
|
|
343
|
+
async next(...args) {
|
|
344
|
+
let result;
|
|
345
|
+
try {
|
|
346
|
+
result = await _api.context.with(run.runContext, () => inner.next(...args));
|
|
347
|
+
} catch (error) {
|
|
348
|
+
settle(error);
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
if (result.done) {
|
|
352
|
+
settle();
|
|
353
|
+
}
|
|
354
|
+
return result;
|
|
355
|
+
},
|
|
356
|
+
async return(value) {
|
|
357
|
+
try {
|
|
358
|
+
return inner.return ? await _api.context.with(run.runContext, () => inner.return(value)) : { value, done: true };
|
|
359
|
+
} finally {
|
|
360
|
+
settle();
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
async throw(error) {
|
|
364
|
+
try {
|
|
365
|
+
if (!inner.throw) {
|
|
366
|
+
throw error;
|
|
367
|
+
}
|
|
368
|
+
return await _api.context.with(run.runContext, () => inner.throw(error));
|
|
369
|
+
} finally {
|
|
370
|
+
settle(error);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
return iterable;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/internal/instrumentation/auto-init.ts
|
|
92
380
|
var exceptionLogger = (error) => {
|
|
93
381
|
_chunkWC573FCIcjs.logger.error(`Exception in instrumentation: ${String(error)}`);
|
|
94
382
|
};
|
|
@@ -130,7 +418,7 @@ function loadGenAIInstrumentations() {
|
|
|
130
418
|
function loadMCPInstrumentation() {
|
|
131
419
|
void (async () => {
|
|
132
420
|
try {
|
|
133
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
421
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-M3WRCR7G.cjs")));
|
|
134
422
|
const mcp = new MCPInstrumentation({ exceptionLogger });
|
|
135
423
|
_instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
|
|
136
424
|
_chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
|
|
@@ -141,6 +429,14 @@ function loadMCPInstrumentation() {
|
|
|
141
429
|
}
|
|
142
430
|
})();
|
|
143
431
|
}
|
|
432
|
+
function loadLangGraphInstrumentation() {
|
|
433
|
+
try {
|
|
434
|
+
_instrumentation.registerInstrumentations.call(void 0, { instrumentations: [new LangGraphInstrumentation()] });
|
|
435
|
+
_chunkWC573FCIcjs.logger.debug("Auto-loaded LangGraph instrumentation");
|
|
436
|
+
} catch (error) {
|
|
437
|
+
_chunkWC573FCIcjs.logger.debug(`LangGraph instrumentation not loaded: ${String(error)}`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
144
440
|
function loadVertexAIInstrumentation() {
|
|
145
441
|
void (async () => {
|
|
146
442
|
try {
|
|
@@ -218,6 +514,7 @@ function autoInitializeInstrumentations() {
|
|
|
218
514
|
try {
|
|
219
515
|
const genAIInstrumentations = loadGenAIInstrumentations();
|
|
220
516
|
loadMCPInstrumentation();
|
|
517
|
+
loadLangGraphInstrumentation();
|
|
221
518
|
loadVertexAIInstrumentation();
|
|
222
519
|
loadGoogleGenAIInstrumentation();
|
|
223
520
|
loadVercelAITelemetry();
|
|
@@ -233,7 +530,7 @@ function autoInitializeInstrumentations() {
|
|
|
233
530
|
var autoInstrumentationsLoaded = autoInitializeInstrumentations();
|
|
234
531
|
|
|
235
532
|
// src/internal/sdk.ts
|
|
236
|
-
|
|
533
|
+
|
|
237
534
|
|
|
238
535
|
|
|
239
536
|
|
|
@@ -248,7 +545,7 @@ var _sdktracenode = require('@opentelemetry/sdk-trace-node');
|
|
|
248
545
|
|
|
249
546
|
// src/internal/config.ts
|
|
250
547
|
function resolveConfig(options) {
|
|
251
|
-
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access',
|
|
548
|
+
const envLogLevel = process.env["BRIZZ_LOG_LEVEL"] || _optionalChain([options, 'access', _19 => _19.logLevel, 'optionalAccess', _20 => _20.toString, 'call', _21 => _21()]) || _chunkWC573FCIcjs.DEFAULT_LOG_LEVEL.toString();
|
|
252
549
|
let resolvedLogLevel;
|
|
253
550
|
if (envLogLevel) {
|
|
254
551
|
resolvedLogLevel = _chunkWC573FCIcjs.parseLogLevel.call(void 0, envLogLevel);
|
|
@@ -394,6 +691,94 @@ var SDK_LANGUAGE = "typescript";
|
|
|
394
691
|
|
|
395
692
|
|
|
396
693
|
|
|
694
|
+
|
|
695
|
+
// src/internal/instrumentation/langchain.ts
|
|
696
|
+
|
|
697
|
+
var SCOPE_NAME = "@arizeai/openinference-instrumentation-langchain";
|
|
698
|
+
var PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.callbackManagerPatched");
|
|
699
|
+
var OMITTED_KEYS = /* @__PURE__ */ new Set([
|
|
700
|
+
_chunk5WBPX342cjs.USER_EMAIL,
|
|
701
|
+
_chunk5WBPX342cjs.USER_NAME,
|
|
702
|
+
_chunk5WBPX342cjs.ORGANIZATION_NAME,
|
|
703
|
+
_chunk5WBPX342cjs.ORGANIZATION_DOMAIN
|
|
704
|
+
]);
|
|
705
|
+
function runMetadataFromContext() {
|
|
706
|
+
const bag = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
707
|
+
if (!bag) {
|
|
708
|
+
return void 0;
|
|
709
|
+
}
|
|
710
|
+
const metadata = {};
|
|
711
|
+
for (const [name, value] of Object.entries(bag)) {
|
|
712
|
+
if (!OMITTED_KEYS.has(name)) {
|
|
713
|
+
metadata[`${_chunk5WBPX342cjs.BRIZZ}.${name}`] = String(value);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
717
|
+
}
|
|
718
|
+
function patchCallbackManagerModule(module2) {
|
|
719
|
+
const callbackManager = _optionalChain([module2, 'optionalAccess', _22 => _22.CallbackManager]);
|
|
720
|
+
if (callbackManager === null || typeof callbackManager !== "function" && typeof callbackManager !== "object") {
|
|
721
|
+
return false;
|
|
722
|
+
}
|
|
723
|
+
const statics = callbackManager;
|
|
724
|
+
if (statics[PATCHED_MARKER] === true) {
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
const key = "_configureSync" in statics ? "_configureSync" : "configure";
|
|
728
|
+
const original = statics[key];
|
|
729
|
+
if (typeof original !== "function") {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
const configure2 = original;
|
|
733
|
+
statics[key] = function(...args) {
|
|
734
|
+
const manager = configure2.apply(this, args);
|
|
735
|
+
try {
|
|
736
|
+
const metadata = runMetadataFromContext();
|
|
737
|
+
if (manager && metadata) {
|
|
738
|
+
manager.addMetadata(metadata);
|
|
739
|
+
}
|
|
740
|
+
} catch (e2) {
|
|
741
|
+
}
|
|
742
|
+
return manager;
|
|
743
|
+
};
|
|
744
|
+
statics[PATCHED_MARKER] = true;
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
function patchInstalledCallbackManager() {
|
|
748
|
+
void (async () => {
|
|
749
|
+
try {
|
|
750
|
+
patchCallbackManagerModule(await Promise.resolve().then(() => _interopRequireWildcard(require("@langchain/core/callbacks/manager"))));
|
|
751
|
+
} catch (error) {
|
|
752
|
+
_chunkWC573FCIcjs.logger.debug(`LangChain callback manager not patched: ${String(error)}`);
|
|
753
|
+
}
|
|
754
|
+
})();
|
|
755
|
+
}
|
|
756
|
+
function restampLangChainSpan(span) {
|
|
757
|
+
try {
|
|
758
|
+
const scope = span.instrumentationScope;
|
|
759
|
+
if (_optionalChain([scope, 'optionalAccess', _23 => _23.name]) !== SCOPE_NAME) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
const attrs = span.attributes;
|
|
763
|
+
const metadata = attrs["metadata"];
|
|
764
|
+
if (typeof metadata !== "string" || !metadata.includes(`"${_chunk5WBPX342cjs.BRIZZ}.`)) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
const parsed = JSON.parse(metadata);
|
|
768
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
772
|
+
if (key.startsWith(`${_chunk5WBPX342cjs.BRIZZ}.`) && value !== null && value !== void 0) {
|
|
773
|
+
attrs[key] = String(value);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
} catch (error) {
|
|
777
|
+
_chunkWC573FCIcjs.logger.debug("Skipped LangChain span re-stamp", { err: error });
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// src/internal/instrumentation/registry.ts
|
|
397
782
|
var InstrumentationRegistry = (_class = class _InstrumentationRegistry {constructor() { _class.prototype.__init.call(this); }
|
|
398
783
|
|
|
399
784
|
static getInstance() {
|
|
@@ -426,7 +811,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
426
811
|
* @private
|
|
427
812
|
*/
|
|
428
813
|
loadManualInstrumentations(instrumentations, exceptionLogger2) {
|
|
429
|
-
if (_optionalChain([this, 'access',
|
|
814
|
+
if (_optionalChain([this, 'access', _24 => _24.manualModules, 'optionalAccess', _25 => _25.openAI])) {
|
|
430
815
|
try {
|
|
431
816
|
const openAIInst = new (0, _openinferenceinstrumentationopenai.OpenAIInstrumentation)();
|
|
432
817
|
openAIInst.manuallyInstrument(this.manualModules.openAI);
|
|
@@ -437,18 +822,18 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
437
822
|
}
|
|
438
823
|
}
|
|
439
824
|
const instrumentationConfigs = [
|
|
440
|
-
{ class: _instrumentationanthropic.AnthropicInstrumentation, name: "Anthropic", module: _optionalChain([this, 'access',
|
|
441
|
-
{ class: _instrumentationcohere.CohereInstrumentation, name: "Cohere", module: _optionalChain([this, 'access',
|
|
442
|
-
{ class: _instrumentationbedrock.BedrockInstrumentation, name: "Bedrock", module: _optionalChain([this, 'access',
|
|
443
|
-
{ class: _instrumentationpinecone.PineconeInstrumentation, name: "Pinecone", module: _optionalChain([this, 'access',
|
|
825
|
+
{ class: _instrumentationanthropic.AnthropicInstrumentation, name: "Anthropic", module: _optionalChain([this, 'access', _26 => _26.manualModules, 'optionalAccess', _27 => _27.anthropic]) },
|
|
826
|
+
{ class: _instrumentationcohere.CohereInstrumentation, name: "Cohere", module: _optionalChain([this, 'access', _28 => _28.manualModules, 'optionalAccess', _29 => _29.cohere]) },
|
|
827
|
+
{ class: _instrumentationbedrock.BedrockInstrumentation, name: "Bedrock", module: _optionalChain([this, 'access', _30 => _30.manualModules, 'optionalAccess', _31 => _31.bedrock]) },
|
|
828
|
+
{ class: _instrumentationpinecone.PineconeInstrumentation, name: "Pinecone", module: _optionalChain([this, 'access', _32 => _32.manualModules, 'optionalAccess', _33 => _33.pinecone]) },
|
|
444
829
|
{
|
|
445
830
|
class: _instrumentationllamaindex.LlamaIndexInstrumentation,
|
|
446
831
|
name: "LlamaIndex",
|
|
447
|
-
module: _optionalChain([this, 'access',
|
|
832
|
+
module: _optionalChain([this, 'access', _34 => _34.manualModules, 'optionalAccess', _35 => _35.llamaindex])
|
|
448
833
|
},
|
|
449
|
-
{ class: _instrumentationchromadb.ChromaDBInstrumentation, name: "ChromaDB", module: _optionalChain([this, 'access',
|
|
450
|
-
{ class: _instrumentationqdrant.QdrantInstrumentation, name: "Qdrant", module: _optionalChain([this, 'access',
|
|
451
|
-
{ class: _instrumentationtogether.TogetherInstrumentation, name: "Together", module: _optionalChain([this, 'access',
|
|
834
|
+
{ class: _instrumentationchromadb.ChromaDBInstrumentation, name: "ChromaDB", module: _optionalChain([this, 'access', _36 => _36.manualModules, 'optionalAccess', _37 => _37.chromadb]) },
|
|
835
|
+
{ class: _instrumentationqdrant.QdrantInstrumentation, name: "Qdrant", module: _optionalChain([this, 'access', _38 => _38.manualModules, 'optionalAccess', _39 => _39.qdrant]) },
|
|
836
|
+
{ class: _instrumentationtogether.TogetherInstrumentation, name: "Together", module: _optionalChain([this, 'access', _40 => _40.manualModules, 'optionalAccess', _41 => _41.together]) }
|
|
452
837
|
];
|
|
453
838
|
for (const config of instrumentationConfigs) {
|
|
454
839
|
if (!config.module) {
|
|
@@ -464,13 +849,14 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
464
849
|
instrumentations.push(instrumentation);
|
|
465
850
|
}
|
|
466
851
|
}
|
|
467
|
-
if (_optionalChain([this, 'access',
|
|
852
|
+
if (_optionalChain([this, 'access', _42 => _42.manualModules, 'optionalAccess', _43 => _43.langchain, 'optionalAccess', _44 => _44.callbackManagerModule])) {
|
|
468
853
|
const callbackManagerModule = this.manualModules.langchain.callbackManagerModule;
|
|
469
854
|
void (async () => {
|
|
470
855
|
try {
|
|
471
856
|
const { LangChainInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("@arizeai/openinference-instrumentation-langchain")));
|
|
472
857
|
const lcInst = new LangChainInstrumentation();
|
|
473
858
|
lcInst.manuallyInstrument(callbackManagerModule);
|
|
859
|
+
patchCallbackManagerModule(callbackManagerModule);
|
|
474
860
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for LangChain");
|
|
475
861
|
} catch (error) {
|
|
476
862
|
_chunkWC573FCIcjs.logger.error(
|
|
@@ -479,7 +865,15 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
479
865
|
}
|
|
480
866
|
})();
|
|
481
867
|
}
|
|
482
|
-
if (_optionalChain([this, 'access',
|
|
868
|
+
if (_optionalChain([this, 'access', _45 => _45.manualModules, 'optionalAccess', _46 => _46.langgraph])) {
|
|
869
|
+
try {
|
|
870
|
+
new LangGraphInstrumentation().manuallyInstrument(this.manualModules.langgraph);
|
|
871
|
+
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for LangGraph");
|
|
872
|
+
} catch (error) {
|
|
873
|
+
_chunkWC573FCIcjs.logger.error(`Failed to apply LangGraph instrumentation: ${String(error)}`);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
if (_optionalChain([this, 'access', _47 => _47.manualModules, 'optionalAccess', _48 => _48.google_vertexai])) {
|
|
483
877
|
const vertexModule = this.manualModules.google_vertexai;
|
|
484
878
|
void (async () => {
|
|
485
879
|
try {
|
|
@@ -494,7 +888,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
494
888
|
}
|
|
495
889
|
})();
|
|
496
890
|
}
|
|
497
|
-
if (_optionalChain([this, 'access',
|
|
891
|
+
if (_optionalChain([this, 'access', _49 => _49.manualModules, 'optionalAccess', _50 => _50.google_genai])) {
|
|
498
892
|
const genaiModule = this.manualModules.google_genai;
|
|
499
893
|
void (async () => {
|
|
500
894
|
try {
|
|
@@ -509,11 +903,11 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
509
903
|
}
|
|
510
904
|
})();
|
|
511
905
|
}
|
|
512
|
-
if (_optionalChain([this, 'access',
|
|
906
|
+
if (_optionalChain([this, 'access', _51 => _51.manualModules, 'optionalAccess', _52 => _52.mcp])) {
|
|
513
907
|
const mcpModules = this.manualModules.mcp;
|
|
514
908
|
void (async () => {
|
|
515
909
|
try {
|
|
516
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
910
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-M3WRCR7G.cjs")));
|
|
517
911
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
518
912
|
instrumentation.manuallyInstrument(mcpModules);
|
|
519
913
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -565,7 +959,7 @@ function setCurrentSpanCustomProperties(properties) {
|
|
|
565
959
|
for (const [key, value] of Object.entries(properties)) {
|
|
566
960
|
try {
|
|
567
961
|
current.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
|
|
568
|
-
} catch (
|
|
962
|
+
} catch (e3) {
|
|
569
963
|
}
|
|
570
964
|
}
|
|
571
965
|
}
|
|
@@ -589,15 +983,15 @@ function withProperties(properties, fn, thisArg) {
|
|
|
589
983
|
function propagatePropertiesImperatively(properties, base = _api.context.active()) {
|
|
590
984
|
try {
|
|
591
985
|
const manager = _api.context;
|
|
592
|
-
const mgr = _optionalChain([manager, 'access',
|
|
593
|
-
const store = _optionalChain([mgr, 'optionalAccess',
|
|
986
|
+
const mgr = _optionalChain([manager, 'access', _53 => _53._getContextManager, 'optionalCall', _54 => _54()]);
|
|
987
|
+
const store = _optionalChain([mgr, 'optionalAccess', _55 => _55._asyncLocalStorage]);
|
|
594
988
|
if (!store || typeof store.enterWith !== "function") {
|
|
595
989
|
return;
|
|
596
990
|
}
|
|
597
991
|
const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
598
992
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
599
993
|
store.enterWith(base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged));
|
|
600
|
-
} catch (
|
|
994
|
+
} catch (e4) {
|
|
601
995
|
}
|
|
602
996
|
}
|
|
603
997
|
function setUser(user) {
|
|
@@ -691,7 +1085,7 @@ function withServiceName(name, fn, thisArg) {
|
|
|
691
1085
|
}
|
|
692
1086
|
function resolveServiceNameFromContext() {
|
|
693
1087
|
const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
694
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1088
|
+
return _optionalChain([props, 'optionalAccess', _56 => _56[_chunk5WBPX342cjs.SERVICE_NAME]]);
|
|
695
1089
|
}
|
|
696
1090
|
function userProperties(user) {
|
|
697
1091
|
const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
|
|
@@ -758,7 +1152,7 @@ function withMessageId(id, fn, thisArg) {
|
|
|
758
1152
|
}
|
|
759
1153
|
function inheritedMuteTools() {
|
|
760
1154
|
const properties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
761
|
-
return _optionalChain([properties, 'optionalAccess',
|
|
1155
|
+
return _optionalChain([properties, 'optionalAccess', _57 => _57[_chunk5WBPX342cjs.MUTE_TOOLS]]);
|
|
762
1156
|
}
|
|
763
1157
|
function muteProperties(options) {
|
|
764
1158
|
const { input = true, output = true, tools = output } = options;
|
|
@@ -817,9 +1211,9 @@ var Session = (_class2 = class {
|
|
|
817
1211
|
* @param text - Text to append (null becomes a null/"hide marker")
|
|
818
1212
|
* @param context - Optional per-turn context bag to attach to this turn
|
|
819
1213
|
*/
|
|
820
|
-
setInput(text,
|
|
1214
|
+
setInput(text, context7) {
|
|
821
1215
|
this.inputs.push(text);
|
|
822
|
-
this.inputContexts.push(_nullishCoalesce(
|
|
1216
|
+
this.inputContexts.push(_nullishCoalesce(context7, () => ( {})));
|
|
823
1217
|
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT, JSON.stringify(this.inputs));
|
|
824
1218
|
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
|
|
825
1219
|
}
|
|
@@ -833,9 +1227,9 @@ var Session = (_class2 = class {
|
|
|
833
1227
|
* @param text - Text to append (null becomes a null/"hide marker")
|
|
834
1228
|
* @param context - Optional per-turn context bag to attach to this turn
|
|
835
1229
|
*/
|
|
836
|
-
setOutput(text,
|
|
1230
|
+
setOutput(text, context7) {
|
|
837
1231
|
this.outputs.push(text);
|
|
838
|
-
this.outputContexts.push(_nullishCoalesce(
|
|
1232
|
+
this.outputContexts.push(_nullishCoalesce(context7, () => ( {})));
|
|
839
1233
|
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
|
|
840
1234
|
this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
|
|
841
1235
|
}
|
|
@@ -920,7 +1314,7 @@ var Session = (_class2 = class {
|
|
|
920
1314
|
* (free-form category, defaults to `'generic'`)
|
|
921
1315
|
*/
|
|
922
1316
|
addExternalLink(url, options) {
|
|
923
|
-
emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess',
|
|
1317
|
+
emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _58 => _58.title]), _optionalChain([options, 'optionalAccess', _59 => _59.linkType]));
|
|
924
1318
|
}
|
|
925
1319
|
}, _class2);
|
|
926
1320
|
var SessionTitle = class {
|
|
@@ -946,11 +1340,11 @@ function resolveSessionIdFromContext() {
|
|
|
946
1340
|
return active.sessionId;
|
|
947
1341
|
}
|
|
948
1342
|
const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
949
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1343
|
+
return _optionalChain([props, 'optionalAccess', _60 => _60[_chunk5WBPX342cjs.SESSION_ID]]);
|
|
950
1344
|
}
|
|
951
1345
|
function resolveMessageIdFromContext() {
|
|
952
1346
|
const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
|
|
953
|
-
return _optionalChain([props, 'optionalAccess',
|
|
1347
|
+
return _optionalChain([props, 'optionalAccess', _61 => _61[_chunk5WBPX342cjs.MESSAGE_ID]]);
|
|
954
1348
|
}
|
|
955
1349
|
function emitExternalLink(sessionId, url, title, linkType) {
|
|
956
1350
|
try {
|
|
@@ -964,30 +1358,30 @@ function emitExternalLink(sessionId, url, title, linkType) {
|
|
|
964
1358
|
}
|
|
965
1359
|
}
|
|
966
1360
|
function addExternalLink(url, options) {
|
|
967
|
-
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1361
|
+
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _62 => _62.sessionId]), () => ( resolveSessionIdFromContext()));
|
|
968
1362
|
if (!sessionId) {
|
|
969
1363
|
_chunkWC573FCIcjs.logger.warn(
|
|
970
1364
|
"addExternalLink called without a resolvable session id; link dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope."
|
|
971
1365
|
);
|
|
972
1366
|
return;
|
|
973
1367
|
}
|
|
974
|
-
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess',
|
|
1368
|
+
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _63 => _63.title]), _optionalChain([options, 'optionalAccess', _64 => _64.linkType]));
|
|
975
1369
|
}
|
|
976
1370
|
function recordFeedback(type, options) {
|
|
977
1371
|
const eventAttributes = { [_chunk5WBPX342cjs.FEEDBACK_TYPE]: type };
|
|
978
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1372
|
+
if (_optionalChain([options, 'optionalAccess', _65 => _65.score]) !== void 0) {
|
|
979
1373
|
eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SCORE] = options.score;
|
|
980
1374
|
}
|
|
981
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1375
|
+
if (_optionalChain([options, 'optionalAccess', _66 => _66.reason]) !== void 0) {
|
|
982
1376
|
eventAttributes[_chunk5WBPX342cjs.FEEDBACK_REASON] = options.reason;
|
|
983
1377
|
}
|
|
984
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1378
|
+
if (_optionalChain([options, 'optionalAccess', _67 => _67.comment]) !== void 0) {
|
|
985
1379
|
eventAttributes[_chunk5WBPX342cjs.FEEDBACK_COMMENT] = options.comment;
|
|
986
1380
|
}
|
|
987
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1381
|
+
if (_optionalChain([options, 'optionalAccess', _68 => _68.source]) !== void 0) {
|
|
988
1382
|
eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SOURCE] = options.source;
|
|
989
1383
|
}
|
|
990
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1384
|
+
if (_optionalChain([options, 'optionalAccess', _69 => _69.attributes])) {
|
|
991
1385
|
for (const [key, value] of Object.entries(options.attributes)) {
|
|
992
1386
|
const k = `${_chunk5WBPX342cjs.FEEDBACK_ATTR_PREFIX}${key}`;
|
|
993
1387
|
if (eventAttributes[k] === void 0) {
|
|
@@ -995,8 +1389,8 @@ function recordFeedback(type, options) {
|
|
|
995
1389
|
}
|
|
996
1390
|
}
|
|
997
1391
|
}
|
|
998
|
-
const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
999
|
-
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1392
|
+
const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _70 => _70.messageId]), () => ( resolveMessageIdFromContext()));
|
|
1393
|
+
const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _71 => _71.sessionId]), () => ( resolveSessionIdFromContext()));
|
|
1000
1394
|
if (messageId === void 0 && sessionId === void 0) {
|
|
1001
1395
|
_chunkWC573FCIcjs.logger.warn(
|
|
1002
1396
|
"recordFeedback called with no resolvable message id or session id; the feedback cannot be attributed to a message or conversation. Pass options.messageId / options.sessionId or call inside a startSession/callWithMessageId scope."
|
|
@@ -1027,7 +1421,7 @@ function recordMetric(options) {
|
|
|
1027
1421
|
try {
|
|
1028
1422
|
recordMetricImpl(options);
|
|
1029
1423
|
} catch (error) {
|
|
1030
|
-
_chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess',
|
|
1424
|
+
_chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess', _72 => _72.name]))}) failed; metric dropped.`, error);
|
|
1031
1425
|
}
|
|
1032
1426
|
}
|
|
1033
1427
|
function recordMetricImpl(options) {
|
|
@@ -1142,7 +1536,7 @@ function recordMetricImpl(options) {
|
|
|
1142
1536
|
}
|
|
1143
1537
|
}
|
|
1144
1538
|
function startSession(sessionId, callback, extraProperties, options) {
|
|
1145
|
-
const isTitle = _optionalChain([options, 'optionalAccess',
|
|
1539
|
+
const isTitle = _optionalChain([options, 'optionalAccess', _73 => _73.mode]) === "title";
|
|
1146
1540
|
const spanName = isTitle ? _chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME : _chunk5WBPX342cjs.SESSION_SPAN_NAME;
|
|
1147
1541
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1148
1542
|
return tracer.startActiveSpan(spanName, (span) => {
|
|
@@ -1191,7 +1585,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1191
1585
|
});
|
|
1192
1586
|
}
|
|
1193
1587
|
function startSessionTitle(callback, options) {
|
|
1194
|
-
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
1588
|
+
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _74 => _74.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _75 => _75(), 'optionalAccess', _76 => _76.sessionId])));
|
|
1195
1589
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1196
1590
|
return tracer.startActiveSpan(_chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1197
1591
|
if (resolvedSessionId) {
|
|
@@ -1663,7 +2057,7 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
|
|
|
1663
2057
|
this.config = config;
|
|
1664
2058
|
}
|
|
1665
2059
|
onEmit(logRecord) {
|
|
1666
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2060
|
+
const maskingConfig = _optionalChain([this, 'access', _77 => _77.config, 'access', _78 => _78.masking, 'optionalAccess', _79 => _79.eventMasking]);
|
|
1667
2061
|
if (maskingConfig) {
|
|
1668
2062
|
maskLog(logRecord, maskingConfig);
|
|
1669
2063
|
}
|
|
@@ -1683,7 +2077,7 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
|
|
|
1683
2077
|
this.config = config;
|
|
1684
2078
|
}
|
|
1685
2079
|
onEmit(logRecord) {
|
|
1686
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2080
|
+
const maskingConfig = _optionalChain([this, 'access', _80 => _80.config, 'access', _81 => _81.masking, 'optionalAccess', _82 => _82.eventMasking]);
|
|
1687
2081
|
if (maskingConfig) {
|
|
1688
2082
|
maskLog(logRecord, maskingConfig);
|
|
1689
2083
|
}
|
|
@@ -1775,14 +2169,14 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
1775
2169
|
_chunkWC573FCIcjs.logger.debug("Creating logger provider", {
|
|
1776
2170
|
serviceName,
|
|
1777
2171
|
disableBatch: config.disableBatch,
|
|
1778
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
2172
|
+
hasMasking: !!_optionalChain([config, 'access', _83 => _83.masking, 'optionalAccess', _84 => _84.eventMasking])
|
|
1779
2173
|
});
|
|
1780
2174
|
const exporter = this.createLogExporter(config, serviceName);
|
|
1781
2175
|
const processor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(exporter, config) : new BrizzBatchLogRecordProcessor(exporter, config);
|
|
1782
2176
|
const resourceAttributes = {
|
|
1783
2177
|
...config.resourceAttributes,
|
|
1784
2178
|
"service.name": serviceName,
|
|
1785
|
-
[BRIZZ_SDK_VERSION]:
|
|
2179
|
+
[BRIZZ_SDK_VERSION]: _chunkVFWTFL7Ecjs.getSDKVersion.call(void 0, ),
|
|
1786
2180
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
1787
2181
|
};
|
|
1788
2182
|
if (config.environment) {
|
|
@@ -2031,7 +2425,7 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2031
2425
|
const resourceAttrs = {
|
|
2032
2426
|
...config.resourceAttributes,
|
|
2033
2427
|
"service.name": config.appName,
|
|
2034
|
-
[BRIZZ_SDK_VERSION]:
|
|
2428
|
+
[BRIZZ_SDK_VERSION]: _chunkVFWTFL7Ecjs.getSDKVersion.call(void 0, ),
|
|
2035
2429
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2036
2430
|
};
|
|
2037
2431
|
if (config.environment) {
|
|
@@ -2158,8 +2552,8 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2158
2552
|
}
|
|
2159
2553
|
async forceFlush() {
|
|
2160
2554
|
await Promise.all([
|
|
2161
|
-
_optionalChain([this, 'access',
|
|
2162
|
-
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access',
|
|
2555
|
+
_optionalChain([this, 'access', _85 => _85._delegate, 'access', _86 => _86.forceFlush, 'optionalCall', _87 => _87()]),
|
|
2556
|
+
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _88 => _88.forceFlush, 'optionalCall', _89 => _89()]))
|
|
2163
2557
|
]);
|
|
2164
2558
|
}
|
|
2165
2559
|
}, _class5);
|
|
@@ -2195,7 +2589,8 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
|
|
|
2195
2589
|
super.onStart(span, parentContext);
|
|
2196
2590
|
}
|
|
2197
2591
|
onEnd(span) {
|
|
2198
|
-
|
|
2592
|
+
restampLangChainSpan(span);
|
|
2593
|
+
const maskingConfig = _optionalChain([this, 'access', _90 => _90.config, 'access', _91 => _91.masking, 'optionalAccess', _92 => _92.spanMasking]);
|
|
2199
2594
|
if (maskingConfig) {
|
|
2200
2595
|
maskReadableSpan(span, maskingConfig);
|
|
2201
2596
|
}
|
|
@@ -2213,7 +2608,8 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
|
|
|
2213
2608
|
super.onStart(span, parentContext);
|
|
2214
2609
|
}
|
|
2215
2610
|
onEnd(span) {
|
|
2216
|
-
|
|
2611
|
+
restampLangChainSpan(span);
|
|
2612
|
+
const maskingConfig = _optionalChain([this, 'access', _93 => _93.config, 'access', _94 => _94.masking, 'optionalAccess', _95 => _95.spanMasking]);
|
|
2217
2613
|
if (maskingConfig) {
|
|
2218
2614
|
maskReadableSpan(span, maskingConfig);
|
|
2219
2615
|
}
|
|
@@ -2300,7 +2696,7 @@ var TracingModule = (_class6 = class _TracingModule {constructor() { _class6.pro
|
|
|
2300
2696
|
}
|
|
2301
2697
|
_chunkWC573FCIcjs.logger.debug("Initializing span processor", {
|
|
2302
2698
|
disableBatch: config.disableBatch,
|
|
2303
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
2699
|
+
hasMasking: !!_optionalChain([config, 'access', _96 => _96.masking, 'optionalAccess', _97 => _97.spanMasking])
|
|
2304
2700
|
});
|
|
2305
2701
|
const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
|
|
2306
2702
|
_chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
|
|
@@ -2387,7 +2783,7 @@ function currentTraceparent() {
|
|
|
2387
2783
|
const carrier = {};
|
|
2388
2784
|
try {
|
|
2389
2785
|
_api.propagation.inject(_api.context.active(), carrier);
|
|
2390
|
-
} catch (
|
|
2786
|
+
} catch (e5) {
|
|
2391
2787
|
}
|
|
2392
2788
|
return _nullishCoalesce(carrier["traceparent"], () => ( ""));
|
|
2393
2789
|
}
|
|
@@ -2410,7 +2806,7 @@ function decodeToken(token) {
|
|
|
2410
2806
|
try {
|
|
2411
2807
|
const payload = JSON.parse(Buffer.from(token, "base64url").toString("utf8"));
|
|
2412
2808
|
return payload.id ? payload : void 0;
|
|
2413
|
-
} catch (
|
|
2809
|
+
} catch (e6) {
|
|
2414
2810
|
return void 0;
|
|
2415
2811
|
}
|
|
2416
2812
|
}
|
|
@@ -2448,7 +2844,7 @@ function resolveAgent(agent) {
|
|
|
2448
2844
|
if (decoded.traceparent) {
|
|
2449
2845
|
try {
|
|
2450
2846
|
parentContext = _api.propagation.extract(parentContext, { traceparent: decoded.traceparent });
|
|
2451
|
-
} catch (
|
|
2847
|
+
} catch (e7) {
|
|
2452
2848
|
}
|
|
2453
2849
|
}
|
|
2454
2850
|
}
|
|
@@ -2520,7 +2916,8 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2520
2916
|
*/
|
|
2521
2917
|
setupInstrumentation(options) {
|
|
2522
2918
|
const registry = InstrumentationRegistry.getInstance();
|
|
2523
|
-
|
|
2919
|
+
_chunkVFWTFL7Ecjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
|
|
2920
|
+
patchInstalledCallbackManager();
|
|
2524
2921
|
if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
|
|
2525
2922
|
registry.setManualModules(options.instrumentModules);
|
|
2526
2923
|
}
|
|
@@ -2543,7 +2940,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2543
2940
|
const resourceAttributes = {
|
|
2544
2941
|
...resolvedConfig.resourceAttributes,
|
|
2545
2942
|
"service.name": resolvedConfig.appName,
|
|
2546
|
-
[BRIZZ_SDK_VERSION]:
|
|
2943
|
+
[BRIZZ_SDK_VERSION]: _chunkVFWTFL7Ecjs.getSDKVersion.call(void 0, ),
|
|
2547
2944
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2548
2945
|
};
|
|
2549
2946
|
if (resolvedConfig.environment) {
|
|
@@ -2613,19 +3010,19 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2613
3010
|
try {
|
|
2614
3011
|
const tracingModule = TracingModule.getInstance();
|
|
2615
3012
|
await tracingModule.shutdown();
|
|
2616
|
-
} catch (
|
|
3013
|
+
} catch (e8) {
|
|
2617
3014
|
_chunkWC573FCIcjs.logger.debug("Tracing module already shut down or not initialized");
|
|
2618
3015
|
}
|
|
2619
3016
|
try {
|
|
2620
3017
|
const metricsModule = MetricsModule.getInstance();
|
|
2621
3018
|
metricsModule.shutdown();
|
|
2622
|
-
} catch (
|
|
3019
|
+
} catch (e9) {
|
|
2623
3020
|
_chunkWC573FCIcjs.logger.debug("Metrics module already shut down or not initialized");
|
|
2624
3021
|
}
|
|
2625
3022
|
try {
|
|
2626
3023
|
const loggingModule = LoggingModule.getInstance();
|
|
2627
3024
|
await loggingModule.shutdown();
|
|
2628
|
-
} catch (
|
|
3025
|
+
} catch (e10) {
|
|
2629
3026
|
_chunkWC573FCIcjs.logger.debug("Logging module already shut down or not initialized");
|
|
2630
3027
|
}
|
|
2631
3028
|
_chunkWC573FCIcjs.logger.info("All telemetry modules shut down successfully");
|
|
@@ -2691,10 +3088,10 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2691
3088
|
}
|
|
2692
3089
|
try {
|
|
2693
3090
|
await this.shutdownModules();
|
|
2694
|
-
await _optionalChain([this, 'access',
|
|
2695
|
-
await _optionalChain([this, 'access',
|
|
2696
|
-
await _optionalChain([this, 'access',
|
|
2697
|
-
await _optionalChain([this, 'access',
|
|
3091
|
+
await _optionalChain([this, 'access', _98 => _98._tracerProvider, 'optionalAccess', _99 => _99.forceFlush, 'call', _100 => _100()]);
|
|
3092
|
+
await _optionalChain([this, 'access', _101 => _101._tracerProvider, 'optionalAccess', _102 => _102.shutdown, 'call', _103 => _103()]);
|
|
3093
|
+
await _optionalChain([this, 'access', _104 => _104._meterProvider, 'optionalAccess', _105 => _105.forceFlush, 'call', _106 => _106()]);
|
|
3094
|
+
await _optionalChain([this, 'access', _107 => _107._meterProvider, 'optionalAccess', _108 => _108.shutdown, 'call', _109 => _109()]);
|
|
2698
3095
|
this._initialized = false;
|
|
2699
3096
|
this._tracerProvider = null;
|
|
2700
3097
|
this._meterProvider = null;
|