@brizz/sdk 0.1.44 → 0.1.45

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.
@@ -223,7 +223,7 @@ function popTrackingArguments(request) {
223
223
 
224
224
  // src/internal/version.ts
225
225
  function getSDKVersion() {
226
- return "0.1.44";
226
+ return "0.1.45";
227
227
  }
228
228
 
229
229
  export {
@@ -223,7 +223,7 @@ function popTrackingArguments(request) {
223
223
 
224
224
  // src/internal/version.ts
225
225
  function getSDKVersion() {
226
- return "0.1.44";
226
+ return "0.1.45";
227
227
  }
228
228
 
229
229
 
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunkA3HH5OULcjs = require('./chunk-A3HH5OUL.cjs');
8
+ var _chunkCBEDIRVKcjs = require('./chunk-CBEDIRVK.cjs');
9
9
 
10
10
 
11
11
 
@@ -130,7 +130,7 @@ function loadGenAIInstrumentations() {
130
130
  function loadMCPInstrumentation() {
131
131
  void (async () => {
132
132
  try {
133
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-5FSUXYHM.cjs")));
133
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-CCFYA5CI.cjs")));
134
134
  const mcp = new MCPInstrumentation({ exceptionLogger });
135
135
  _instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
136
136
  _chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
@@ -394,6 +394,94 @@ var SDK_LANGUAGE = "typescript";
394
394
 
395
395
 
396
396
 
397
+
398
+ // src/internal/instrumentation/langchain.ts
399
+
400
+ var SCOPE_NAME = "@arizeai/openinference-instrumentation-langchain";
401
+ var PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.callbackManagerPatched");
402
+ var OMITTED_KEYS = /* @__PURE__ */ new Set([
403
+ _chunk5WBPX342cjs.USER_EMAIL,
404
+ _chunk5WBPX342cjs.USER_NAME,
405
+ _chunk5WBPX342cjs.ORGANIZATION_NAME,
406
+ _chunk5WBPX342cjs.ORGANIZATION_DOMAIN
407
+ ]);
408
+ function runMetadataFromContext() {
409
+ const bag = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
410
+ if (!bag) {
411
+ return void 0;
412
+ }
413
+ const metadata = {};
414
+ for (const [name, value] of Object.entries(bag)) {
415
+ if (!OMITTED_KEYS.has(name)) {
416
+ metadata[`${_chunk5WBPX342cjs.BRIZZ}.${name}`] = String(value);
417
+ }
418
+ }
419
+ return Object.keys(metadata).length > 0 ? metadata : void 0;
420
+ }
421
+ function patchCallbackManagerModule(module2) {
422
+ const callbackManager = _optionalChain([module2, 'optionalAccess', _5 => _5.CallbackManager]);
423
+ if (callbackManager === null || typeof callbackManager !== "function" && typeof callbackManager !== "object") {
424
+ return false;
425
+ }
426
+ const statics = callbackManager;
427
+ if (statics[PATCHED_MARKER] === true) {
428
+ return false;
429
+ }
430
+ const key = "_configureSync" in statics ? "_configureSync" : "configure";
431
+ const original = statics[key];
432
+ if (typeof original !== "function") {
433
+ return false;
434
+ }
435
+ const configure2 = original;
436
+ statics[key] = function(...args) {
437
+ const manager = configure2.apply(this, args);
438
+ try {
439
+ const metadata = runMetadataFromContext();
440
+ if (manager && metadata) {
441
+ manager.addMetadata(metadata);
442
+ }
443
+ } catch (e2) {
444
+ }
445
+ return manager;
446
+ };
447
+ statics[PATCHED_MARKER] = true;
448
+ return true;
449
+ }
450
+ function patchInstalledCallbackManager() {
451
+ void (async () => {
452
+ try {
453
+ patchCallbackManagerModule(await Promise.resolve().then(() => _interopRequireWildcard(require("@langchain/core/callbacks/manager"))));
454
+ } catch (error) {
455
+ _chunkWC573FCIcjs.logger.debug(`LangChain callback manager not patched: ${String(error)}`);
456
+ }
457
+ })();
458
+ }
459
+ function restampLangChainSpan(span) {
460
+ try {
461
+ const scope = span.instrumentationScope;
462
+ if (_optionalChain([scope, 'optionalAccess', _6 => _6.name]) !== SCOPE_NAME) {
463
+ return;
464
+ }
465
+ const attrs = span.attributes;
466
+ const metadata = attrs["metadata"];
467
+ if (typeof metadata !== "string" || !metadata.includes(`"${_chunk5WBPX342cjs.BRIZZ}.`)) {
468
+ return;
469
+ }
470
+ const parsed = JSON.parse(metadata);
471
+ if (typeof parsed !== "object" || parsed === null) {
472
+ return;
473
+ }
474
+ for (const [key, value] of Object.entries(parsed)) {
475
+ if (key.startsWith(`${_chunk5WBPX342cjs.BRIZZ}.`) && value !== null && value !== void 0) {
476
+ attrs[key] = String(value);
477
+ }
478
+ }
479
+ } catch (error) {
480
+ _chunkWC573FCIcjs.logger.debug("Skipped LangChain span re-stamp", { err: error });
481
+ }
482
+ }
483
+
484
+ // src/internal/instrumentation/registry.ts
397
485
  var InstrumentationRegistry = (_class = class _InstrumentationRegistry {constructor() { _class.prototype.__init.call(this); }
398
486
 
399
487
  static getInstance() {
@@ -426,7 +514,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
426
514
  * @private
427
515
  */
428
516
  loadManualInstrumentations(instrumentations, exceptionLogger2) {
429
- if (_optionalChain([this, 'access', _5 => _5.manualModules, 'optionalAccess', _6 => _6.openAI])) {
517
+ if (_optionalChain([this, 'access', _7 => _7.manualModules, 'optionalAccess', _8 => _8.openAI])) {
430
518
  try {
431
519
  const openAIInst = new (0, _openinferenceinstrumentationopenai.OpenAIInstrumentation)();
432
520
  openAIInst.manuallyInstrument(this.manualModules.openAI);
@@ -437,18 +525,18 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
437
525
  }
438
526
  }
439
527
  const instrumentationConfigs = [
440
- { class: _instrumentationanthropic.AnthropicInstrumentation, name: "Anthropic", module: _optionalChain([this, 'access', _7 => _7.manualModules, 'optionalAccess', _8 => _8.anthropic]) },
441
- { class: _instrumentationcohere.CohereInstrumentation, name: "Cohere", module: _optionalChain([this, 'access', _9 => _9.manualModules, 'optionalAccess', _10 => _10.cohere]) },
442
- { class: _instrumentationbedrock.BedrockInstrumentation, name: "Bedrock", module: _optionalChain([this, 'access', _11 => _11.manualModules, 'optionalAccess', _12 => _12.bedrock]) },
443
- { class: _instrumentationpinecone.PineconeInstrumentation, name: "Pinecone", module: _optionalChain([this, 'access', _13 => _13.manualModules, 'optionalAccess', _14 => _14.pinecone]) },
528
+ { class: _instrumentationanthropic.AnthropicInstrumentation, name: "Anthropic", module: _optionalChain([this, 'access', _9 => _9.manualModules, 'optionalAccess', _10 => _10.anthropic]) },
529
+ { class: _instrumentationcohere.CohereInstrumentation, name: "Cohere", module: _optionalChain([this, 'access', _11 => _11.manualModules, 'optionalAccess', _12 => _12.cohere]) },
530
+ { class: _instrumentationbedrock.BedrockInstrumentation, name: "Bedrock", module: _optionalChain([this, 'access', _13 => _13.manualModules, 'optionalAccess', _14 => _14.bedrock]) },
531
+ { class: _instrumentationpinecone.PineconeInstrumentation, name: "Pinecone", module: _optionalChain([this, 'access', _15 => _15.manualModules, 'optionalAccess', _16 => _16.pinecone]) },
444
532
  {
445
533
  class: _instrumentationllamaindex.LlamaIndexInstrumentation,
446
534
  name: "LlamaIndex",
447
- module: _optionalChain([this, 'access', _15 => _15.manualModules, 'optionalAccess', _16 => _16.llamaindex])
535
+ module: _optionalChain([this, 'access', _17 => _17.manualModules, 'optionalAccess', _18 => _18.llamaindex])
448
536
  },
449
- { class: _instrumentationchromadb.ChromaDBInstrumentation, name: "ChromaDB", module: _optionalChain([this, 'access', _17 => _17.manualModules, 'optionalAccess', _18 => _18.chromadb]) },
450
- { class: _instrumentationqdrant.QdrantInstrumentation, name: "Qdrant", module: _optionalChain([this, 'access', _19 => _19.manualModules, 'optionalAccess', _20 => _20.qdrant]) },
451
- { class: _instrumentationtogether.TogetherInstrumentation, name: "Together", module: _optionalChain([this, 'access', _21 => _21.manualModules, 'optionalAccess', _22 => _22.together]) }
537
+ { class: _instrumentationchromadb.ChromaDBInstrumentation, name: "ChromaDB", module: _optionalChain([this, 'access', _19 => _19.manualModules, 'optionalAccess', _20 => _20.chromadb]) },
538
+ { class: _instrumentationqdrant.QdrantInstrumentation, name: "Qdrant", module: _optionalChain([this, 'access', _21 => _21.manualModules, 'optionalAccess', _22 => _22.qdrant]) },
539
+ { class: _instrumentationtogether.TogetherInstrumentation, name: "Together", module: _optionalChain([this, 'access', _23 => _23.manualModules, 'optionalAccess', _24 => _24.together]) }
452
540
  ];
453
541
  for (const config of instrumentationConfigs) {
454
542
  if (!config.module) {
@@ -464,13 +552,14 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
464
552
  instrumentations.push(instrumentation);
465
553
  }
466
554
  }
467
- if (_optionalChain([this, 'access', _23 => _23.manualModules, 'optionalAccess', _24 => _24.langchain, 'optionalAccess', _25 => _25.callbackManagerModule])) {
555
+ if (_optionalChain([this, 'access', _25 => _25.manualModules, 'optionalAccess', _26 => _26.langchain, 'optionalAccess', _27 => _27.callbackManagerModule])) {
468
556
  const callbackManagerModule = this.manualModules.langchain.callbackManagerModule;
469
557
  void (async () => {
470
558
  try {
471
559
  const { LangChainInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("@arizeai/openinference-instrumentation-langchain")));
472
560
  const lcInst = new LangChainInstrumentation();
473
561
  lcInst.manuallyInstrument(callbackManagerModule);
562
+ patchCallbackManagerModule(callbackManagerModule);
474
563
  _chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for LangChain");
475
564
  } catch (error) {
476
565
  _chunkWC573FCIcjs.logger.error(
@@ -479,7 +568,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
479
568
  }
480
569
  })();
481
570
  }
482
- if (_optionalChain([this, 'access', _26 => _26.manualModules, 'optionalAccess', _27 => _27.google_vertexai])) {
571
+ if (_optionalChain([this, 'access', _28 => _28.manualModules, 'optionalAccess', _29 => _29.google_vertexai])) {
483
572
  const vertexModule = this.manualModules.google_vertexai;
484
573
  void (async () => {
485
574
  try {
@@ -494,7 +583,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
494
583
  }
495
584
  })();
496
585
  }
497
- if (_optionalChain([this, 'access', _28 => _28.manualModules, 'optionalAccess', _29 => _29.google_genai])) {
586
+ if (_optionalChain([this, 'access', _30 => _30.manualModules, 'optionalAccess', _31 => _31.google_genai])) {
498
587
  const genaiModule = this.manualModules.google_genai;
499
588
  void (async () => {
500
589
  try {
@@ -509,11 +598,11 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
509
598
  }
510
599
  })();
511
600
  }
512
- if (_optionalChain([this, 'access', _30 => _30.manualModules, 'optionalAccess', _31 => _31.mcp])) {
601
+ if (_optionalChain([this, 'access', _32 => _32.manualModules, 'optionalAccess', _33 => _33.mcp])) {
513
602
  const mcpModules = this.manualModules.mcp;
514
603
  void (async () => {
515
604
  try {
516
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-5FSUXYHM.cjs")));
605
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-CCFYA5CI.cjs")));
517
606
  const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
518
607
  instrumentation.manuallyInstrument(mcpModules);
519
608
  _chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
@@ -565,7 +654,7 @@ function setCurrentSpanCustomProperties(properties) {
565
654
  for (const [key, value] of Object.entries(properties)) {
566
655
  try {
567
656
  current.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
568
- } catch (e2) {
657
+ } catch (e3) {
569
658
  }
570
659
  }
571
660
  }
@@ -589,15 +678,15 @@ function withProperties(properties, fn, thisArg) {
589
678
  function propagatePropertiesImperatively(properties, base = _api.context.active()) {
590
679
  try {
591
680
  const manager = _api.context;
592
- const mgr = _optionalChain([manager, 'access', _32 => _32._getContextManager, 'optionalCall', _33 => _33()]);
593
- const store = _optionalChain([mgr, 'optionalAccess', _34 => _34._asyncLocalStorage]);
681
+ const mgr = _optionalChain([manager, 'access', _34 => _34._getContextManager, 'optionalCall', _35 => _35()]);
682
+ const store = _optionalChain([mgr, 'optionalAccess', _36 => _36._asyncLocalStorage]);
594
683
  if (!store || typeof store.enterWith !== "function") {
595
684
  return;
596
685
  }
597
686
  const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
598
687
  const merged = prev ? { ...prev, ...properties } : properties;
599
688
  store.enterWith(base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged));
600
- } catch (e3) {
689
+ } catch (e4) {
601
690
  }
602
691
  }
603
692
  function setUser(user) {
@@ -691,7 +780,7 @@ function withServiceName(name, fn, thisArg) {
691
780
  }
692
781
  function resolveServiceNameFromContext() {
693
782
  const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
694
- return _optionalChain([props, 'optionalAccess', _35 => _35[_chunk5WBPX342cjs.SERVICE_NAME]]);
783
+ return _optionalChain([props, 'optionalAccess', _37 => _37[_chunk5WBPX342cjs.SERVICE_NAME]]);
695
784
  }
696
785
  function userProperties(user) {
697
786
  const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
@@ -758,7 +847,7 @@ function withMessageId(id, fn, thisArg) {
758
847
  }
759
848
  function inheritedMuteTools() {
760
849
  const properties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
761
- return _optionalChain([properties, 'optionalAccess', _36 => _36[_chunk5WBPX342cjs.MUTE_TOOLS]]);
850
+ return _optionalChain([properties, 'optionalAccess', _38 => _38[_chunk5WBPX342cjs.MUTE_TOOLS]]);
762
851
  }
763
852
  function muteProperties(options) {
764
853
  const { input = true, output = true, tools = output } = options;
@@ -817,9 +906,9 @@ var Session = (_class2 = class {
817
906
  * @param text - Text to append (null becomes a null/"hide marker")
818
907
  * @param context - Optional per-turn context bag to attach to this turn
819
908
  */
820
- setInput(text, context5) {
909
+ setInput(text, context6) {
821
910
  this.inputs.push(text);
822
- this.inputContexts.push(_nullishCoalesce(context5, () => ( {})));
911
+ this.inputContexts.push(_nullishCoalesce(context6, () => ( {})));
823
912
  this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT, JSON.stringify(this.inputs));
824
913
  this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
825
914
  }
@@ -833,9 +922,9 @@ var Session = (_class2 = class {
833
922
  * @param text - Text to append (null becomes a null/"hide marker")
834
923
  * @param context - Optional per-turn context bag to attach to this turn
835
924
  */
836
- setOutput(text, context5) {
925
+ setOutput(text, context6) {
837
926
  this.outputs.push(text);
838
- this.outputContexts.push(_nullishCoalesce(context5, () => ( {})));
927
+ this.outputContexts.push(_nullishCoalesce(context6, () => ( {})));
839
928
  this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
840
929
  this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
841
930
  }
@@ -920,7 +1009,7 @@ var Session = (_class2 = class {
920
1009
  * (free-form category, defaults to `'generic'`)
921
1010
  */
922
1011
  addExternalLink(url, options) {
923
- emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _37 => _37.title]), _optionalChain([options, 'optionalAccess', _38 => _38.linkType]));
1012
+ emitExternalLink(this.sessionId, url, _optionalChain([options, 'optionalAccess', _39 => _39.title]), _optionalChain([options, 'optionalAccess', _40 => _40.linkType]));
924
1013
  }
925
1014
  }, _class2);
926
1015
  var SessionTitle = class {
@@ -946,11 +1035,11 @@ function resolveSessionIdFromContext() {
946
1035
  return active.sessionId;
947
1036
  }
948
1037
  const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
949
- return _optionalChain([props, 'optionalAccess', _39 => _39[_chunk5WBPX342cjs.SESSION_ID]]);
1038
+ return _optionalChain([props, 'optionalAccess', _41 => _41[_chunk5WBPX342cjs.SESSION_ID]]);
950
1039
  }
951
1040
  function resolveMessageIdFromContext() {
952
1041
  const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
953
- return _optionalChain([props, 'optionalAccess', _40 => _40[_chunk5WBPX342cjs.MESSAGE_ID]]);
1042
+ return _optionalChain([props, 'optionalAccess', _42 => _42[_chunk5WBPX342cjs.MESSAGE_ID]]);
954
1043
  }
955
1044
  function emitExternalLink(sessionId, url, title, linkType) {
956
1045
  try {
@@ -964,30 +1053,30 @@ function emitExternalLink(sessionId, url, title, linkType) {
964
1053
  }
965
1054
  }
966
1055
  function addExternalLink(url, options) {
967
- const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _41 => _41.sessionId]), () => ( resolveSessionIdFromContext()));
1056
+ const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _43 => _43.sessionId]), () => ( resolveSessionIdFromContext()));
968
1057
  if (!sessionId) {
969
1058
  _chunkWC573FCIcjs.logger.warn(
970
1059
  "addExternalLink called without a resolvable session id; link dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope."
971
1060
  );
972
1061
  return;
973
1062
  }
974
- emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _42 => _42.title]), _optionalChain([options, 'optionalAccess', _43 => _43.linkType]));
1063
+ emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _44 => _44.title]), _optionalChain([options, 'optionalAccess', _45 => _45.linkType]));
975
1064
  }
976
1065
  function recordFeedback(type, options) {
977
1066
  const eventAttributes = { [_chunk5WBPX342cjs.FEEDBACK_TYPE]: type };
978
- if (_optionalChain([options, 'optionalAccess', _44 => _44.score]) !== void 0) {
1067
+ if (_optionalChain([options, 'optionalAccess', _46 => _46.score]) !== void 0) {
979
1068
  eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SCORE] = options.score;
980
1069
  }
981
- if (_optionalChain([options, 'optionalAccess', _45 => _45.reason]) !== void 0) {
1070
+ if (_optionalChain([options, 'optionalAccess', _47 => _47.reason]) !== void 0) {
982
1071
  eventAttributes[_chunk5WBPX342cjs.FEEDBACK_REASON] = options.reason;
983
1072
  }
984
- if (_optionalChain([options, 'optionalAccess', _46 => _46.comment]) !== void 0) {
1073
+ if (_optionalChain([options, 'optionalAccess', _48 => _48.comment]) !== void 0) {
985
1074
  eventAttributes[_chunk5WBPX342cjs.FEEDBACK_COMMENT] = options.comment;
986
1075
  }
987
- if (_optionalChain([options, 'optionalAccess', _47 => _47.source]) !== void 0) {
1076
+ if (_optionalChain([options, 'optionalAccess', _49 => _49.source]) !== void 0) {
988
1077
  eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SOURCE] = options.source;
989
1078
  }
990
- if (_optionalChain([options, 'optionalAccess', _48 => _48.attributes])) {
1079
+ if (_optionalChain([options, 'optionalAccess', _50 => _50.attributes])) {
991
1080
  for (const [key, value] of Object.entries(options.attributes)) {
992
1081
  const k = `${_chunk5WBPX342cjs.FEEDBACK_ATTR_PREFIX}${key}`;
993
1082
  if (eventAttributes[k] === void 0) {
@@ -995,8 +1084,8 @@ function recordFeedback(type, options) {
995
1084
  }
996
1085
  }
997
1086
  }
998
- const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _49 => _49.messageId]), () => ( resolveMessageIdFromContext()));
999
- const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _50 => _50.sessionId]), () => ( resolveSessionIdFromContext()));
1087
+ const messageId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _51 => _51.messageId]), () => ( resolveMessageIdFromContext()));
1088
+ const sessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _52 => _52.sessionId]), () => ( resolveSessionIdFromContext()));
1000
1089
  if (messageId === void 0 && sessionId === void 0) {
1001
1090
  _chunkWC573FCIcjs.logger.warn(
1002
1091
  "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 +1116,7 @@ function recordMetric(options) {
1027
1116
  try {
1028
1117
  recordMetricImpl(options);
1029
1118
  } catch (error) {
1030
- _chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess', _51 => _51.name]))}) failed; metric dropped.`, error);
1119
+ _chunkWC573FCIcjs.logger.warn(`recordMetric(${JSON.stringify(_optionalChain([options, 'optionalAccess', _53 => _53.name]))}) failed; metric dropped.`, error);
1031
1120
  }
1032
1121
  }
1033
1122
  function recordMetricImpl(options) {
@@ -1142,7 +1231,7 @@ function recordMetricImpl(options) {
1142
1231
  }
1143
1232
  }
1144
1233
  function startSession(sessionId, callback, extraProperties, options) {
1145
- const isTitle = _optionalChain([options, 'optionalAccess', _52 => _52.mode]) === "title";
1234
+ const isTitle = _optionalChain([options, 'optionalAccess', _54 => _54.mode]) === "title";
1146
1235
  const spanName = isTitle ? _chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME : _chunk5WBPX342cjs.SESSION_SPAN_NAME;
1147
1236
  const tracer = _api.trace.getTracer("@brizz/sdk");
1148
1237
  return tracer.startActiveSpan(spanName, (span) => {
@@ -1191,7 +1280,7 @@ function startSession(sessionId, callback, extraProperties, options) {
1191
1280
  });
1192
1281
  }
1193
1282
  function startSessionTitle(callback, options) {
1194
- const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _53 => _53.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _54 => _54(), 'optionalAccess', _55 => _55.sessionId])));
1283
+ const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _55 => _55.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _56 => _56(), 'optionalAccess', _57 => _57.sessionId])));
1195
1284
  const tracer = _api.trace.getTracer("@brizz/sdk");
1196
1285
  return tracer.startActiveSpan(_chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1197
1286
  if (resolvedSessionId) {
@@ -1663,7 +1752,7 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
1663
1752
  this.config = config;
1664
1753
  }
1665
1754
  onEmit(logRecord) {
1666
- const maskingConfig = _optionalChain([this, 'access', _56 => _56.config, 'access', _57 => _57.masking, 'optionalAccess', _58 => _58.eventMasking]);
1755
+ const maskingConfig = _optionalChain([this, 'access', _58 => _58.config, 'access', _59 => _59.masking, 'optionalAccess', _60 => _60.eventMasking]);
1667
1756
  if (maskingConfig) {
1668
1757
  maskLog(logRecord, maskingConfig);
1669
1758
  }
@@ -1683,7 +1772,7 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
1683
1772
  this.config = config;
1684
1773
  }
1685
1774
  onEmit(logRecord) {
1686
- const maskingConfig = _optionalChain([this, 'access', _59 => _59.config, 'access', _60 => _60.masking, 'optionalAccess', _61 => _61.eventMasking]);
1775
+ const maskingConfig = _optionalChain([this, 'access', _61 => _61.config, 'access', _62 => _62.masking, 'optionalAccess', _63 => _63.eventMasking]);
1687
1776
  if (maskingConfig) {
1688
1777
  maskLog(logRecord, maskingConfig);
1689
1778
  }
@@ -1775,14 +1864,14 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
1775
1864
  _chunkWC573FCIcjs.logger.debug("Creating logger provider", {
1776
1865
  serviceName,
1777
1866
  disableBatch: config.disableBatch,
1778
- hasMasking: !!_optionalChain([config, 'access', _62 => _62.masking, 'optionalAccess', _63 => _63.eventMasking])
1867
+ hasMasking: !!_optionalChain([config, 'access', _64 => _64.masking, 'optionalAccess', _65 => _65.eventMasking])
1779
1868
  });
1780
1869
  const exporter = this.createLogExporter(config, serviceName);
1781
1870
  const processor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(exporter, config) : new BrizzBatchLogRecordProcessor(exporter, config);
1782
1871
  const resourceAttributes = {
1783
1872
  ...config.resourceAttributes,
1784
1873
  "service.name": serviceName,
1785
- [BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
1874
+ [BRIZZ_SDK_VERSION]: _chunkCBEDIRVKcjs.getSDKVersion.call(void 0, ),
1786
1875
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
1787
1876
  };
1788
1877
  if (config.environment) {
@@ -2031,7 +2120,7 @@ var BrizzSpanExporter = (_class5 = class {
2031
2120
  const resourceAttrs = {
2032
2121
  ...config.resourceAttributes,
2033
2122
  "service.name": config.appName,
2034
- [BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
2123
+ [BRIZZ_SDK_VERSION]: _chunkCBEDIRVKcjs.getSDKVersion.call(void 0, ),
2035
2124
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2036
2125
  };
2037
2126
  if (config.environment) {
@@ -2158,8 +2247,8 @@ var BrizzSpanExporter = (_class5 = class {
2158
2247
  }
2159
2248
  async forceFlush() {
2160
2249
  await Promise.all([
2161
- _optionalChain([this, 'access', _64 => _64._delegate, 'access', _65 => _65.forceFlush, 'optionalCall', _66 => _66()]),
2162
- ...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _67 => _67.forceFlush, 'optionalCall', _68 => _68()]))
2250
+ _optionalChain([this, 'access', _66 => _66._delegate, 'access', _67 => _67.forceFlush, 'optionalCall', _68 => _68()]),
2251
+ ...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _69 => _69.forceFlush, 'optionalCall', _70 => _70()]))
2163
2252
  ]);
2164
2253
  }
2165
2254
  }, _class5);
@@ -2195,7 +2284,8 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
2195
2284
  super.onStart(span, parentContext);
2196
2285
  }
2197
2286
  onEnd(span) {
2198
- const maskingConfig = _optionalChain([this, 'access', _69 => _69.config, 'access', _70 => _70.masking, 'optionalAccess', _71 => _71.spanMasking]);
2287
+ restampLangChainSpan(span);
2288
+ const maskingConfig = _optionalChain([this, 'access', _71 => _71.config, 'access', _72 => _72.masking, 'optionalAccess', _73 => _73.spanMasking]);
2199
2289
  if (maskingConfig) {
2200
2290
  maskReadableSpan(span, maskingConfig);
2201
2291
  }
@@ -2213,7 +2303,8 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
2213
2303
  super.onStart(span, parentContext);
2214
2304
  }
2215
2305
  onEnd(span) {
2216
- const maskingConfig = _optionalChain([this, 'access', _72 => _72.config, 'access', _73 => _73.masking, 'optionalAccess', _74 => _74.spanMasking]);
2306
+ restampLangChainSpan(span);
2307
+ const maskingConfig = _optionalChain([this, 'access', _74 => _74.config, 'access', _75 => _75.masking, 'optionalAccess', _76 => _76.spanMasking]);
2217
2308
  if (maskingConfig) {
2218
2309
  maskReadableSpan(span, maskingConfig);
2219
2310
  }
@@ -2300,7 +2391,7 @@ var TracingModule = (_class6 = class _TracingModule {constructor() { _class6.pro
2300
2391
  }
2301
2392
  _chunkWC573FCIcjs.logger.debug("Initializing span processor", {
2302
2393
  disableBatch: config.disableBatch,
2303
- hasMasking: !!_optionalChain([config, 'access', _75 => _75.masking, 'optionalAccess', _76 => _76.spanMasking])
2394
+ hasMasking: !!_optionalChain([config, 'access', _77 => _77.masking, 'optionalAccess', _78 => _78.spanMasking])
2304
2395
  });
2305
2396
  const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
2306
2397
  _chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
@@ -2387,7 +2478,7 @@ function currentTraceparent() {
2387
2478
  const carrier = {};
2388
2479
  try {
2389
2480
  _api.propagation.inject(_api.context.active(), carrier);
2390
- } catch (e4) {
2481
+ } catch (e5) {
2391
2482
  }
2392
2483
  return _nullishCoalesce(carrier["traceparent"], () => ( ""));
2393
2484
  }
@@ -2410,7 +2501,7 @@ function decodeToken(token) {
2410
2501
  try {
2411
2502
  const payload = JSON.parse(Buffer.from(token, "base64url").toString("utf8"));
2412
2503
  return payload.id ? payload : void 0;
2413
- } catch (e5) {
2504
+ } catch (e6) {
2414
2505
  return void 0;
2415
2506
  }
2416
2507
  }
@@ -2448,7 +2539,7 @@ function resolveAgent(agent) {
2448
2539
  if (decoded.traceparent) {
2449
2540
  try {
2450
2541
  parentContext = _api.propagation.extract(parentContext, { traceparent: decoded.traceparent });
2451
- } catch (e6) {
2542
+ } catch (e7) {
2452
2543
  }
2453
2544
  }
2454
2545
  }
@@ -2520,7 +2611,8 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2520
2611
  */
2521
2612
  setupInstrumentation(options) {
2522
2613
  const registry = InstrumentationRegistry.getInstance();
2523
- _chunkA3HH5OULcjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
2614
+ _chunkCBEDIRVKcjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
2615
+ patchInstalledCallbackManager();
2524
2616
  if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
2525
2617
  registry.setManualModules(options.instrumentModules);
2526
2618
  }
@@ -2543,7 +2635,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2543
2635
  const resourceAttributes = {
2544
2636
  ...resolvedConfig.resourceAttributes,
2545
2637
  "service.name": resolvedConfig.appName,
2546
- [BRIZZ_SDK_VERSION]: _chunkA3HH5OULcjs.getSDKVersion.call(void 0, ),
2638
+ [BRIZZ_SDK_VERSION]: _chunkCBEDIRVKcjs.getSDKVersion.call(void 0, ),
2547
2639
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2548
2640
  };
2549
2641
  if (resolvedConfig.environment) {
@@ -2613,19 +2705,19 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2613
2705
  try {
2614
2706
  const tracingModule = TracingModule.getInstance();
2615
2707
  await tracingModule.shutdown();
2616
- } catch (e7) {
2708
+ } catch (e8) {
2617
2709
  _chunkWC573FCIcjs.logger.debug("Tracing module already shut down or not initialized");
2618
2710
  }
2619
2711
  try {
2620
2712
  const metricsModule = MetricsModule.getInstance();
2621
2713
  metricsModule.shutdown();
2622
- } catch (e8) {
2714
+ } catch (e9) {
2623
2715
  _chunkWC573FCIcjs.logger.debug("Metrics module already shut down or not initialized");
2624
2716
  }
2625
2717
  try {
2626
2718
  const loggingModule = LoggingModule.getInstance();
2627
2719
  await loggingModule.shutdown();
2628
- } catch (e9) {
2720
+ } catch (e10) {
2629
2721
  _chunkWC573FCIcjs.logger.debug("Logging module already shut down or not initialized");
2630
2722
  }
2631
2723
  _chunkWC573FCIcjs.logger.info("All telemetry modules shut down successfully");
@@ -2691,10 +2783,10 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2691
2783
  }
2692
2784
  try {
2693
2785
  await this.shutdownModules();
2694
- await _optionalChain([this, 'access', _77 => _77._tracerProvider, 'optionalAccess', _78 => _78.forceFlush, 'call', _79 => _79()]);
2695
- await _optionalChain([this, 'access', _80 => _80._tracerProvider, 'optionalAccess', _81 => _81.shutdown, 'call', _82 => _82()]);
2696
- await _optionalChain([this, 'access', _83 => _83._meterProvider, 'optionalAccess', _84 => _84.forceFlush, 'call', _85 => _85()]);
2697
- await _optionalChain([this, 'access', _86 => _86._meterProvider, 'optionalAccess', _87 => _87.shutdown, 'call', _88 => _88()]);
2786
+ await _optionalChain([this, 'access', _79 => _79._tracerProvider, 'optionalAccess', _80 => _80.forceFlush, 'call', _81 => _81()]);
2787
+ await _optionalChain([this, 'access', _82 => _82._tracerProvider, 'optionalAccess', _83 => _83.shutdown, 'call', _84 => _84()]);
2788
+ await _optionalChain([this, 'access', _85 => _85._meterProvider, 'optionalAccess', _86 => _86.forceFlush, 'call', _87 => _87()]);
2789
+ await _optionalChain([this, 'access', _88 => _88._meterProvider, 'optionalAccess', _89 => _89.shutdown, 'call', _90 => _90()]);
2698
2790
  this._initialized = false;
2699
2791
  this._tracerProvider = null;
2700
2792
  this._meterProvider = null;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  configure,
7
7
  getSDKVersion
8
- } from "./chunk-AELIATPI.js";
8
+ } from "./chunk-BAQTZKGI.js";
9
9
  import {
10
10
  DEFAULT_LOG_LEVEL,
11
11
  LogLevel,
@@ -130,7 +130,7 @@ function loadGenAIInstrumentations() {
130
130
  function loadMCPInstrumentation() {
131
131
  void (async () => {
132
132
  try {
133
- const { MCPInstrumentation } = await import("./mcp-7EJXVCPI.js");
133
+ const { MCPInstrumentation } = await import("./mcp-FTYCIWL4.js");
134
134
  const mcp = new MCPInstrumentation({ exceptionLogger });
135
135
  registerInstrumentations({ instrumentations: [mcp] });
136
136
  logger.debug("Auto-loaded MCP instrumentation");
@@ -394,6 +394,94 @@ import { LlamaIndexInstrumentation as LlamaIndexInstrumentation2 } from "@tracel
394
394
  import { PineconeInstrumentation as PineconeInstrumentation2 } from "@traceloop/instrumentation-pinecone";
395
395
  import { QdrantInstrumentation as QdrantInstrumentation2 } from "@traceloop/instrumentation-qdrant";
396
396
  import { TogetherInstrumentation as TogetherInstrumentation2 } from "@traceloop/instrumentation-together";
397
+
398
+ // src/internal/instrumentation/langchain.ts
399
+ import { context } from "@opentelemetry/api";
400
+ var SCOPE_NAME = "@arizeai/openinference-instrumentation-langchain";
401
+ var PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.callbackManagerPatched");
402
+ var OMITTED_KEYS = /* @__PURE__ */ new Set([
403
+ USER_EMAIL,
404
+ USER_NAME,
405
+ ORGANIZATION_NAME,
406
+ ORGANIZATION_DOMAIN
407
+ ]);
408
+ function runMetadataFromContext() {
409
+ const bag = context.active().getValue(PROPERTIES_CONTEXT_KEY);
410
+ if (!bag) {
411
+ return void 0;
412
+ }
413
+ const metadata = {};
414
+ for (const [name, value] of Object.entries(bag)) {
415
+ if (!OMITTED_KEYS.has(name)) {
416
+ metadata[`${BRIZZ}.${name}`] = String(value);
417
+ }
418
+ }
419
+ return Object.keys(metadata).length > 0 ? metadata : void 0;
420
+ }
421
+ function patchCallbackManagerModule(module2) {
422
+ const callbackManager = module2?.CallbackManager;
423
+ if (callbackManager === null || typeof callbackManager !== "function" && typeof callbackManager !== "object") {
424
+ return false;
425
+ }
426
+ const statics = callbackManager;
427
+ if (statics[PATCHED_MARKER] === true) {
428
+ return false;
429
+ }
430
+ const key = "_configureSync" in statics ? "_configureSync" : "configure";
431
+ const original = statics[key];
432
+ if (typeof original !== "function") {
433
+ return false;
434
+ }
435
+ const configure2 = original;
436
+ statics[key] = function(...args) {
437
+ const manager = configure2.apply(this, args);
438
+ try {
439
+ const metadata = runMetadataFromContext();
440
+ if (manager && metadata) {
441
+ manager.addMetadata(metadata);
442
+ }
443
+ } catch {
444
+ }
445
+ return manager;
446
+ };
447
+ statics[PATCHED_MARKER] = true;
448
+ return true;
449
+ }
450
+ function patchInstalledCallbackManager() {
451
+ void (async () => {
452
+ try {
453
+ patchCallbackManagerModule(await import("@langchain/core/callbacks/manager"));
454
+ } catch (error) {
455
+ logger.debug(`LangChain callback manager not patched: ${String(error)}`);
456
+ }
457
+ })();
458
+ }
459
+ function restampLangChainSpan(span) {
460
+ try {
461
+ const scope = span.instrumentationScope;
462
+ if (scope?.name !== SCOPE_NAME) {
463
+ return;
464
+ }
465
+ const attrs = span.attributes;
466
+ const metadata = attrs["metadata"];
467
+ if (typeof metadata !== "string" || !metadata.includes(`"${BRIZZ}.`)) {
468
+ return;
469
+ }
470
+ const parsed = JSON.parse(metadata);
471
+ if (typeof parsed !== "object" || parsed === null) {
472
+ return;
473
+ }
474
+ for (const [key, value] of Object.entries(parsed)) {
475
+ if (key.startsWith(`${BRIZZ}.`) && value !== null && value !== void 0) {
476
+ attrs[key] = String(value);
477
+ }
478
+ }
479
+ } catch (error) {
480
+ logger.debug("Skipped LangChain span re-stamp", { err: error });
481
+ }
482
+ }
483
+
484
+ // src/internal/instrumentation/registry.ts
397
485
  var InstrumentationRegistry = class _InstrumentationRegistry {
398
486
  static instance;
399
487
  static getInstance() {
@@ -471,6 +559,7 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
471
559
  const { LangChainInstrumentation } = await import("@arizeai/openinference-instrumentation-langchain");
472
560
  const lcInst = new LangChainInstrumentation();
473
561
  lcInst.manuallyInstrument(callbackManagerModule);
562
+ patchCallbackManagerModule(callbackManagerModule);
474
563
  logger.debug("Manual instrumentation enabled for LangChain");
475
564
  } catch (error) {
476
565
  logger.error(
@@ -513,7 +602,7 @@ var InstrumentationRegistry = class _InstrumentationRegistry {
513
602
  const mcpModules = this.manualModules.mcp;
514
603
  void (async () => {
515
604
  try {
516
- const { MCPInstrumentation } = await import("./mcp-7EJXVCPI.js");
605
+ const { MCPInstrumentation } = await import("./mcp-FTYCIWL4.js");
517
606
  const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
518
607
  instrumentation.manuallyInstrument(mcpModules);
519
608
  logger.debug("Manual instrumentation enabled for MCP");
@@ -556,7 +645,7 @@ import { resourceFromAttributes } from "@opentelemetry/resources";
556
645
  import { LoggerProvider } from "@opentelemetry/sdk-logs";
557
646
 
558
647
  // src/internal/trace/session.ts
559
- import { context, trace, SpanStatusCode } from "@opentelemetry/api";
648
+ import { context as context2, trace, SpanStatusCode } from "@opentelemetry/api";
560
649
  function setCurrentSpanCustomProperties(properties) {
561
650
  const current = trace.getActiveSpan();
562
651
  if (!current || !current.isRecording()) {
@@ -570,11 +659,11 @@ function setCurrentSpanCustomProperties(properties) {
570
659
  }
571
660
  }
572
661
  function callWithProperties(properties, fn, thisArg, ...args) {
573
- const base = context.active();
662
+ const base = context2.active();
574
663
  const prev = base.getValue(PROPERTIES_CONTEXT_KEY);
575
664
  const merged = prev ? { ...prev, ...properties } : properties;
576
665
  const next = base.setValue(PROPERTIES_CONTEXT_KEY, merged);
577
- return context.with(next, fn, thisArg, ...args);
666
+ return context2.with(next, fn, thisArg, ...args);
578
667
  }
579
668
  function withProperties(properties, fn, thisArg) {
580
669
  return function wrapped(...args) {
@@ -586,9 +675,9 @@ function withProperties(properties, fn, thisArg) {
586
675
  );
587
676
  };
588
677
  }
589
- function propagatePropertiesImperatively(properties, base = context.active()) {
678
+ function propagatePropertiesImperatively(properties, base = context2.active()) {
590
679
  try {
591
- const manager = context;
680
+ const manager = context2;
592
681
  const mgr = manager._getContextManager?.();
593
682
  const store = mgr?._asyncLocalStorage;
594
683
  if (!store || typeof store.enterWith !== "function") {
@@ -690,7 +779,7 @@ function withServiceName(name, fn, thisArg) {
690
779
  return withProperties(serviceNameProperties(name), fn, thisArg);
691
780
  }
692
781
  function resolveServiceNameFromContext() {
693
- const props = context.active().getValue(PROPERTIES_CONTEXT_KEY);
782
+ const props = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
694
783
  return props?.[SERVICE_NAME];
695
784
  }
696
785
  function userProperties(user) {
@@ -757,7 +846,7 @@ function withMessageId(id, fn, thisArg) {
757
846
  return withProperties({ [MESSAGE_ID]: id }, fn, thisArg);
758
847
  }
759
848
  function inheritedMuteTools() {
760
- const properties = context.active().getValue(PROPERTIES_CONTEXT_KEY);
849
+ const properties = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
761
850
  return properties?.[MUTE_TOOLS];
762
851
  }
763
852
  function muteProperties(options) {
@@ -817,9 +906,9 @@ var Session = class {
817
906
  * @param text - Text to append (null becomes a null/"hide marker")
818
907
  * @param context - Optional per-turn context bag to attach to this turn
819
908
  */
820
- setInput(text, context5) {
909
+ setInput(text, context6) {
821
910
  this.inputs.push(text);
822
- this.inputContexts.push(context5 ?? {});
911
+ this.inputContexts.push(context6 ?? {});
823
912
  this.span.setAttribute(SESSION_INPUT, JSON.stringify(this.inputs));
824
913
  this.span.setAttribute(SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
825
914
  }
@@ -833,9 +922,9 @@ var Session = class {
833
922
  * @param text - Text to append (null becomes a null/"hide marker")
834
923
  * @param context - Optional per-turn context bag to attach to this turn
835
924
  */
836
- setOutput(text, context5) {
925
+ setOutput(text, context6) {
837
926
  this.outputs.push(text);
838
- this.outputContexts.push(context5 ?? {});
927
+ this.outputContexts.push(context6 ?? {});
839
928
  this.span.setAttribute(SESSION_OUTPUT, JSON.stringify(this.outputs));
840
929
  this.span.setAttribute(SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
841
930
  }
@@ -938,18 +1027,18 @@ var SessionTitle = class {
938
1027
  }
939
1028
  };
940
1029
  function getActiveSession() {
941
- return context.active().getValue(SESSION_OBJECT_CONTEXT_KEY);
1030
+ return context2.active().getValue(SESSION_OBJECT_CONTEXT_KEY);
942
1031
  }
943
1032
  function resolveSessionIdFromContext() {
944
1033
  const active = getActiveSession();
945
1034
  if (active) {
946
1035
  return active.sessionId;
947
1036
  }
948
- const props = context.active().getValue(PROPERTIES_CONTEXT_KEY);
1037
+ const props = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
949
1038
  return props?.[SESSION_ID];
950
1039
  }
951
1040
  function resolveMessageIdFromContext() {
952
- const props = context.active().getValue(PROPERTIES_CONTEXT_KEY);
1041
+ const props = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
953
1042
  return props?.[MESSAGE_ID];
954
1043
  }
955
1044
  function emitExternalLink(sessionId, url, title, linkType) {
@@ -1163,8 +1252,8 @@ function startSession(sessionId, callback, extraProperties, options) {
1163
1252
  }
1164
1253
  }
1165
1254
  return callWithProperties(contextProperties, () => {
1166
- const sessionCtx = context.active().setValue(SESSION_OBJECT_CONTEXT_KEY, session);
1167
- return context.with(sessionCtx, () => {
1255
+ const sessionCtx = context2.active().setValue(SESSION_OBJECT_CONTEXT_KEY, session);
1256
+ return context2.with(sessionCtx, () => {
1168
1257
  try {
1169
1258
  const result = callback(session);
1170
1259
  if (result && typeof result.then === "function") {
@@ -1229,7 +1318,7 @@ function startSessionTitle(callback, options) {
1229
1318
  }
1230
1319
 
1231
1320
  // src/internal/log/processors/log-processor.ts
1232
- import { context as context2 } from "@opentelemetry/api";
1321
+ import { context as context3 } from "@opentelemetry/api";
1233
1322
  import { BatchLogRecordProcessor, SimpleLogRecordProcessor } from "@opentelemetry/sdk-logs";
1234
1323
 
1235
1324
  // src/internal/masking/patterns.ts
@@ -1667,7 +1756,7 @@ var BrizzSimpleLogRecordProcessor = class extends SimpleLogRecordProcessor {
1667
1756
  if (maskingConfig) {
1668
1757
  maskLog(logRecord, maskingConfig);
1669
1758
  }
1670
- const associationProperties = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
1759
+ const associationProperties = context3.active().getValue(PROPERTIES_CONTEXT_KEY);
1671
1760
  if (associationProperties) {
1672
1761
  for (const [key, value] of Object.entries(associationProperties)) {
1673
1762
  logRecord.setAttribute(`${BRIZZ}.${key}`, value);
@@ -1687,7 +1776,7 @@ var BrizzBatchLogRecordProcessor = class extends BatchLogRecordProcessor {
1687
1776
  if (maskingConfig) {
1688
1777
  maskLog(logRecord, maskingConfig);
1689
1778
  }
1690
- const associationProperties = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
1779
+ const associationProperties = context3.active().getValue(PROPERTIES_CONTEXT_KEY);
1691
1780
  if (associationProperties) {
1692
1781
  for (const [key, value] of Object.entries(associationProperties)) {
1693
1782
  logRecord.setAttribute(`${BRIZZ}.${key}`, value);
@@ -2165,13 +2254,13 @@ var BrizzSpanExporter = class {
2165
2254
  };
2166
2255
 
2167
2256
  // src/internal/trace/processors/span-processor.ts
2168
- import { context as context3 } from "@opentelemetry/api";
2257
+ import { context as context4 } from "@opentelemetry/api";
2169
2258
  import {
2170
2259
  BatchSpanProcessor,
2171
2260
  SimpleSpanProcessor
2172
2261
  } from "@opentelemetry/sdk-trace-base";
2173
2262
  function applyContextAttributes(span) {
2174
- const sessionProperties = context3.active().getValue(PROPERTIES_CONTEXT_KEY);
2263
+ const sessionProperties = context4.active().getValue(PROPERTIES_CONTEXT_KEY);
2175
2264
  if (sessionProperties) {
2176
2265
  for (const [key, value] of Object.entries(sessionProperties)) {
2177
2266
  span.setAttribute(`${BRIZZ}.${key}`, value);
@@ -2195,6 +2284,7 @@ var BrizzSimpleSpanProcessor = class extends SimpleSpanProcessor {
2195
2284
  super.onStart(span, parentContext);
2196
2285
  }
2197
2286
  onEnd(span) {
2287
+ restampLangChainSpan(span);
2198
2288
  const maskingConfig = this.config.masking?.spanMasking;
2199
2289
  if (maskingConfig) {
2200
2290
  maskReadableSpan(span, maskingConfig);
@@ -2213,6 +2303,7 @@ var BrizzBatchSpanProcessor = class extends BatchSpanProcessor {
2213
2303
  super.onStart(span, parentContext);
2214
2304
  }
2215
2305
  onEnd(span) {
2306
+ restampLangChainSpan(span);
2216
2307
  const maskingConfig = this.config.masking?.spanMasking;
2217
2308
  if (maskingConfig) {
2218
2309
  maskReadableSpan(span, maskingConfig);
@@ -2366,12 +2457,12 @@ function getSpanProcessor() {
2366
2457
 
2367
2458
  // src/internal/trace/agent.ts
2368
2459
  import { randomUUID } from "crypto";
2369
- import { context as context4, propagation } from "@opentelemetry/api";
2460
+ import { context as context5, propagation } from "@opentelemetry/api";
2370
2461
  function newInstanceId() {
2371
2462
  return randomUUID().replaceAll("-", "").slice(0, 8);
2372
2463
  }
2373
2464
  function activeProperties() {
2374
- return context4.active().getValue(PROPERTIES_CONTEXT_KEY) ?? {};
2465
+ return context5.active().getValue(PROPERTIES_CONTEXT_KEY) ?? {};
2375
2466
  }
2376
2467
  function encodeToken(agent) {
2377
2468
  const payload = {
@@ -2386,7 +2477,7 @@ function encodeToken(agent) {
2386
2477
  function currentTraceparent() {
2387
2478
  const carrier = {};
2388
2479
  try {
2389
- propagation.inject(context4.active(), carrier);
2480
+ propagation.inject(context5.active(), carrier);
2390
2481
  } catch {
2391
2482
  }
2392
2483
  return carrier["traceparent"] ?? "";
@@ -2430,7 +2521,7 @@ function resolveAgent(agent) {
2430
2521
  let parentId;
2431
2522
  let name;
2432
2523
  let sessionId = "";
2433
- let parentContext = context4.active();
2524
+ let parentContext = context5.active();
2434
2525
  if (options.token === void 0) {
2435
2526
  id = options.id || newInstanceId();
2436
2527
  parentId = options.parentId || activeProperties()[AGENT_ID] || "";
@@ -2467,7 +2558,7 @@ function startAgent(agent, callback) {
2467
2558
  return callback(unreadableAgent(agent));
2468
2559
  }
2469
2560
  const { id, parentId, name, properties, parentContext } = resolved;
2470
- return context4.with(
2561
+ return context5.with(
2471
2562
  parentContext,
2472
2563
  () => callWithProperties(properties, () => callback(agentHandle(id, parentId, name)))
2473
2564
  );
@@ -2521,6 +2612,7 @@ var _Brizz = class __Brizz {
2521
2612
  setupInstrumentation(options) {
2522
2613
  const registry = InstrumentationRegistry.getInstance();
2523
2614
  configure(resolveMcpSessionTracking(options.mcpSessionTracking));
2615
+ patchInstalledCallbackManager();
2524
2616
  if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
2525
2617
  registry.setManualModules(options.instrumentModules);
2526
2618
  }
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- var _chunkA3HH5OULcjs = require('./chunk-A3HH5OUL.cjs');
11
+ var _chunkCBEDIRVKcjs = require('./chunk-CBEDIRVK.cjs');
12
12
 
13
13
 
14
14
  var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
@@ -387,14 +387,14 @@ function wrapOnRequest(original, tracer) {
387
387
  return original.apply(this, args);
388
388
  }
389
389
  const method = request.method;
390
- if (method === METHOD_TOOLS_CALL && _chunkA3HH5OULcjs.isSessionToolCall.call(void 0, request)) {
390
+ if (method === METHOD_TOOLS_CALL && _chunkCBEDIRVKcjs.isSessionToolCall.call(void 0, request)) {
391
391
  return answerSessionToolCall(this, request, tracer, args, original);
392
392
  }
393
393
  const handler = _nullishCoalesce(handlers.get(method), () => ( this.fallbackRequestHandler));
394
394
  if (!handler) {
395
395
  return original.apply(this, args);
396
396
  }
397
- const tracking = _chunkA3HH5OULcjs.isEnabled.call(void 0, ) && method === METHOD_TOOLS_CALL ? _chunkA3HH5OULcjs.popTrackingArguments.call(void 0, request) : {};
397
+ const tracking = _chunkCBEDIRVKcjs.isEnabled.call(void 0, ) && method === METHOD_TOOLS_CALL ? _chunkCBEDIRVKcjs.popTrackingArguments.call(void 0, request) : {};
398
398
  const started = safeStartServerSpan(tracer, request, this, tracking);
399
399
  if (!started) {
400
400
  return original.apply(this, args);
@@ -404,9 +404,9 @@ function wrapOnRequest(original, tracer) {
404
404
  if (method === METHOD_TOOLS_LIST) {
405
405
  hooks.onResult = (result) => {
406
406
  let advertised = result;
407
- if (_chunkA3HH5OULcjs.isEnabled.call(void 0, )) {
407
+ if (_chunkCBEDIRVKcjs.isEnabled.call(void 0, )) {
408
408
  try {
409
- advertised = _chunkA3HH5OULcjs.patchListToolsResult.call(void 0, result);
409
+ advertised = _chunkCBEDIRVKcjs.patchListToolsResult.call(void 0, result);
410
410
  } catch (error) {
411
411
  _chunkWC573FCIcjs.logger.warn(
412
412
  `Brizz MCP: failed to patch tools/list schemas: ${String(error)}`
@@ -417,7 +417,7 @@ function wrapOnRequest(original, tracer) {
417
417
  try {
418
418
  emitSchemaSpansFromListResponse(
419
419
  advertised,
420
- _chunkA3HH5OULcjs.resolveTransportSessionId.call(void 0, this),
420
+ _chunkCBEDIRVKcjs.resolveTransportSessionId.call(void 0, this),
421
421
  tracer
422
422
  );
423
423
  } catch (error) {
@@ -430,7 +430,7 @@ function wrapOnRequest(original, tracer) {
430
430
  }
431
431
  if (method !== METHOD_TOOLS_CALL) {
432
432
  hooks.onError = () => {
433
- _chunkA3HH5OULcjs.stampAndPropagateSession.call(void 0, span, _chunkA3HH5OULcjs.resolveSessionId.call(void 0, this, spanCtx), spanCtx);
433
+ _chunkCBEDIRVKcjs.stampAndPropagateSession.call(void 0, span, _chunkCBEDIRVKcjs.resolveSessionId.call(void 0, this, spanCtx), spanCtx);
434
434
  };
435
435
  }
436
436
  const wrappedHandler = (req, extra) => _api.context.with(
@@ -464,7 +464,7 @@ function answerSessionToolCall(protocol, request, tracer, args, original) {
464
464
  if (!handlers) {
465
465
  return original.apply(protocol, args);
466
466
  }
467
- const { id, result } = _chunkA3HH5OULcjs.sessionToolResult.call(void 0, );
467
+ const { id, result } = _chunkCBEDIRVKcjs.sessionToolResult.call(void 0, );
468
468
  const started = safeStartServerSpan(tracer, request, protocol, { sessionId: id });
469
469
  const handler = () => started ? _api.context.with(started.spanCtx, () => result) : result;
470
470
  const hadEntry = handlers.has(METHOD_TOOLS_CALL);
@@ -554,8 +554,8 @@ function safeStartServerSpan(tracer, request, protocol, tracking = {}) {
554
554
  parentCtx
555
555
  );
556
556
  applyServerRequestAttributes(span, request, protocol);
557
- const resolved = request.method === METHOD_TOOLS_CALL ? _nullishCoalesce(tracking.sessionId, () => ( _chunkA3HH5OULcjs.resolveSessionId.call(void 0, protocol, parentCtx))) : void 0;
558
- const { context: sessCtx } = _chunkA3HH5OULcjs.stampAndPropagateSession.call(void 0,
557
+ const resolved = request.method === METHOD_TOOLS_CALL ? _nullishCoalesce(tracking.sessionId, () => ( _chunkCBEDIRVKcjs.resolveSessionId.call(void 0, protocol, parentCtx))) : void 0;
558
+ const { context: sessCtx } = _chunkCBEDIRVKcjs.stampAndPropagateSession.call(void 0,
559
559
  span,
560
560
  resolved,
561
561
  parentCtx,
@@ -611,7 +611,7 @@ function safeEnd(span) {
611
611
 
612
612
  // src/internal/instrumentation/mcp/version.ts
613
613
  var INSTRUMENTATION_NAME = "@brizz/sdk/mcp";
614
- var INSTRUMENTATION_VERSION = _chunkA3HH5OULcjs.getSDKVersion.call(void 0, );
614
+ var INSTRUMENTATION_VERSION = _chunkCBEDIRVKcjs.getSDKVersion.call(void 0, );
615
615
 
616
616
  // src/internal/instrumentation/mcp/instrumentation.ts
617
617
  var PROTOCOL_MODULE_NAME = "@modelcontextprotocol/sdk/shared/protocol.js";
@@ -8,7 +8,7 @@ import {
8
8
  resolveTransportSessionId,
9
9
  sessionToolResult,
10
10
  stampAndPropagateSession
11
- } from "./chunk-AELIATPI.js";
11
+ } from "./chunk-BAQTZKGI.js";
12
12
  import {
13
13
  logger
14
14
  } from "./chunk-Y4HNUX3Q.js";
@@ -0,0 +1,4 @@
1
+ import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
2
+ export declare function patchCallbackManagerModule(module: unknown): boolean;
3
+ export declare function patchInstalledCallbackManager(): void;
4
+ export declare function restampLangChainSpan(span: ReadableSpan): void;
@@ -0,0 +1,4 @@
1
+ import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';
2
+ export declare function patchCallbackManagerModule(module: unknown): boolean;
3
+ export declare function patchInstalledCallbackManager(): void;
4
+ export declare function restampLangChainSpan(span: ReadableSpan): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brizz/sdk",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "type": "module",
5
5
  "description": "OpenTelemetry-based observability SDK for AI applications",
6
6
  "keywords": [
@@ -101,33 +101,34 @@
101
101
  "registry": "https://registry.npmjs.org/"
102
102
  },
103
103
  "devDependencies": {
104
- "@ai-sdk/anthropic": "^4.0.40",
105
- "@ai-sdk/openai": "^4.0.44",
106
- "@ai-sdk/otel": "^1.0.70",
104
+ "@ai-sdk/anthropic": "^4.0.49",
105
+ "@ai-sdk/openai": "^4.0.60",
106
+ "@ai-sdk/otel": "^1.0.93",
107
107
  "@arethetypeswrong/cli": "^0.18.5",
108
- "@arizeai/openinference-instrumentation-mcp": "^0.2.24",
108
+ "@arizeai/openinference-instrumentation-mcp": "^0.2.30",
109
109
  "@babel/core": "^8.0.1",
110
110
  "@babel/preset-env": "^8.0.2",
111
111
  "@babel/preset-typescript": "^8.0.1",
112
- "@changesets/changelog-github": "^1.0.0",
113
- "@changesets/cli": "^3.0.1",
114
- "@google/genai": "^2.18.0",
112
+ "@changesets/changelog-github": "^1.0.1",
113
+ "@changesets/cli": "^3.0.2",
114
+ "@google/genai": "^2.21.0",
115
+ "@langchain/core": "^1.1.41",
115
116
  "@modelcontextprotocol/sdk": "^1.30.0",
116
117
  "@traceloop/instrumentation-google-generativeai": "^0.27.0",
117
118
  "@traceloop/instrumentation-vertexai": "^0.27.0",
118
119
  "@types/jest": "^30.0.0",
119
- "@types/node": "^26.2.0",
120
- "ai": "^7.0.70",
121
- "babel-jest": "^30.4.1",
122
- "jest": "^30.4.2",
123
- "jest-environment-jsdom": "^30.4.1",
124
- "openai": "^7.5.0",
125
- "oxlint": "^1.79.0",
120
+ "@types/node": "^26.4.1",
121
+ "ai": "^7.0.93",
122
+ "babel-jest": "^30.5.1",
123
+ "jest": "^30.5.1",
124
+ "jest-environment-jsdom": "^30.5.1",
125
+ "openai": "^7.10.0",
126
+ "oxlint": "^1.81.0",
126
127
  "prettier": "^3.9.6",
127
128
  "tsup": "^8.5.1",
128
129
  "typescript": "^7.0.2",
129
- "vitest": "^4.1.11",
130
- "zod": "^4.4.3"
130
+ "vitest": "^5.0.0",
131
+ "zod": "^4.5.4"
131
132
  },
132
133
  "peerDependencies": {
133
134
  "@ai-sdk/otel": "^1",
@@ -166,21 +167,21 @@
166
167
  }
167
168
  },
168
169
  "dependencies": {
169
- "@arizeai/openinference-instrumentation-langchain": "^4.0.18",
170
+ "@arizeai/openinference-instrumentation-langchain": "^4.0.23",
170
171
  "@arizeai/openinference-instrumentation-openai": "^2.3.1",
171
172
  "@opentelemetry/api": "^1.9.0",
172
- "@opentelemetry/api-logs": "^0.221.0",
173
- "@opentelemetry/core": "^2.10.0",
174
- "@opentelemetry/exporter-logs-otlp-http": "^0.221.0",
175
- "@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
176
- "@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
177
- "@opentelemetry/exporter-trace-otlp-proto": "^0.221.0",
178
- "@opentelemetry/instrumentation": "^0.221.0",
179
- "@opentelemetry/resources": "^2.10.0",
180
- "@opentelemetry/sdk-logs": "^0.221.0",
181
- "@opentelemetry/sdk-metrics": "^2.10.0",
182
- "@opentelemetry/sdk-trace-base": "^2.10.0",
183
- "@opentelemetry/sdk-trace-node": "^2.10.0",
173
+ "@opentelemetry/api-logs": "^0.222.0",
174
+ "@opentelemetry/core": "^2.11.0",
175
+ "@opentelemetry/exporter-logs-otlp-http": "^0.222.0",
176
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.222.0",
177
+ "@opentelemetry/exporter-trace-otlp-http": "^0.222.0",
178
+ "@opentelemetry/exporter-trace-otlp-proto": "^0.222.0",
179
+ "@opentelemetry/instrumentation": "^0.222.0",
180
+ "@opentelemetry/resources": "^2.11.0",
181
+ "@opentelemetry/sdk-logs": "^0.222.0",
182
+ "@opentelemetry/sdk-metrics": "^2.11.0",
183
+ "@opentelemetry/sdk-trace-base": "^2.11.0",
184
+ "@opentelemetry/sdk-trace-node": "^2.11.0",
184
185
  "@opentelemetry/semantic-conventions": "^1.43.0",
185
186
  "@traceloop/ai-semantic-conventions": "^0.27.0",
186
187
  "@traceloop/instrumentation-anthropic": "^0.27.0",
@@ -198,7 +199,8 @@
198
199
  "packageManager": "pnpm@10.17.0+sha512.fce8a3dd29a4ed2ec566fb53efbb04d8c44a0f05bc6f24a73046910fb9c3ce7afa35a0980500668fa3573345bd644644fa98338fa168235c80f4aa17aa17fbef",
199
200
  "pnpm": {
200
201
  "overrides": {
201
- "@babel/core": "^8.0.1"
202
+ "@babel/core": "^8.0.1",
203
+ "@opentelemetry/core": "^2.11.0"
202
204
  },
203
205
  "updateConfig": {
204
206
  "ignoreDependencies": [