@brizz/sdk 0.1.49 → 0.1.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunkVAUO47L3cjs = require('./chunk-VAUO47L3.cjs');
8
+ var _chunkVH5N6E54cjs = require('./chunk-VH5N6E54.cjs');
9
9
 
10
10
 
11
11
 
@@ -16,7 +16,7 @@ var _chunkVAUO47L3cjs = require('./chunk-VAUO47L3.cjs');
16
16
  var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
17
17
 
18
18
 
19
- var _chunkELLCNMLIcjs = require('./chunk-ELLCNMLI.cjs');
19
+ var _chunkO2IBZJOJcjs = require('./chunk-O2IBZJOJ.cjs');
20
20
 
21
21
 
22
22
 
@@ -74,7 +74,10 @@ var _chunkELLCNMLIcjs = require('./chunk-ELLCNMLI.cjs');
74
74
 
75
75
 
76
76
 
77
- var _chunkGMZQ6N77cjs = require('./chunk-GMZQ6N77.cjs');
77
+
78
+
79
+
80
+ var _chunkRV7JIIDGcjs = require('./chunk-RV7JIIDG.cjs');
78
81
 
79
82
 
80
83
  var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
@@ -101,7 +104,7 @@ var _api = require('@opentelemetry/api');
101
104
 
102
105
  // src/internal/instrumentation/langgraph/attributes.ts
103
106
  var INSTRUMENTATION_NAME = "@brizz/sdk/langgraph";
104
- var INSTRUMENTATION_VERSION = _chunkVAUO47L3cjs.getSDKVersion.call(void 0, );
107
+ var INSTRUMENTATION_VERSION = _chunkVH5N6E54cjs.getSDKVersion.call(void 0, );
105
108
  var MODULE_NAME = "@langchain/langgraph";
106
109
  var SUPPORTED_VERSIONS = [">=0.2.0 <2"];
107
110
  function isSupportedVersion(version) {
@@ -465,7 +468,7 @@ function loadGenAIInstrumentations() {
465
468
  function loadMCPInstrumentation() {
466
469
  void (async () => {
467
470
  try {
468
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-FWGIYACB.cjs")));
471
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3URJU7OY.cjs")));
469
472
  const mcp = new MCPInstrumentation({ exceptionLogger });
470
473
  _instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
471
474
  _chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
@@ -529,7 +532,7 @@ function loadVercelAITelemetry() {
529
532
  }
530
533
  const isV7 = typeof ai.registerTelemetry === "function";
531
534
  const integrations = [];
532
- const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-YQHEXVES.cjs")));
535
+ const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-BYLSBXTV.cjs")));
533
536
  integrations.push(createInterruptIntegration());
534
537
  let otelCollectorLoaded = false;
535
538
  try {
@@ -745,20 +748,20 @@ var SDK_LANGUAGE = "typescript";
745
748
  var SCOPE_NAME = "@arizeai/openinference-instrumentation-langchain";
746
749
  var PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.callbackManagerPatched");
747
750
  var OMITTED_KEYS = /* @__PURE__ */ new Set([
748
- _chunkGMZQ6N77cjs.USER_EMAIL,
749
- _chunkGMZQ6N77cjs.USER_NAME,
750
- _chunkGMZQ6N77cjs.ORGANIZATION_NAME,
751
- _chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN
751
+ _chunkRV7JIIDGcjs.USER_EMAIL,
752
+ _chunkRV7JIIDGcjs.USER_NAME,
753
+ _chunkRV7JIIDGcjs.ORGANIZATION_NAME,
754
+ _chunkRV7JIIDGcjs.ORGANIZATION_DOMAIN
752
755
  ]);
753
756
  function runMetadataFromContext() {
754
- const bag = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
757
+ const bag = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
755
758
  if (!bag) {
756
759
  return void 0;
757
760
  }
758
761
  const metadata = {};
759
762
  for (const [name, value] of Object.entries(bag)) {
760
763
  if (!OMITTED_KEYS.has(name)) {
761
- metadata[`${_chunkGMZQ6N77cjs.BRIZZ}.${name}`] = String(value);
764
+ metadata[`${_chunkRV7JIIDGcjs.BRIZZ}.${name}`] = String(value);
762
765
  }
763
766
  }
764
767
  return Object.keys(metadata).length > 0 ? metadata : void 0;
@@ -815,7 +818,7 @@ function restampLangChainSpan(span) {
815
818
  }
816
819
  const attrs = span.attributes;
817
820
  const metadata = attrs["metadata"];
818
- if (typeof metadata !== "string" || !metadata.includes(`"${_chunkGMZQ6N77cjs.BRIZZ}.`)) {
821
+ if (typeof metadata !== "string" || !metadata.includes(`"${_chunkRV7JIIDGcjs.BRIZZ}.`)) {
819
822
  return;
820
823
  }
821
824
  const parsed = JSON.parse(metadata);
@@ -823,7 +826,7 @@ function restampLangChainSpan(span) {
823
826
  return;
824
827
  }
825
828
  for (const [key, value] of Object.entries(parsed)) {
826
- if (key.startsWith(`${_chunkGMZQ6N77cjs.BRIZZ}.`) && value !== null && value !== void 0) {
829
+ if (key.startsWith(`${_chunkRV7JIIDGcjs.BRIZZ}.`) && value !== null && value !== void 0) {
827
830
  attrs[key] = String(value);
828
831
  }
829
832
  }
@@ -961,7 +964,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
961
964
  const mcpModules = this.manualModules.mcp;
962
965
  void (async () => {
963
966
  try {
964
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-FWGIYACB.cjs")));
967
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3URJU7OY.cjs")));
965
968
  const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
966
969
  instrumentation.manuallyInstrument(mcpModules);
967
970
  _chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
@@ -1012,16 +1015,16 @@ function setCurrentSpanCustomProperties(properties) {
1012
1015
  }
1013
1016
  for (const [key, value] of Object.entries(properties)) {
1014
1017
  try {
1015
- current.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
1018
+ current.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
1016
1019
  } catch (e3) {
1017
1020
  }
1018
1021
  }
1019
1022
  }
1020
1023
  function callWithProperties(properties, fn, thisArg, ...args) {
1021
1024
  const base = _api.context.active();
1022
- const prev = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1025
+ const prev = base.getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
1023
1026
  const merged = prev ? { ...prev, ...properties } : properties;
1024
- const next = base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, merged);
1027
+ const next = base.setValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY, merged);
1025
1028
  return _api.context.with(next, fn, thisArg, ...args);
1026
1029
  }
1027
1030
  function withProperties(properties, fn, thisArg) {
@@ -1042,25 +1045,25 @@ function propagatePropertiesImperatively(properties, base = _api.context.active(
1042
1045
  if (!store || typeof store.enterWith !== "function") {
1043
1046
  return;
1044
1047
  }
1045
- const prev = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1048
+ const prev = base.getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
1046
1049
  const merged = prev ? { ...prev, ...properties } : properties;
1047
- store.enterWith(base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, merged));
1050
+ store.enterWith(base.setValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY, merged));
1048
1051
  } catch (e4) {
1049
1052
  }
1050
1053
  }
1051
1054
  function setUser(user) {
1052
- const properties = { [_chunkGMZQ6N77cjs.USER_ID]: user.id };
1055
+ const properties = { [_chunkRV7JIIDGcjs.USER_ID]: user.id };
1053
1056
  if (user.email !== void 0) {
1054
- properties[_chunkGMZQ6N77cjs.USER_EMAIL] = user.email;
1057
+ properties[_chunkRV7JIIDGcjs.USER_EMAIL] = user.email;
1055
1058
  }
1056
1059
  if (user.name !== void 0) {
1057
- properties[_chunkGMZQ6N77cjs.USER_NAME] = user.name;
1060
+ properties[_chunkRV7JIIDGcjs.USER_NAME] = user.name;
1058
1061
  }
1059
1062
  if (user.role !== void 0) {
1060
- properties[_chunkGMZQ6N77cjs.USER_ROLE] = user.role;
1063
+ properties[_chunkRV7JIIDGcjs.USER_ROLE] = user.role;
1061
1064
  }
1062
1065
  if (user.plan !== void 0) {
1063
- properties[_chunkGMZQ6N77cjs.USER_PLAN] = user.plan;
1066
+ properties[_chunkRV7JIIDGcjs.USER_PLAN] = user.plan;
1064
1067
  }
1065
1068
  if (user.traits) {
1066
1069
  for (const [key, value] of Object.entries(user.traits)) {
@@ -1074,15 +1077,15 @@ function setUser(user) {
1074
1077
  propagatePropertiesImperatively(properties);
1075
1078
  }
1076
1079
  function setOrganization(org) {
1077
- const properties = { [_chunkGMZQ6N77cjs.ORGANIZATION_ID]: org.id };
1080
+ const properties = { [_chunkRV7JIIDGcjs.ORGANIZATION_ID]: org.id };
1078
1081
  if (org.name !== void 0) {
1079
- properties[_chunkGMZQ6N77cjs.ORGANIZATION_NAME] = org.name;
1082
+ properties[_chunkRV7JIIDGcjs.ORGANIZATION_NAME] = org.name;
1080
1083
  }
1081
1084
  if (org.plan !== void 0) {
1082
- properties[_chunkGMZQ6N77cjs.ORGANIZATION_PLAN] = org.plan;
1085
+ properties[_chunkRV7JIIDGcjs.ORGANIZATION_PLAN] = org.plan;
1083
1086
  }
1084
1087
  if (org.domain !== void 0) {
1085
- properties[_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN] = org.domain;
1088
+ properties[_chunkRV7JIIDGcjs.ORGANIZATION_DOMAIN] = org.domain;
1086
1089
  }
1087
1090
  if (org.traits) {
1088
1091
  for (const [key, value] of Object.entries(org.traits)) {
@@ -1096,12 +1099,12 @@ function setOrganization(org) {
1096
1099
  propagatePropertiesImperatively(properties);
1097
1100
  }
1098
1101
  function setMessageId(id) {
1099
- const properties = { [_chunkGMZQ6N77cjs.MESSAGE_ID]: id };
1102
+ const properties = { [_chunkRV7JIIDGcjs.MESSAGE_ID]: id };
1100
1103
  setCurrentSpanCustomProperties(properties);
1101
1104
  propagatePropertiesImperatively(properties);
1102
1105
  }
1103
1106
  function setSessionId(id) {
1104
- const properties = { [_chunkGMZQ6N77cjs.SESSION_ID]: id };
1107
+ const properties = { [_chunkRV7JIIDGcjs.SESSION_ID]: id };
1105
1108
  setCurrentSpanCustomProperties(properties);
1106
1109
  propagatePropertiesImperatively(properties);
1107
1110
  }
@@ -1125,7 +1128,7 @@ function serviceNameProperties(name) {
1125
1128
  _chunkWC573FCIcjs.logger.warn(`Service name ${problem}; keeping the configured appName.`);
1126
1129
  return {};
1127
1130
  }
1128
- return { [_chunkGMZQ6N77cjs.SERVICE_NAME]: name };
1131
+ return { [_chunkRV7JIIDGcjs.SERVICE_NAME]: name };
1129
1132
  }
1130
1133
  function setServiceName(name) {
1131
1134
  const properties = serviceNameProperties(name);
@@ -1139,22 +1142,22 @@ function withServiceName(name, fn, thisArg) {
1139
1142
  return withProperties(serviceNameProperties(name), fn, thisArg);
1140
1143
  }
1141
1144
  function resolveServiceNameFromContext() {
1142
- const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1143
- return _optionalChain([props, 'optionalAccess', _56 => _56[_chunkGMZQ6N77cjs.SERVICE_NAME]]);
1145
+ const props = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
1146
+ return _optionalChain([props, 'optionalAccess', _56 => _56[_chunkRV7JIIDGcjs.SERVICE_NAME]]);
1144
1147
  }
1145
1148
  function userProperties(user) {
1146
- const properties = { [_chunkGMZQ6N77cjs.USER_ID]: user.id };
1149
+ const properties = { [_chunkRV7JIIDGcjs.USER_ID]: user.id };
1147
1150
  if (user.email !== void 0) {
1148
- properties[_chunkGMZQ6N77cjs.USER_EMAIL] = user.email;
1151
+ properties[_chunkRV7JIIDGcjs.USER_EMAIL] = user.email;
1149
1152
  }
1150
1153
  if (user.name !== void 0) {
1151
- properties[_chunkGMZQ6N77cjs.USER_NAME] = user.name;
1154
+ properties[_chunkRV7JIIDGcjs.USER_NAME] = user.name;
1152
1155
  }
1153
1156
  if (user.role !== void 0) {
1154
- properties[_chunkGMZQ6N77cjs.USER_ROLE] = user.role;
1157
+ properties[_chunkRV7JIIDGcjs.USER_ROLE] = user.role;
1155
1158
  }
1156
1159
  if (user.plan !== void 0) {
1157
- properties[_chunkGMZQ6N77cjs.USER_PLAN] = user.plan;
1160
+ properties[_chunkRV7JIIDGcjs.USER_PLAN] = user.plan;
1158
1161
  }
1159
1162
  if (user.traits) {
1160
1163
  for (const [key, value] of Object.entries(user.traits)) {
@@ -1167,15 +1170,15 @@ function userProperties(user) {
1167
1170
  return properties;
1168
1171
  }
1169
1172
  function organizationProperties(org) {
1170
- const properties = { [_chunkGMZQ6N77cjs.ORGANIZATION_ID]: org.id };
1173
+ const properties = { [_chunkRV7JIIDGcjs.ORGANIZATION_ID]: org.id };
1171
1174
  if (org.name !== void 0) {
1172
- properties[_chunkGMZQ6N77cjs.ORGANIZATION_NAME] = org.name;
1175
+ properties[_chunkRV7JIIDGcjs.ORGANIZATION_NAME] = org.name;
1173
1176
  }
1174
1177
  if (org.plan !== void 0) {
1175
- properties[_chunkGMZQ6N77cjs.ORGANIZATION_PLAN] = org.plan;
1178
+ properties[_chunkRV7JIIDGcjs.ORGANIZATION_PLAN] = org.plan;
1176
1179
  }
1177
1180
  if (org.domain !== void 0) {
1178
- properties[_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN] = org.domain;
1181
+ properties[_chunkRV7JIIDGcjs.ORGANIZATION_DOMAIN] = org.domain;
1179
1182
  }
1180
1183
  if (org.traits) {
1181
1184
  for (const [key, value] of Object.entries(org.traits)) {
@@ -1200,32 +1203,32 @@ function withOrganization(org, fn, thisArg) {
1200
1203
  return withProperties(organizationProperties(org), fn, thisArg);
1201
1204
  }
1202
1205
  function callWithMessageId(id, fn, thisArg, ...args) {
1203
- return callWithProperties({ [_chunkGMZQ6N77cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
1206
+ return callWithProperties({ [_chunkRV7JIIDGcjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
1204
1207
  }
1205
1208
  function withMessageId(id, fn, thisArg) {
1206
- return withProperties({ [_chunkGMZQ6N77cjs.MESSAGE_ID]: id }, fn, thisArg);
1209
+ return withProperties({ [_chunkRV7JIIDGcjs.MESSAGE_ID]: id }, fn, thisArg);
1207
1210
  }
1208
1211
  function inheritedMuteTools() {
1209
- const properties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1210
- return _optionalChain([properties, 'optionalAccess', _57 => _57[_chunkGMZQ6N77cjs.MUTE_TOOLS]]);
1212
+ const properties = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
1213
+ return _optionalChain([properties, 'optionalAccess', _57 => _57[_chunkRV7JIIDGcjs.MUTE_TOOLS]]);
1211
1214
  }
1212
1215
  function muteProperties(options) {
1213
1216
  const { input = true, output = true, tools = output } = options;
1214
1217
  const properties = {};
1215
1218
  if (input) {
1216
- properties[_chunkGMZQ6N77cjs.MUTE_INPUT] = "true";
1219
+ properties[_chunkRV7JIIDGcjs.MUTE_INPUT] = "true";
1217
1220
  }
1218
1221
  if (output) {
1219
- properties[_chunkGMZQ6N77cjs.MUTE_OUTPUT] = "true";
1222
+ properties[_chunkRV7JIIDGcjs.MUTE_OUTPUT] = "true";
1220
1223
  }
1221
1224
  if (tools !== output) {
1222
- properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = String(tools);
1225
+ properties[_chunkRV7JIIDGcjs.MUTE_TOOLS] = String(tools);
1223
1226
  } else {
1224
1227
  const inherited = inheritedMuteTools();
1225
1228
  if (tools && inherited === "false") {
1226
- properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = "true";
1229
+ properties[_chunkRV7JIIDGcjs.MUTE_TOOLS] = "true";
1227
1230
  } else if (options.tools === false && inherited === "true") {
1228
- properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = "false";
1231
+ properties[_chunkRV7JIIDGcjs.MUTE_TOOLS] = "false";
1229
1232
  }
1230
1233
  }
1231
1234
  return properties;
@@ -1237,11 +1240,11 @@ function withMute(options, fn, thisArg) {
1237
1240
  return withProperties(muteProperties(options), fn, thisArg);
1238
1241
  }
1239
1242
  function withSessionId(sessionId, fn, thisArg, extraProperties) {
1240
- const properties = { [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId, ...extraProperties };
1243
+ const properties = { [_chunkRV7JIIDGcjs.SESSION_ID]: sessionId, ...extraProperties };
1241
1244
  return withProperties(properties, fn, thisArg);
1242
1245
  }
1243
1246
  function callWithSessionId(sessionId, fn, thisArg, ...args) {
1244
- return callWithProperties({ [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
1247
+ return callWithProperties({ [_chunkRV7JIIDGcjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
1245
1248
  }
1246
1249
  var Session = (_class2 = class {
1247
1250
 
@@ -1269,8 +1272,8 @@ var Session = (_class2 = class {
1269
1272
  setInput(text, context7) {
1270
1273
  this.inputs.push(text);
1271
1274
  this.inputContexts.push(_nullishCoalesce(context7, () => ( {})));
1272
- this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_INPUT, JSON.stringify(this.inputs));
1273
- this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
1275
+ this.span.setAttribute(_chunkRV7JIIDGcjs.SESSION_INPUT, JSON.stringify(this.inputs));
1276
+ this.span.setAttribute(_chunkRV7JIIDGcjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
1274
1277
  }
1275
1278
  /**
1276
1279
  * Append an assistant turn to session output tracking.
@@ -1285,8 +1288,8 @@ var Session = (_class2 = class {
1285
1288
  setOutput(text, context7) {
1286
1289
  this.outputs.push(text);
1287
1290
  this.outputContexts.push(_nullishCoalesce(context7, () => ( {})));
1288
- this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
1289
- this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
1291
+ this.span.setAttribute(_chunkRV7JIIDGcjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
1292
+ this.span.setAttribute(_chunkRV7JIIDGcjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
1290
1293
  }
1291
1294
  /**
1292
1295
  * Set the session title on the span.
@@ -1294,7 +1297,7 @@ var Session = (_class2 = class {
1294
1297
  * @param title - The generated title string
1295
1298
  */
1296
1299
  setTitle(title) {
1297
- this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_TITLE, title);
1300
+ this.span.setAttribute(_chunkRV7JIIDGcjs.SESSION_TITLE, title);
1298
1301
  }
1299
1302
  /**
1300
1303
  * Update custom properties on the session span.
@@ -1304,7 +1307,7 @@ var Session = (_class2 = class {
1304
1307
  */
1305
1308
  updateProperties(properties) {
1306
1309
  for (const [key, value] of Object.entries(properties)) {
1307
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
1310
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
1308
1311
  }
1309
1312
  }
1310
1313
  /**
@@ -1316,21 +1319,21 @@ var Session = (_class2 = class {
1316
1319
  setUser(user) {
1317
1320
  if (user.traits) {
1318
1321
  for (const [key, value] of Object.entries(user.traits)) {
1319
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.user.${key}`, value);
1322
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.user.${key}`, value);
1320
1323
  }
1321
1324
  }
1322
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_ID}`, user.id);
1325
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_ID}`, user.id);
1323
1326
  if (user.email !== void 0) {
1324
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_EMAIL}`, user.email);
1327
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_EMAIL}`, user.email);
1325
1328
  }
1326
1329
  if (user.name !== void 0) {
1327
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_NAME}`, user.name);
1330
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_NAME}`, user.name);
1328
1331
  }
1329
1332
  if (user.role !== void 0) {
1330
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_ROLE}`, user.role);
1333
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_ROLE}`, user.role);
1331
1334
  }
1332
1335
  if (user.plan !== void 0) {
1333
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_PLAN}`, user.plan);
1336
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_PLAN}`, user.plan);
1334
1337
  }
1335
1338
  }
1336
1339
  /**
@@ -1342,18 +1345,18 @@ var Session = (_class2 = class {
1342
1345
  setOrganization(org) {
1343
1346
  if (org.traits) {
1344
1347
  for (const [key, value] of Object.entries(org.traits)) {
1345
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.organization.${key}`, value);
1348
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.organization.${key}`, value);
1346
1349
  }
1347
1350
  }
1348
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_ID}`, org.id);
1351
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.ORGANIZATION_ID}`, org.id);
1349
1352
  if (org.name !== void 0) {
1350
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_NAME}`, org.name);
1353
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.ORGANIZATION_NAME}`, org.name);
1351
1354
  }
1352
1355
  if (org.plan !== void 0) {
1353
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_PLAN}`, org.plan);
1356
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.ORGANIZATION_PLAN}`, org.plan);
1354
1357
  }
1355
1358
  if (org.domain !== void 0) {
1356
- this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN}`, org.domain);
1359
+ this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.ORGANIZATION_DOMAIN}`, org.domain);
1357
1360
  }
1358
1361
  }
1359
1362
  /**
@@ -1383,30 +1386,30 @@ var SessionTitle = class {
1383
1386
  * @param title - The generated title string
1384
1387
  */
1385
1388
  setTitle(title) {
1386
- this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_TITLE, title);
1389
+ this.span.setAttribute(_chunkRV7JIIDGcjs.SESSION_TITLE, title);
1387
1390
  }
1388
1391
  };
1389
1392
  function getActiveSession() {
1390
- return _api.context.active().getValue(_chunkGMZQ6N77cjs.SESSION_OBJECT_CONTEXT_KEY);
1393
+ return _api.context.active().getValue(_chunkRV7JIIDGcjs.SESSION_OBJECT_CONTEXT_KEY);
1391
1394
  }
1392
1395
  function resolveSessionIdFromContext() {
1393
1396
  const active = getActiveSession();
1394
1397
  if (active) {
1395
1398
  return active.sessionId;
1396
1399
  }
1397
- const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1398
- return _optionalChain([props, 'optionalAccess', _60 => _60[_chunkGMZQ6N77cjs.SESSION_ID]]);
1400
+ const props = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
1401
+ return _optionalChain([props, 'optionalAccess', _60 => _60[_chunkRV7JIIDGcjs.SESSION_ID]]);
1399
1402
  }
1400
1403
  function resolveMessageIdFromContext() {
1401
- const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1402
- return _optionalChain([props, 'optionalAccess', _61 => _61[_chunkGMZQ6N77cjs.MESSAGE_ID]]);
1404
+ const props = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
1405
+ return _optionalChain([props, 'optionalAccess', _61 => _61[_chunkRV7JIIDGcjs.MESSAGE_ID]]);
1403
1406
  }
1404
1407
  function emitExternalLink(sessionId, url, title, linkType) {
1405
1408
  try {
1406
- emitEventWithSessionId(sessionId, _chunkGMZQ6N77cjs.EXTERNAL_LINK_EVENT_NAME, {
1407
- [_chunkGMZQ6N77cjs.EXTERNAL_LINK_URL]: url,
1408
- [_chunkGMZQ6N77cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
1409
- [_chunkGMZQ6N77cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
1409
+ emitEventWithSessionId(sessionId, _chunkRV7JIIDGcjs.EXTERNAL_LINK_EVENT_NAME, {
1410
+ [_chunkRV7JIIDGcjs.EXTERNAL_LINK_URL]: url,
1411
+ [_chunkRV7JIIDGcjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
1412
+ [_chunkRV7JIIDGcjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
1410
1413
  });
1411
1414
  } catch (error) {
1412
1415
  _chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
@@ -1423,22 +1426,22 @@ function addExternalLink(url, options) {
1423
1426
  emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _63 => _63.title]), _optionalChain([options, 'optionalAccess', _64 => _64.linkType]));
1424
1427
  }
1425
1428
  function recordFeedback(type, options) {
1426
- const eventAttributes = { [_chunkGMZQ6N77cjs.FEEDBACK_TYPE]: type };
1429
+ const eventAttributes = { [_chunkRV7JIIDGcjs.FEEDBACK_TYPE]: type };
1427
1430
  if (_optionalChain([options, 'optionalAccess', _65 => _65.score]) !== void 0) {
1428
- eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_SCORE] = options.score;
1431
+ eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_SCORE] = options.score;
1429
1432
  }
1430
1433
  if (_optionalChain([options, 'optionalAccess', _66 => _66.reason]) !== void 0) {
1431
- eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_REASON] = options.reason;
1434
+ eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_REASON] = options.reason;
1432
1435
  }
1433
1436
  if (_optionalChain([options, 'optionalAccess', _67 => _67.comment]) !== void 0) {
1434
- eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_COMMENT] = options.comment;
1437
+ eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_COMMENT] = options.comment;
1435
1438
  }
1436
1439
  if (_optionalChain([options, 'optionalAccess', _68 => _68.source]) !== void 0) {
1437
- eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_SOURCE] = options.source;
1440
+ eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_SOURCE] = options.source;
1438
1441
  }
1439
1442
  if (_optionalChain([options, 'optionalAccess', _69 => _69.attributes])) {
1440
1443
  for (const [key, value] of Object.entries(options.attributes)) {
1441
- const k = `${_chunkGMZQ6N77cjs.FEEDBACK_ATTR_PREFIX}${key}`;
1444
+ const k = `${_chunkRV7JIIDGcjs.FEEDBACK_ATTR_PREFIX}${key}`;
1442
1445
  if (eventAttributes[k] === void 0) {
1443
1446
  eventAttributes[k] = value;
1444
1447
  }
@@ -1453,16 +1456,16 @@ function recordFeedback(type, options) {
1453
1456
  }
1454
1457
  const anchor = {};
1455
1458
  if (messageId !== void 0) {
1456
- anchor[_chunkGMZQ6N77cjs.MESSAGE_ID] = messageId;
1459
+ anchor[_chunkRV7JIIDGcjs.MESSAGE_ID] = messageId;
1457
1460
  }
1458
1461
  if (sessionId !== void 0) {
1459
- anchor[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
1462
+ anchor[_chunkRV7JIIDGcjs.SESSION_ID] = sessionId;
1460
1463
  }
1461
1464
  try {
1462
1465
  if (Object.keys(anchor).length === 0) {
1463
- emitEvent(_chunkGMZQ6N77cjs.FEEDBACK_EVENT_NAME, eventAttributes);
1466
+ emitEvent(_chunkRV7JIIDGcjs.FEEDBACK_EVENT_NAME, eventAttributes);
1464
1467
  } else {
1465
- callWithProperties(anchor, () => emitEvent(_chunkGMZQ6N77cjs.FEEDBACK_EVENT_NAME, eventAttributes));
1468
+ callWithProperties(anchor, () => emitEvent(_chunkRV7JIIDGcjs.FEEDBACK_EVENT_NAME, eventAttributes));
1466
1469
  }
1467
1470
  } catch (error) {
1468
1471
  _chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
@@ -1487,7 +1490,7 @@ function recordMetricImpl(options) {
1487
1490
  );
1488
1491
  return;
1489
1492
  }
1490
- if (_chunkGMZQ6N77cjs.RESERVED_METRIC_NAMES.has(name)) {
1493
+ if (_chunkRV7JIIDGcjs.RESERVED_METRIC_NAMES.has(name)) {
1491
1494
  _chunkWC573FCIcjs.logger.warn(
1492
1495
  `recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
1493
1496
  );
@@ -1512,18 +1515,28 @@ function recordMetricImpl(options) {
1512
1515
  return;
1513
1516
  }
1514
1517
  }
1518
+ const scope = _nullishCoalesce(options.scope, () => ( _chunkRV7JIIDGcjs.METRIC_SCOPE_SESSION));
1519
+ if (scope !== _chunkRV7JIIDGcjs.METRIC_SCOPE_SESSION && scope !== _chunkRV7JIIDGcjs.METRIC_SCOPE_TRACE) {
1520
+ _chunkWC573FCIcjs.logger.warn(
1521
+ `recordMetric(${name}) called with an invalid scope ${JSON.stringify(scope)}; expected '${_chunkRV7JIIDGcjs.METRIC_SCOPE_SESSION}' or '${_chunkRV7JIIDGcjs.METRIC_SCOPE_TRACE}'. Metric dropped.`
1522
+ );
1523
+ return;
1524
+ }
1515
1525
  const eventAttributes = {
1516
- [_chunkGMZQ6N77cjs.METRIC_NAME]: name,
1517
- [_chunkGMZQ6N77cjs.METRIC_VALUE]: numericValue
1526
+ [_chunkRV7JIIDGcjs.METRIC_NAME]: name,
1527
+ [_chunkRV7JIIDGcjs.METRIC_VALUE]: numericValue
1518
1528
  };
1529
+ if (options.scope !== void 0) {
1530
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_SCOPE] = scope;
1531
+ }
1519
1532
  if (options.unit !== void 0) {
1520
- eventAttributes[_chunkGMZQ6N77cjs.METRIC_UNIT] = options.unit;
1533
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_UNIT] = options.unit;
1521
1534
  }
1522
1535
  if (options.minValue !== void 0) {
1523
- eventAttributes[_chunkGMZQ6N77cjs.METRIC_MIN] = options.minValue;
1536
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_MIN] = options.minValue;
1524
1537
  }
1525
1538
  if (options.maxValue !== void 0) {
1526
- eventAttributes[_chunkGMZQ6N77cjs.METRIC_MAX] = options.maxValue;
1539
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_MAX] = options.maxValue;
1527
1540
  }
1528
1541
  if (options.comment !== void 0) {
1529
1542
  let comment = options.comment;
@@ -1533,21 +1546,21 @@ function recordMetricImpl(options) {
1533
1546
  );
1534
1547
  comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
1535
1548
  }
1536
- eventAttributes[_chunkGMZQ6N77cjs.METRIC_COMMENT] = comment;
1549
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_COMMENT] = comment;
1537
1550
  }
1538
1551
  if (options.polarity !== void 0) {
1539
1552
  const polarity = options.polarity;
1540
- if (polarity === _chunkGMZQ6N77cjs.METRIC_POLARITY_POSITIVE || polarity === _chunkGMZQ6N77cjs.METRIC_POLARITY_NEGATIVE) {
1541
- eventAttributes[_chunkGMZQ6N77cjs.METRIC_POLARITY] = polarity;
1553
+ if (polarity === _chunkRV7JIIDGcjs.METRIC_POLARITY_POSITIVE || polarity === _chunkRV7JIIDGcjs.METRIC_POLARITY_NEGATIVE) {
1554
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_POLARITY] = polarity;
1542
1555
  } else {
1543
1556
  _chunkWC573FCIcjs.logger.warn(
1544
- `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunkGMZQ6N77cjs.METRIC_POLARITY_POSITIVE}' or '${_chunkGMZQ6N77cjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1557
+ `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunkRV7JIIDGcjs.METRIC_POLARITY_POSITIVE}' or '${_chunkRV7JIIDGcjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1545
1558
  );
1546
1559
  }
1547
1560
  }
1548
1561
  if (options.timestamp !== void 0) {
1549
1562
  if (Number.isFinite(options.timestamp.getTime())) {
1550
- eventAttributes[_chunkGMZQ6N77cjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1563
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1551
1564
  } else {
1552
1565
  _chunkWC573FCIcjs.logger.warn(
1553
1566
  `recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
@@ -1577,13 +1590,23 @@ function recordMetricImpl(options) {
1577
1590
  );
1578
1591
  text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
1579
1592
  }
1580
- eventAttributes[`${_chunkGMZQ6N77cjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1593
+ eventAttributes[`${_chunkRV7JIIDGcjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1581
1594
  accepted += 1;
1582
1595
  }
1583
1596
  }
1584
1597
  const traceId = typeof options.traceId === "string" && options.traceId !== "" ? options.traceId : void 0;
1585
1598
  if (traceId !== void 0) {
1586
- eventAttributes[_chunkGMZQ6N77cjs.METRIC_TRACE_ID] = traceId;
1599
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_TRACE_ID] = traceId;
1600
+ }
1601
+ if (scope === _chunkRV7JIIDGcjs.METRIC_SCOPE_TRACE && traceId === void 0) {
1602
+ const spanContext = _optionalChain([_api.trace, 'access', _73 => _73.getActiveSpan, 'call', _74 => _74(), 'optionalAccess', _75 => _75.spanContext, 'call', _76 => _76()]);
1603
+ if (!spanContext || !_api.isSpanContextValid.call(void 0, spanContext)) {
1604
+ _chunkWC573FCIcjs.logger.warn(
1605
+ `recordMetric(${name}) called with scope 'trace' but no trace; metric dropped. Pass options.traceId, or call inside the span of the trace being scored.`
1606
+ );
1607
+ return;
1608
+ }
1609
+ eventAttributes[_chunkRV7JIIDGcjs.METRIC_TRACE_ID] = spanContext.traceId;
1587
1610
  }
1588
1611
  const sessionId = _nullishCoalesce(options.sessionId, () => ( (traceId === void 0 ? resolveSessionIdFromContext() : void 0)));
1589
1612
  if (sessionId === void 0 && traceId === void 0) {
@@ -1593,41 +1616,41 @@ function recordMetricImpl(options) {
1593
1616
  return;
1594
1617
  }
1595
1618
  const base = _api.context.active();
1596
- const ambient = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1619
+ const ambient = base.getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
1597
1620
  const properties = { ...ambient };
1598
1621
  if (sessionId === void 0) {
1599
- delete properties[_chunkGMZQ6N77cjs.SESSION_ID];
1600
- delete properties[_chunkGMZQ6N77cjs.MESSAGE_ID];
1622
+ delete properties[_chunkRV7JIIDGcjs.SESSION_ID];
1623
+ delete properties[_chunkRV7JIIDGcjs.MESSAGE_ID];
1601
1624
  } else {
1602
- properties[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
1625
+ properties[_chunkRV7JIIDGcjs.SESSION_ID] = sessionId;
1603
1626
  }
1604
1627
  if (options.serviceName !== void 0) {
1605
- properties[_chunkGMZQ6N77cjs.SERVICE_NAME] = options.serviceName;
1628
+ properties[_chunkRV7JIIDGcjs.SERVICE_NAME] = options.serviceName;
1606
1629
  }
1607
1630
  try {
1608
1631
  _api.context.with(
1609
- base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, properties),
1610
- () => emitEvent(_chunkGMZQ6N77cjs.METRIC_EVENT_NAME, eventAttributes)
1632
+ base.setValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY, properties),
1633
+ () => emitEvent(_chunkRV7JIIDGcjs.METRIC_EVENT_NAME, eventAttributes)
1611
1634
  );
1612
1635
  } catch (error) {
1613
1636
  _chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
1614
1637
  }
1615
1638
  }
1616
1639
  function startSession(sessionId, callback, extraProperties, options) {
1617
- const isTitle = _optionalChain([options, 'optionalAccess', _73 => _73.mode]) === "title";
1618
- const spanName = isTitle ? _chunkGMZQ6N77cjs.SESSION_TITLE_SPAN_NAME : _chunkGMZQ6N77cjs.SESSION_SPAN_NAME;
1640
+ const isTitle = _optionalChain([options, 'optionalAccess', _77 => _77.mode]) === "title";
1641
+ const spanName = isTitle ? _chunkRV7JIIDGcjs.SESSION_TITLE_SPAN_NAME : _chunkRV7JIIDGcjs.SESSION_SPAN_NAME;
1619
1642
  const tracer = _api.trace.getTracer("@brizz/sdk");
1620
1643
  return tracer.startActiveSpan(spanName, (span) => {
1621
- span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.SESSION_ID}`, sessionId);
1644
+ span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.SESSION_ID}`, sessionId);
1622
1645
  if (extraProperties) {
1623
1646
  for (const [key, value] of Object.entries(extraProperties)) {
1624
- span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
1647
+ span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
1625
1648
  }
1626
1649
  }
1627
1650
  const session = new Session(sessionId, span);
1628
- const contextProperties = { [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId };
1651
+ const contextProperties = { [_chunkRV7JIIDGcjs.SESSION_ID]: sessionId };
1629
1652
  if (isTitle) {
1630
- contextProperties[_chunkGMZQ6N77cjs.SESSION_TITLE_GENERATION] = "true";
1653
+ contextProperties[_chunkRV7JIIDGcjs.SESSION_TITLE_GENERATION] = "true";
1631
1654
  }
1632
1655
  if (extraProperties) {
1633
1656
  for (const [key, value] of Object.entries(extraProperties)) {
@@ -1635,7 +1658,7 @@ function startSession(sessionId, callback, extraProperties, options) {
1635
1658
  }
1636
1659
  }
1637
1660
  return callWithProperties(contextProperties, () => {
1638
- const sessionCtx = _api.context.active().setValue(_chunkGMZQ6N77cjs.SESSION_OBJECT_CONTEXT_KEY, session);
1661
+ const sessionCtx = _api.context.active().setValue(_chunkRV7JIIDGcjs.SESSION_OBJECT_CONTEXT_KEY, session);
1639
1662
  return _api.context.with(sessionCtx, () => {
1640
1663
  try {
1641
1664
  const result = callback(session);
@@ -1663,16 +1686,16 @@ function startSession(sessionId, callback, extraProperties, options) {
1663
1686
  });
1664
1687
  }
1665
1688
  function startSessionTitle(callback, options) {
1666
- const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _74 => _74.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _75 => _75(), 'optionalAccess', _76 => _76.sessionId])));
1689
+ const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _78 => _78.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _79 => _79(), 'optionalAccess', _80 => _80.sessionId])));
1667
1690
  const tracer = _api.trace.getTracer("@brizz/sdk");
1668
- return tracer.startActiveSpan(_chunkGMZQ6N77cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1691
+ return tracer.startActiveSpan(_chunkRV7JIIDGcjs.SESSION_TITLE_SPAN_NAME, (span) => {
1669
1692
  if (resolvedSessionId) {
1670
- span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.SESSION_ID}`, resolvedSessionId);
1693
+ span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.SESSION_ID}`, resolvedSessionId);
1671
1694
  }
1672
1695
  const sessionTitle = new SessionTitle(span);
1673
- const properties = { [_chunkGMZQ6N77cjs.SESSION_TITLE_GENERATION]: "true" };
1696
+ const properties = { [_chunkRV7JIIDGcjs.SESSION_TITLE_GENERATION]: "true" };
1674
1697
  if (resolvedSessionId) {
1675
- properties[_chunkGMZQ6N77cjs.SESSION_ID] = resolvedSessionId;
1698
+ properties[_chunkRV7JIIDGcjs.SESSION_ID] = resolvedSessionId;
1676
1699
  }
1677
1700
  return callWithProperties(properties, () => {
1678
1701
  try {
@@ -2135,14 +2158,14 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
2135
2158
  this.config = config;
2136
2159
  }
2137
2160
  onEmit(logRecord) {
2138
- const maskingConfig = _optionalChain([this, 'access', _77 => _77.config, 'access', _78 => _78.masking, 'optionalAccess', _79 => _79.eventMasking]);
2161
+ const maskingConfig = _optionalChain([this, 'access', _81 => _81.config, 'access', _82 => _82.masking, 'optionalAccess', _83 => _83.eventMasking]);
2139
2162
  if (maskingConfig) {
2140
2163
  maskLog(logRecord, maskingConfig);
2141
2164
  }
2142
- const associationProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2165
+ const associationProperties = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
2143
2166
  if (associationProperties) {
2144
2167
  for (const [key, value] of Object.entries(associationProperties)) {
2145
- logRecord.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2168
+ logRecord.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
2146
2169
  }
2147
2170
  }
2148
2171
  super.onEmit(logRecord);
@@ -2155,14 +2178,14 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
2155
2178
  this.config = config;
2156
2179
  }
2157
2180
  onEmit(logRecord) {
2158
- const maskingConfig = _optionalChain([this, 'access', _80 => _80.config, 'access', _81 => _81.masking, 'optionalAccess', _82 => _82.eventMasking]);
2181
+ const maskingConfig = _optionalChain([this, 'access', _84 => _84.config, 'access', _85 => _85.masking, 'optionalAccess', _86 => _86.eventMasking]);
2159
2182
  if (maskingConfig) {
2160
2183
  maskLog(logRecord, maskingConfig);
2161
2184
  }
2162
- const associationProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2185
+ const associationProperties = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
2163
2186
  if (associationProperties) {
2164
2187
  for (const [key, value] of Object.entries(associationProperties)) {
2165
- logRecord.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2188
+ logRecord.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
2166
2189
  }
2167
2190
  }
2168
2191
  super.onEmit(logRecord);
@@ -2189,7 +2212,7 @@ function maskLog(logRecord, config) {
2189
2212
  newAttributes[key] = value;
2190
2213
  }
2191
2214
  for (const [key, value] of Object.entries(logRecord.attributes)) {
2192
- if (key.startsWith(_chunkGMZQ6N77cjs.INTERNAL_EVENT_PREFIX)) {
2215
+ if (key.startsWith(_chunkRV7JIIDGcjs.INTERNAL_EVENT_PREFIX)) {
2193
2216
  newAttributes[key] = value;
2194
2217
  }
2195
2218
  }
@@ -2256,14 +2279,14 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
2256
2279
  _chunkWC573FCIcjs.logger.debug("Creating logger provider", {
2257
2280
  serviceName,
2258
2281
  disableBatch: config.disableBatch,
2259
- hasMasking: !!_optionalChain([config, 'access', _83 => _83.masking, 'optionalAccess', _84 => _84.eventMasking])
2282
+ hasMasking: !!_optionalChain([config, 'access', _87 => _87.masking, 'optionalAccess', _88 => _88.eventMasking])
2260
2283
  });
2261
2284
  const exporter = this.createLogExporter(config, serviceName);
2262
2285
  const processor = config.disableBatch ? new BrizzSimpleLogRecordProcessor(exporter, config) : new BrizzBatchLogRecordProcessor(exporter, config);
2263
2286
  const resourceAttributes = {
2264
2287
  ...config.resourceAttributes,
2265
2288
  "service.name": serviceName,
2266
- [BRIZZ_SDK_VERSION]: _chunkVAUO47L3cjs.getSDKVersion.call(void 0, ),
2289
+ [BRIZZ_SDK_VERSION]: _chunkVH5N6E54cjs.getSDKVersion.call(void 0, ),
2267
2290
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2268
2291
  };
2269
2292
  if (config.environment) {
@@ -2512,7 +2535,7 @@ var BrizzSpanExporter = (_class5 = class {
2512
2535
  const resourceAttrs = {
2513
2536
  ...config.resourceAttributes,
2514
2537
  "service.name": config.appName,
2515
- [BRIZZ_SDK_VERSION]: _chunkVAUO47L3cjs.getSDKVersion.call(void 0, ),
2538
+ [BRIZZ_SDK_VERSION]: _chunkVH5N6E54cjs.getSDKVersion.call(void 0, ),
2516
2539
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2517
2540
  };
2518
2541
  if (config.environment) {
@@ -2526,7 +2549,7 @@ var BrizzSpanExporter = (_class5 = class {
2526
2549
  }
2527
2550
  /** The service a span reports under: its scoped override, else the configured appName. */
2528
2551
  _serviceNameOf(span) {
2529
- const value = span.attributes[_chunkGMZQ6N77cjs.SERVICE_NAME_ATTRIBUTE];
2552
+ const value = span.attributes[_chunkRV7JIIDGcjs.SERVICE_NAME_ATTRIBUTE];
2530
2553
  return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
2531
2554
  }
2532
2555
  _resourceFor(serviceName) {
@@ -2639,8 +2662,8 @@ var BrizzSpanExporter = (_class5 = class {
2639
2662
  }
2640
2663
  async forceFlush() {
2641
2664
  await Promise.all([
2642
- _optionalChain([this, 'access', _85 => _85._delegate, 'access', _86 => _86.forceFlush, 'optionalCall', _87 => _87()]),
2643
- ...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _88 => _88.forceFlush, 'optionalCall', _89 => _89()]))
2665
+ _optionalChain([this, 'access', _89 => _89._delegate, 'access', _90 => _90.forceFlush, 'optionalCall', _91 => _91()]),
2666
+ ...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access', _92 => _92.forceFlush, 'optionalCall', _93 => _93()]))
2644
2667
  ]);
2645
2668
  }
2646
2669
  }, _class5);
@@ -2652,10 +2675,10 @@ var BrizzSpanExporter = (_class5 = class {
2652
2675
 
2653
2676
  var _sdktracebase = require('@opentelemetry/sdk-trace-base');
2654
2677
  function applyContextAttributes(span) {
2655
- const sessionProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2678
+ const sessionProperties = _api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
2656
2679
  if (sessionProperties) {
2657
2680
  for (const [key, value] of Object.entries(sessionProperties)) {
2658
- span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2681
+ span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
2659
2682
  }
2660
2683
  }
2661
2684
  }
@@ -2677,7 +2700,7 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
2677
2700
  }
2678
2701
  onEnd(span) {
2679
2702
  restampLangChainSpan(span);
2680
- const maskingConfig = _optionalChain([this, 'access', _90 => _90.config, 'access', _91 => _91.masking, 'optionalAccess', _92 => _92.spanMasking]);
2703
+ const maskingConfig = _optionalChain([this, 'access', _94 => _94.config, 'access', _95 => _95.masking, 'optionalAccess', _96 => _96.spanMasking]);
2681
2704
  if (maskingConfig) {
2682
2705
  maskReadableSpan(span, maskingConfig);
2683
2706
  }
@@ -2696,7 +2719,7 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
2696
2719
  }
2697
2720
  onEnd(span) {
2698
2721
  restampLangChainSpan(span);
2699
- const maskingConfig = _optionalChain([this, 'access', _93 => _93.config, 'access', _94 => _94.masking, 'optionalAccess', _95 => _95.spanMasking]);
2722
+ const maskingConfig = _optionalChain([this, 'access', _97 => _97.config, 'access', _98 => _98.masking, 'optionalAccess', _99 => _99.spanMasking]);
2700
2723
  if (maskingConfig) {
2701
2724
  maskReadableSpan(span, maskingConfig);
2702
2725
  }
@@ -2783,7 +2806,7 @@ var TracingModule = (_class6 = class _TracingModule {constructor() { _class6.pro
2783
2806
  }
2784
2807
  _chunkWC573FCIcjs.logger.debug("Initializing span processor", {
2785
2808
  disableBatch: config.disableBatch,
2786
- hasMasking: !!_optionalChain([config, 'access', _96 => _96.masking, 'optionalAccess', _97 => _97.spanMasking])
2809
+ hasMasking: !!_optionalChain([config, 'access', _100 => _100.masking, 'optionalAccess', _101 => _101.spanMasking])
2787
2810
  });
2788
2811
  const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
2789
2812
  _chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
@@ -2854,7 +2877,7 @@ function newInstanceId() {
2854
2877
  return _crypto.randomUUID.call(void 0, ).replaceAll("-", "").slice(0, 8);
2855
2878
  }
2856
2879
  function activeProperties() {
2857
- return _nullishCoalesce(_api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
2880
+ return _nullishCoalesce(_api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
2858
2881
  }
2859
2882
  function encodeToken(agent) {
2860
2883
  const payload = {
@@ -2880,7 +2903,7 @@ function agentHandle(id, parentId, name) {
2880
2903
  parentId,
2881
2904
  name,
2882
2905
  traceparent: currentTraceparent(),
2883
- sessionId: _nullishCoalesce(activeProperties()[_chunkGMZQ6N77cjs.SESSION_ID], () => ( ""))
2906
+ sessionId: _nullishCoalesce(activeProperties()[_chunkRV7JIIDGcjs.SESSION_ID], () => ( ""))
2884
2907
  };
2885
2908
  return {
2886
2909
  ...opened,
@@ -2916,7 +2939,7 @@ function resolveAgent(agent) {
2916
2939
  let parentContext = _api.context.active();
2917
2940
  if (options.token === void 0) {
2918
2941
  id = options.id || newInstanceId();
2919
- parentId = options.parentId || activeProperties()[_chunkGMZQ6N77cjs.AGENT_ID] || "";
2942
+ parentId = options.parentId || activeProperties()[_chunkRV7JIIDGcjs.AGENT_ID] || "";
2920
2943
  name = _nullishCoalesce(options.name, () => ( ""));
2921
2944
  } else {
2922
2945
  const decoded = decodeToken(options.token);
@@ -2935,12 +2958,12 @@ function resolveAgent(agent) {
2935
2958
  }
2936
2959
  }
2937
2960
  }
2938
- const properties = { [_chunkGMZQ6N77cjs.AGENT_ID]: id, [_chunkGMZQ6N77cjs.AGENT_NAME]: name };
2961
+ const properties = { [_chunkRV7JIIDGcjs.AGENT_ID]: id, [_chunkRV7JIIDGcjs.AGENT_NAME]: name };
2939
2962
  if (parentId) {
2940
- properties[_chunkGMZQ6N77cjs.AGENT_PARENT_ID] = parentId;
2963
+ properties[_chunkRV7JIIDGcjs.AGENT_PARENT_ID] = parentId;
2941
2964
  }
2942
2965
  if (sessionId) {
2943
- properties[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
2966
+ properties[_chunkRV7JIIDGcjs.SESSION_ID] = sessionId;
2944
2967
  }
2945
2968
  return { id, parentId, name, properties, parentContext };
2946
2969
  }
@@ -3003,7 +3026,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
3003
3026
  */
3004
3027
  setupInstrumentation(options) {
3005
3028
  const registry = InstrumentationRegistry.getInstance();
3006
- _chunkVAUO47L3cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
3029
+ _chunkVH5N6E54cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
3007
3030
  patchInstalledCallbackManager();
3008
3031
  patchInstalledLangGraph();
3009
3032
  if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
@@ -3028,7 +3051,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
3028
3051
  const resourceAttributes = {
3029
3052
  ...resolvedConfig.resourceAttributes,
3030
3053
  "service.name": resolvedConfig.appName,
3031
- [BRIZZ_SDK_VERSION]: _chunkVAUO47L3cjs.getSDKVersion.call(void 0, ),
3054
+ [BRIZZ_SDK_VERSION]: _chunkVH5N6E54cjs.getSDKVersion.call(void 0, ),
3032
3055
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
3033
3056
  };
3034
3057
  if (resolvedConfig.environment) {
@@ -3040,7 +3063,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
3040
3063
  const resource = _resources2.defaultResource.call(void 0, ).merge(_resources2.detectResources.call(void 0, { detectors: [_resources2.envDetector, _resources2.hostDetector, _resources2.processDetector] })).merge(_resources2.resourceFromAttributes.call(void 0, resourceAttributes));
3041
3064
  this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
3042
3065
  resource,
3043
- spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkELLCNMLIcjs.InterruptPropagator)(), getSpanProcessor()]
3066
+ spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkO2IBZJOJcjs.InterruptPropagator)(), getSpanProcessor()]
3044
3067
  });
3045
3068
  this._tracerProvider.register();
3046
3069
  this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
@@ -3176,10 +3199,10 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
3176
3199
  }
3177
3200
  try {
3178
3201
  await this.shutdownModules();
3179
- await _optionalChain([this, 'access', _98 => _98._tracerProvider, 'optionalAccess', _99 => _99.forceFlush, 'call', _100 => _100()]);
3180
- await _optionalChain([this, 'access', _101 => _101._tracerProvider, 'optionalAccess', _102 => _102.shutdown, 'call', _103 => _103()]);
3181
- await _optionalChain([this, 'access', _104 => _104._meterProvider, 'optionalAccess', _105 => _105.forceFlush, 'call', _106 => _106()]);
3182
- await _optionalChain([this, 'access', _107 => _107._meterProvider, 'optionalAccess', _108 => _108.shutdown, 'call', _109 => _109()]);
3202
+ await _optionalChain([this, 'access', _102 => _102._tracerProvider, 'optionalAccess', _103 => _103.forceFlush, 'call', _104 => _104()]);
3203
+ await _optionalChain([this, 'access', _105 => _105._tracerProvider, 'optionalAccess', _106 => _106.shutdown, 'call', _107 => _107()]);
3204
+ await _optionalChain([this, 'access', _108 => _108._meterProvider, 'optionalAccess', _109 => _109.forceFlush, 'call', _110 => _110()]);
3205
+ await _optionalChain([this, 'access', _111 => _111._meterProvider, 'optionalAccess', _112 => _112.shutdown, 'call', _113 => _113()]);
3183
3206
  this._initialized = false;
3184
3207
  this._tracerProvider = null;
3185
3208
  this._meterProvider = null;