@brizz/sdk 0.1.47 → 0.1.48

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 _chunkEWT4TUB7cjs = require('./chunk-EWT4TUB7.cjs');
8
+ var _chunkJDJLJ2V2cjs = require('./chunk-JDJLJ2V2.cjs');
9
9
 
10
10
 
11
11
 
@@ -16,7 +16,7 @@ var _chunkEWT4TUB7cjs = require('./chunk-EWT4TUB7.cjs');
16
16
  var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
17
17
 
18
18
 
19
- var _chunk3IGBYXLRcjs = require('./chunk-3IGBYXLR.cjs');
19
+ var _chunkELLCNMLIcjs = require('./chunk-ELLCNMLI.cjs');
20
20
 
21
21
 
22
22
 
@@ -73,7 +73,8 @@ var _chunk3IGBYXLRcjs = require('./chunk-3IGBYXLR.cjs');
73
73
 
74
74
 
75
75
 
76
- var _chunk5WBPX342cjs = require('./chunk-5WBPX342.cjs');
76
+
77
+ var _chunkGMZQ6N77cjs = require('./chunk-GMZQ6N77.cjs');
77
78
 
78
79
 
79
80
  var _chunkOBGZSXTJcjs = require('./chunk-OBGZSXTJ.cjs');
@@ -99,7 +100,7 @@ var _api = require('@opentelemetry/api');
99
100
 
100
101
  // src/internal/instrumentation/langgraph/attributes.ts
101
102
  var INSTRUMENTATION_NAME = "@brizz/sdk/langgraph";
102
- var INSTRUMENTATION_VERSION = _chunkEWT4TUB7cjs.getSDKVersion.call(void 0, );
103
+ var INSTRUMENTATION_VERSION = _chunkJDJLJ2V2cjs.getSDKVersion.call(void 0, );
103
104
  var MODULE_NAME = "@langchain/langgraph";
104
105
  var SUPPORTED_VERSIONS = [">=0.2.0 <2"];
105
106
  var CHECKPOINT_SPAN_NAME = "brizz.langgraph.checkpoint";
@@ -418,7 +419,7 @@ function loadGenAIInstrumentations() {
418
419
  function loadMCPInstrumentation() {
419
420
  void (async () => {
420
421
  try {
421
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3FOEDOF2.cjs")));
422
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3E34LCRM.cjs")));
422
423
  const mcp = new MCPInstrumentation({ exceptionLogger });
423
424
  _instrumentation.registerInstrumentations.call(void 0, { instrumentations: [mcp] });
424
425
  _chunkWC573FCIcjs.logger.debug("Auto-loaded MCP instrumentation");
@@ -482,7 +483,7 @@ function loadVercelAITelemetry() {
482
483
  }
483
484
  const isV7 = typeof ai.registerTelemetry === "function";
484
485
  const integrations = [];
485
- const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-IKOUBQGN.cjs")));
486
+ const { createInterruptIntegration } = await Promise.resolve().then(() => _interopRequireWildcard(require("./interrupt-YQHEXVES.cjs")));
486
487
  integrations.push(createInterruptIntegration());
487
488
  let otelCollectorLoaded = false;
488
489
  try {
@@ -698,20 +699,20 @@ var _module = require('module');
698
699
  var SCOPE_NAME = "@arizeai/openinference-instrumentation-langchain";
699
700
  var PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.callbackManagerPatched");
700
701
  var OMITTED_KEYS = /* @__PURE__ */ new Set([
701
- _chunk5WBPX342cjs.USER_EMAIL,
702
- _chunk5WBPX342cjs.USER_NAME,
703
- _chunk5WBPX342cjs.ORGANIZATION_NAME,
704
- _chunk5WBPX342cjs.ORGANIZATION_DOMAIN
702
+ _chunkGMZQ6N77cjs.USER_EMAIL,
703
+ _chunkGMZQ6N77cjs.USER_NAME,
704
+ _chunkGMZQ6N77cjs.ORGANIZATION_NAME,
705
+ _chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN
705
706
  ]);
706
707
  function runMetadataFromContext() {
707
- const bag = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
708
+ const bag = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
708
709
  if (!bag) {
709
710
  return void 0;
710
711
  }
711
712
  const metadata = {};
712
713
  for (const [name, value] of Object.entries(bag)) {
713
714
  if (!OMITTED_KEYS.has(name)) {
714
- metadata[`${_chunk5WBPX342cjs.BRIZZ}.${name}`] = String(value);
715
+ metadata[`${_chunkGMZQ6N77cjs.BRIZZ}.${name}`] = String(value);
715
716
  }
716
717
  }
717
718
  return Object.keys(metadata).length > 0 ? metadata : void 0;
@@ -768,7 +769,7 @@ function restampLangChainSpan(span) {
768
769
  }
769
770
  const attrs = span.attributes;
770
771
  const metadata = attrs["metadata"];
771
- if (typeof metadata !== "string" || !metadata.includes(`"${_chunk5WBPX342cjs.BRIZZ}.`)) {
772
+ if (typeof metadata !== "string" || !metadata.includes(`"${_chunkGMZQ6N77cjs.BRIZZ}.`)) {
772
773
  return;
773
774
  }
774
775
  const parsed = JSON.parse(metadata);
@@ -776,7 +777,7 @@ function restampLangChainSpan(span) {
776
777
  return;
777
778
  }
778
779
  for (const [key, value] of Object.entries(parsed)) {
779
- if (key.startsWith(`${_chunk5WBPX342cjs.BRIZZ}.`) && value !== null && value !== void 0) {
780
+ if (key.startsWith(`${_chunkGMZQ6N77cjs.BRIZZ}.`) && value !== null && value !== void 0) {
780
781
  attrs[key] = String(value);
781
782
  }
782
783
  }
@@ -914,7 +915,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
914
915
  const mcpModules = this.manualModules.mcp;
915
916
  void (async () => {
916
917
  try {
917
- const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3FOEDOF2.cjs")));
918
+ const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3E34LCRM.cjs")));
918
919
  const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
919
920
  instrumentation.manuallyInstrument(mcpModules);
920
921
  _chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
@@ -965,16 +966,16 @@ function setCurrentSpanCustomProperties(properties) {
965
966
  }
966
967
  for (const [key, value] of Object.entries(properties)) {
967
968
  try {
968
- current.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
969
+ current.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
969
970
  } catch (e3) {
970
971
  }
971
972
  }
972
973
  }
973
974
  function callWithProperties(properties, fn, thisArg, ...args) {
974
975
  const base = _api.context.active();
975
- const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
976
+ const prev = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
976
977
  const merged = prev ? { ...prev, ...properties } : properties;
977
- const next = base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged);
978
+ const next = base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, merged);
978
979
  return _api.context.with(next, fn, thisArg, ...args);
979
980
  }
980
981
  function withProperties(properties, fn, thisArg) {
@@ -995,25 +996,25 @@ function propagatePropertiesImperatively(properties, base = _api.context.active(
995
996
  if (!store || typeof store.enterWith !== "function") {
996
997
  return;
997
998
  }
998
- const prev = base.getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
999
+ const prev = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
999
1000
  const merged = prev ? { ...prev, ...properties } : properties;
1000
- store.enterWith(base.setValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY, merged));
1001
+ store.enterWith(base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, merged));
1001
1002
  } catch (e4) {
1002
1003
  }
1003
1004
  }
1004
1005
  function setUser(user) {
1005
- const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
1006
+ const properties = { [_chunkGMZQ6N77cjs.USER_ID]: user.id };
1006
1007
  if (user.email !== void 0) {
1007
- properties[_chunk5WBPX342cjs.USER_EMAIL] = user.email;
1008
+ properties[_chunkGMZQ6N77cjs.USER_EMAIL] = user.email;
1008
1009
  }
1009
1010
  if (user.name !== void 0) {
1010
- properties[_chunk5WBPX342cjs.USER_NAME] = user.name;
1011
+ properties[_chunkGMZQ6N77cjs.USER_NAME] = user.name;
1011
1012
  }
1012
1013
  if (user.role !== void 0) {
1013
- properties[_chunk5WBPX342cjs.USER_ROLE] = user.role;
1014
+ properties[_chunkGMZQ6N77cjs.USER_ROLE] = user.role;
1014
1015
  }
1015
1016
  if (user.plan !== void 0) {
1016
- properties[_chunk5WBPX342cjs.USER_PLAN] = user.plan;
1017
+ properties[_chunkGMZQ6N77cjs.USER_PLAN] = user.plan;
1017
1018
  }
1018
1019
  if (user.traits) {
1019
1020
  for (const [key, value] of Object.entries(user.traits)) {
@@ -1027,15 +1028,15 @@ function setUser(user) {
1027
1028
  propagatePropertiesImperatively(properties);
1028
1029
  }
1029
1030
  function setOrganization(org) {
1030
- const properties = { [_chunk5WBPX342cjs.ORGANIZATION_ID]: org.id };
1031
+ const properties = { [_chunkGMZQ6N77cjs.ORGANIZATION_ID]: org.id };
1031
1032
  if (org.name !== void 0) {
1032
- properties[_chunk5WBPX342cjs.ORGANIZATION_NAME] = org.name;
1033
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_NAME] = org.name;
1033
1034
  }
1034
1035
  if (org.plan !== void 0) {
1035
- properties[_chunk5WBPX342cjs.ORGANIZATION_PLAN] = org.plan;
1036
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_PLAN] = org.plan;
1036
1037
  }
1037
1038
  if (org.domain !== void 0) {
1038
- properties[_chunk5WBPX342cjs.ORGANIZATION_DOMAIN] = org.domain;
1039
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN] = org.domain;
1039
1040
  }
1040
1041
  if (org.traits) {
1041
1042
  for (const [key, value] of Object.entries(org.traits)) {
@@ -1049,35 +1050,36 @@ function setOrganization(org) {
1049
1050
  propagatePropertiesImperatively(properties);
1050
1051
  }
1051
1052
  function setMessageId(id) {
1052
- const properties = { [_chunk5WBPX342cjs.MESSAGE_ID]: id };
1053
+ const properties = { [_chunkGMZQ6N77cjs.MESSAGE_ID]: id };
1053
1054
  setCurrentSpanCustomProperties(properties);
1054
1055
  propagatePropertiesImperatively(properties);
1055
1056
  }
1056
1057
  function setSessionId(id) {
1057
- const properties = { [_chunk5WBPX342cjs.SESSION_ID]: id };
1058
+ const properties = { [_chunkGMZQ6N77cjs.SESSION_ID]: id };
1058
1059
  setCurrentSpanCustomProperties(properties);
1059
1060
  propagatePropertiesImperatively(properties);
1060
1061
  }
1061
1062
  var SERVICE_NAME_MAX_BYTES = 256;
1062
- function serviceNameProperties(name) {
1063
+ function serviceNameProblem(name) {
1063
1064
  if (typeof name !== "string" || name === "") {
1064
- _chunkWC573FCIcjs.logger.warn("Service name must be a non-empty string; keeping the configured appName.");
1065
- return {};
1065
+ return "must be a non-empty string";
1066
1066
  }
1067
1067
  if (/[\r\n\0]/.test(name)) {
1068
- _chunkWC573FCIcjs.logger.warn(
1069
- `Service name ${JSON.stringify(name)} contains CR, LF, or NUL; keeping the configured appName.`
1070
- );
1071
- return {};
1068
+ return `${JSON.stringify(name)} contains CR, LF, or NUL`;
1072
1069
  }
1073
1070
  const byteLength = new globalThis.TextEncoder().encode(name).length;
1074
1071
  if (byteLength > SERVICE_NAME_MAX_BYTES) {
1075
- _chunkWC573FCIcjs.logger.warn(
1076
- `Service name is ${byteLength} bytes, over the ${SERVICE_NAME_MAX_BYTES}-byte limit; keeping the configured appName.`
1077
- );
1072
+ return `is ${byteLength} bytes, over the ${SERVICE_NAME_MAX_BYTES}-byte limit`;
1073
+ }
1074
+ return void 0;
1075
+ }
1076
+ function serviceNameProperties(name) {
1077
+ const problem = serviceNameProblem(name);
1078
+ if (problem !== void 0) {
1079
+ _chunkWC573FCIcjs.logger.warn(`Service name ${problem}; keeping the configured appName.`);
1078
1080
  return {};
1079
1081
  }
1080
- return { [_chunk5WBPX342cjs.SERVICE_NAME]: name };
1082
+ return { [_chunkGMZQ6N77cjs.SERVICE_NAME]: name };
1081
1083
  }
1082
1084
  function setServiceName(name) {
1083
1085
  const properties = serviceNameProperties(name);
@@ -1091,22 +1093,22 @@ function withServiceName(name, fn, thisArg) {
1091
1093
  return withProperties(serviceNameProperties(name), fn, thisArg);
1092
1094
  }
1093
1095
  function resolveServiceNameFromContext() {
1094
- const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1095
- return _optionalChain([props, 'optionalAccess', _56 => _56[_chunk5WBPX342cjs.SERVICE_NAME]]);
1096
+ const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1097
+ return _optionalChain([props, 'optionalAccess', _56 => _56[_chunkGMZQ6N77cjs.SERVICE_NAME]]);
1096
1098
  }
1097
1099
  function userProperties(user) {
1098
- const properties = { [_chunk5WBPX342cjs.USER_ID]: user.id };
1100
+ const properties = { [_chunkGMZQ6N77cjs.USER_ID]: user.id };
1099
1101
  if (user.email !== void 0) {
1100
- properties[_chunk5WBPX342cjs.USER_EMAIL] = user.email;
1102
+ properties[_chunkGMZQ6N77cjs.USER_EMAIL] = user.email;
1101
1103
  }
1102
1104
  if (user.name !== void 0) {
1103
- properties[_chunk5WBPX342cjs.USER_NAME] = user.name;
1105
+ properties[_chunkGMZQ6N77cjs.USER_NAME] = user.name;
1104
1106
  }
1105
1107
  if (user.role !== void 0) {
1106
- properties[_chunk5WBPX342cjs.USER_ROLE] = user.role;
1108
+ properties[_chunkGMZQ6N77cjs.USER_ROLE] = user.role;
1107
1109
  }
1108
1110
  if (user.plan !== void 0) {
1109
- properties[_chunk5WBPX342cjs.USER_PLAN] = user.plan;
1111
+ properties[_chunkGMZQ6N77cjs.USER_PLAN] = user.plan;
1110
1112
  }
1111
1113
  if (user.traits) {
1112
1114
  for (const [key, value] of Object.entries(user.traits)) {
@@ -1119,15 +1121,15 @@ function userProperties(user) {
1119
1121
  return properties;
1120
1122
  }
1121
1123
  function organizationProperties(org) {
1122
- const properties = { [_chunk5WBPX342cjs.ORGANIZATION_ID]: org.id };
1124
+ const properties = { [_chunkGMZQ6N77cjs.ORGANIZATION_ID]: org.id };
1123
1125
  if (org.name !== void 0) {
1124
- properties[_chunk5WBPX342cjs.ORGANIZATION_NAME] = org.name;
1126
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_NAME] = org.name;
1125
1127
  }
1126
1128
  if (org.plan !== void 0) {
1127
- properties[_chunk5WBPX342cjs.ORGANIZATION_PLAN] = org.plan;
1129
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_PLAN] = org.plan;
1128
1130
  }
1129
1131
  if (org.domain !== void 0) {
1130
- properties[_chunk5WBPX342cjs.ORGANIZATION_DOMAIN] = org.domain;
1132
+ properties[_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN] = org.domain;
1131
1133
  }
1132
1134
  if (org.traits) {
1133
1135
  for (const [key, value] of Object.entries(org.traits)) {
@@ -1152,32 +1154,32 @@ function withOrganization(org, fn, thisArg) {
1152
1154
  return withProperties(organizationProperties(org), fn, thisArg);
1153
1155
  }
1154
1156
  function callWithMessageId(id, fn, thisArg, ...args) {
1155
- return callWithProperties({ [_chunk5WBPX342cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
1157
+ return callWithProperties({ [_chunkGMZQ6N77cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
1156
1158
  }
1157
1159
  function withMessageId(id, fn, thisArg) {
1158
- return withProperties({ [_chunk5WBPX342cjs.MESSAGE_ID]: id }, fn, thisArg);
1160
+ return withProperties({ [_chunkGMZQ6N77cjs.MESSAGE_ID]: id }, fn, thisArg);
1159
1161
  }
1160
1162
  function inheritedMuteTools() {
1161
- const properties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1162
- return _optionalChain([properties, 'optionalAccess', _57 => _57[_chunk5WBPX342cjs.MUTE_TOOLS]]);
1163
+ const properties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1164
+ return _optionalChain([properties, 'optionalAccess', _57 => _57[_chunkGMZQ6N77cjs.MUTE_TOOLS]]);
1163
1165
  }
1164
1166
  function muteProperties(options) {
1165
1167
  const { input = true, output = true, tools = output } = options;
1166
1168
  const properties = {};
1167
1169
  if (input) {
1168
- properties[_chunk5WBPX342cjs.MUTE_INPUT] = "true";
1170
+ properties[_chunkGMZQ6N77cjs.MUTE_INPUT] = "true";
1169
1171
  }
1170
1172
  if (output) {
1171
- properties[_chunk5WBPX342cjs.MUTE_OUTPUT] = "true";
1173
+ properties[_chunkGMZQ6N77cjs.MUTE_OUTPUT] = "true";
1172
1174
  }
1173
1175
  if (tools !== output) {
1174
- properties[_chunk5WBPX342cjs.MUTE_TOOLS] = String(tools);
1176
+ properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = String(tools);
1175
1177
  } else {
1176
1178
  const inherited = inheritedMuteTools();
1177
1179
  if (tools && inherited === "false") {
1178
- properties[_chunk5WBPX342cjs.MUTE_TOOLS] = "true";
1180
+ properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = "true";
1179
1181
  } else if (options.tools === false && inherited === "true") {
1180
- properties[_chunk5WBPX342cjs.MUTE_TOOLS] = "false";
1182
+ properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = "false";
1181
1183
  }
1182
1184
  }
1183
1185
  return properties;
@@ -1189,11 +1191,11 @@ function withMute(options, fn, thisArg) {
1189
1191
  return withProperties(muteProperties(options), fn, thisArg);
1190
1192
  }
1191
1193
  function withSessionId(sessionId, fn, thisArg, extraProperties) {
1192
- const properties = { [_chunk5WBPX342cjs.SESSION_ID]: sessionId, ...extraProperties };
1194
+ const properties = { [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId, ...extraProperties };
1193
1195
  return withProperties(properties, fn, thisArg);
1194
1196
  }
1195
1197
  function callWithSessionId(sessionId, fn, thisArg, ...args) {
1196
- return callWithProperties({ [_chunk5WBPX342cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
1198
+ return callWithProperties({ [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
1197
1199
  }
1198
1200
  var Session = (_class2 = class {
1199
1201
 
@@ -1221,8 +1223,8 @@ var Session = (_class2 = class {
1221
1223
  setInput(text, context7) {
1222
1224
  this.inputs.push(text);
1223
1225
  this.inputContexts.push(_nullishCoalesce(context7, () => ( {})));
1224
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT, JSON.stringify(this.inputs));
1225
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
1226
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_INPUT, JSON.stringify(this.inputs));
1227
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
1226
1228
  }
1227
1229
  /**
1228
1230
  * Append an assistant turn to session output tracking.
@@ -1237,8 +1239,8 @@ var Session = (_class2 = class {
1237
1239
  setOutput(text, context7) {
1238
1240
  this.outputs.push(text);
1239
1241
  this.outputContexts.push(_nullishCoalesce(context7, () => ( {})));
1240
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
1241
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
1242
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
1243
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
1242
1244
  }
1243
1245
  /**
1244
1246
  * Set the session title on the span.
@@ -1246,7 +1248,7 @@ var Session = (_class2 = class {
1246
1248
  * @param title - The generated title string
1247
1249
  */
1248
1250
  setTitle(title) {
1249
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_TITLE, title);
1251
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_TITLE, title);
1250
1252
  }
1251
1253
  /**
1252
1254
  * Update custom properties on the session span.
@@ -1256,7 +1258,7 @@ var Session = (_class2 = class {
1256
1258
  */
1257
1259
  updateProperties(properties) {
1258
1260
  for (const [key, value] of Object.entries(properties)) {
1259
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
1261
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
1260
1262
  }
1261
1263
  }
1262
1264
  /**
@@ -1268,21 +1270,21 @@ var Session = (_class2 = class {
1268
1270
  setUser(user) {
1269
1271
  if (user.traits) {
1270
1272
  for (const [key, value] of Object.entries(user.traits)) {
1271
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.user.${key}`, value);
1273
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.user.${key}`, value);
1272
1274
  }
1273
1275
  }
1274
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_ID}`, user.id);
1276
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_ID}`, user.id);
1275
1277
  if (user.email !== void 0) {
1276
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_EMAIL}`, user.email);
1278
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_EMAIL}`, user.email);
1277
1279
  }
1278
1280
  if (user.name !== void 0) {
1279
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_NAME}`, user.name);
1281
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_NAME}`, user.name);
1280
1282
  }
1281
1283
  if (user.role !== void 0) {
1282
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_ROLE}`, user.role);
1284
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_ROLE}`, user.role);
1283
1285
  }
1284
1286
  if (user.plan !== void 0) {
1285
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.USER_PLAN}`, user.plan);
1287
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_PLAN}`, user.plan);
1286
1288
  }
1287
1289
  }
1288
1290
  /**
@@ -1294,18 +1296,18 @@ var Session = (_class2 = class {
1294
1296
  setOrganization(org) {
1295
1297
  if (org.traits) {
1296
1298
  for (const [key, value] of Object.entries(org.traits)) {
1297
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.organization.${key}`, value);
1299
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.organization.${key}`, value);
1298
1300
  }
1299
1301
  }
1300
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_ID}`, org.id);
1302
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_ID}`, org.id);
1301
1303
  if (org.name !== void 0) {
1302
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_NAME}`, org.name);
1304
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_NAME}`, org.name);
1303
1305
  }
1304
1306
  if (org.plan !== void 0) {
1305
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_PLAN}`, org.plan);
1307
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_PLAN}`, org.plan);
1306
1308
  }
1307
1309
  if (org.domain !== void 0) {
1308
- this.span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.ORGANIZATION_DOMAIN}`, org.domain);
1310
+ this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN}`, org.domain);
1309
1311
  }
1310
1312
  }
1311
1313
  /**
@@ -1335,30 +1337,30 @@ var SessionTitle = class {
1335
1337
  * @param title - The generated title string
1336
1338
  */
1337
1339
  setTitle(title) {
1338
- this.span.setAttribute(_chunk5WBPX342cjs.SESSION_TITLE, title);
1340
+ this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_TITLE, title);
1339
1341
  }
1340
1342
  };
1341
1343
  function getActiveSession() {
1342
- return _api.context.active().getValue(_chunk5WBPX342cjs.SESSION_OBJECT_CONTEXT_KEY);
1344
+ return _api.context.active().getValue(_chunkGMZQ6N77cjs.SESSION_OBJECT_CONTEXT_KEY);
1343
1345
  }
1344
1346
  function resolveSessionIdFromContext() {
1345
1347
  const active = getActiveSession();
1346
1348
  if (active) {
1347
1349
  return active.sessionId;
1348
1350
  }
1349
- const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1350
- return _optionalChain([props, 'optionalAccess', _60 => _60[_chunk5WBPX342cjs.SESSION_ID]]);
1351
+ const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1352
+ return _optionalChain([props, 'optionalAccess', _60 => _60[_chunkGMZQ6N77cjs.SESSION_ID]]);
1351
1353
  }
1352
1354
  function resolveMessageIdFromContext() {
1353
- const props = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
1354
- return _optionalChain([props, 'optionalAccess', _61 => _61[_chunk5WBPX342cjs.MESSAGE_ID]]);
1355
+ const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1356
+ return _optionalChain([props, 'optionalAccess', _61 => _61[_chunkGMZQ6N77cjs.MESSAGE_ID]]);
1355
1357
  }
1356
1358
  function emitExternalLink(sessionId, url, title, linkType) {
1357
1359
  try {
1358
- emitEventWithSessionId(sessionId, _chunk5WBPX342cjs.EXTERNAL_LINK_EVENT_NAME, {
1359
- [_chunk5WBPX342cjs.EXTERNAL_LINK_URL]: url,
1360
- [_chunk5WBPX342cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
1361
- [_chunk5WBPX342cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
1360
+ emitEventWithSessionId(sessionId, _chunkGMZQ6N77cjs.EXTERNAL_LINK_EVENT_NAME, {
1361
+ [_chunkGMZQ6N77cjs.EXTERNAL_LINK_URL]: url,
1362
+ [_chunkGMZQ6N77cjs.EXTERNAL_LINK_TITLE]: _nullishCoalesce(title, () => ( "")),
1363
+ [_chunkGMZQ6N77cjs.EXTERNAL_LINK_TYPE]: _nullishCoalesce(linkType, () => ( "generic"))
1362
1364
  });
1363
1365
  } catch (error) {
1364
1366
  _chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
@@ -1375,22 +1377,22 @@ function addExternalLink(url, options) {
1375
1377
  emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _63 => _63.title]), _optionalChain([options, 'optionalAccess', _64 => _64.linkType]));
1376
1378
  }
1377
1379
  function recordFeedback(type, options) {
1378
- const eventAttributes = { [_chunk5WBPX342cjs.FEEDBACK_TYPE]: type };
1380
+ const eventAttributes = { [_chunkGMZQ6N77cjs.FEEDBACK_TYPE]: type };
1379
1381
  if (_optionalChain([options, 'optionalAccess', _65 => _65.score]) !== void 0) {
1380
- eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SCORE] = options.score;
1382
+ eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_SCORE] = options.score;
1381
1383
  }
1382
1384
  if (_optionalChain([options, 'optionalAccess', _66 => _66.reason]) !== void 0) {
1383
- eventAttributes[_chunk5WBPX342cjs.FEEDBACK_REASON] = options.reason;
1385
+ eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_REASON] = options.reason;
1384
1386
  }
1385
1387
  if (_optionalChain([options, 'optionalAccess', _67 => _67.comment]) !== void 0) {
1386
- eventAttributes[_chunk5WBPX342cjs.FEEDBACK_COMMENT] = options.comment;
1388
+ eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_COMMENT] = options.comment;
1387
1389
  }
1388
1390
  if (_optionalChain([options, 'optionalAccess', _68 => _68.source]) !== void 0) {
1389
- eventAttributes[_chunk5WBPX342cjs.FEEDBACK_SOURCE] = options.source;
1391
+ eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_SOURCE] = options.source;
1390
1392
  }
1391
1393
  if (_optionalChain([options, 'optionalAccess', _69 => _69.attributes])) {
1392
1394
  for (const [key, value] of Object.entries(options.attributes)) {
1393
- const k = `${_chunk5WBPX342cjs.FEEDBACK_ATTR_PREFIX}${key}`;
1395
+ const k = `${_chunkGMZQ6N77cjs.FEEDBACK_ATTR_PREFIX}${key}`;
1394
1396
  if (eventAttributes[k] === void 0) {
1395
1397
  eventAttributes[k] = value;
1396
1398
  }
@@ -1405,16 +1407,16 @@ function recordFeedback(type, options) {
1405
1407
  }
1406
1408
  const anchor = {};
1407
1409
  if (messageId !== void 0) {
1408
- anchor[_chunk5WBPX342cjs.MESSAGE_ID] = messageId;
1410
+ anchor[_chunkGMZQ6N77cjs.MESSAGE_ID] = messageId;
1409
1411
  }
1410
1412
  if (sessionId !== void 0) {
1411
- anchor[_chunk5WBPX342cjs.SESSION_ID] = sessionId;
1413
+ anchor[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
1412
1414
  }
1413
1415
  try {
1414
1416
  if (Object.keys(anchor).length === 0) {
1415
- emitEvent(_chunk5WBPX342cjs.FEEDBACK_EVENT_NAME, eventAttributes);
1417
+ emitEvent(_chunkGMZQ6N77cjs.FEEDBACK_EVENT_NAME, eventAttributes);
1416
1418
  } else {
1417
- callWithProperties(anchor, () => emitEvent(_chunk5WBPX342cjs.FEEDBACK_EVENT_NAME, eventAttributes));
1419
+ callWithProperties(anchor, () => emitEvent(_chunkGMZQ6N77cjs.FEEDBACK_EVENT_NAME, eventAttributes));
1418
1420
  }
1419
1421
  } catch (error) {
1420
1422
  _chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
@@ -1439,7 +1441,7 @@ function recordMetricImpl(options) {
1439
1441
  );
1440
1442
  return;
1441
1443
  }
1442
- if (_chunk5WBPX342cjs.RESERVED_METRIC_NAMES.has(name)) {
1444
+ if (_chunkGMZQ6N77cjs.RESERVED_METRIC_NAMES.has(name)) {
1443
1445
  _chunkWC573FCIcjs.logger.warn(
1444
1446
  `recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
1445
1447
  );
@@ -1457,18 +1459,25 @@ function recordMetricImpl(options) {
1457
1459
  );
1458
1460
  return;
1459
1461
  }
1462
+ if (options.serviceName !== void 0) {
1463
+ const problem = serviceNameProblem(options.serviceName);
1464
+ if (problem !== void 0) {
1465
+ _chunkWC573FCIcjs.logger.warn(`recordMetric(${name}) service name ${problem}; metric dropped.`);
1466
+ return;
1467
+ }
1468
+ }
1460
1469
  const eventAttributes = {
1461
- [_chunk5WBPX342cjs.METRIC_NAME]: name,
1462
- [_chunk5WBPX342cjs.METRIC_VALUE]: numericValue
1470
+ [_chunkGMZQ6N77cjs.METRIC_NAME]: name,
1471
+ [_chunkGMZQ6N77cjs.METRIC_VALUE]: numericValue
1463
1472
  };
1464
1473
  if (options.unit !== void 0) {
1465
- eventAttributes[_chunk5WBPX342cjs.METRIC_UNIT] = options.unit;
1474
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_UNIT] = options.unit;
1466
1475
  }
1467
1476
  if (options.minValue !== void 0) {
1468
- eventAttributes[_chunk5WBPX342cjs.METRIC_MIN] = options.minValue;
1477
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_MIN] = options.minValue;
1469
1478
  }
1470
1479
  if (options.maxValue !== void 0) {
1471
- eventAttributes[_chunk5WBPX342cjs.METRIC_MAX] = options.maxValue;
1480
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_MAX] = options.maxValue;
1472
1481
  }
1473
1482
  if (options.comment !== void 0) {
1474
1483
  let comment = options.comment;
@@ -1478,21 +1487,21 @@ function recordMetricImpl(options) {
1478
1487
  );
1479
1488
  comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
1480
1489
  }
1481
- eventAttributes[_chunk5WBPX342cjs.METRIC_COMMENT] = comment;
1490
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_COMMENT] = comment;
1482
1491
  }
1483
1492
  if (options.polarity !== void 0) {
1484
1493
  const polarity = options.polarity;
1485
- if (polarity === _chunk5WBPX342cjs.METRIC_POLARITY_POSITIVE || polarity === _chunk5WBPX342cjs.METRIC_POLARITY_NEGATIVE) {
1486
- eventAttributes[_chunk5WBPX342cjs.METRIC_POLARITY] = polarity;
1494
+ if (polarity === _chunkGMZQ6N77cjs.METRIC_POLARITY_POSITIVE || polarity === _chunkGMZQ6N77cjs.METRIC_POLARITY_NEGATIVE) {
1495
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_POLARITY] = polarity;
1487
1496
  } else {
1488
1497
  _chunkWC573FCIcjs.logger.warn(
1489
- `recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${_chunk5WBPX342cjs.METRIC_POLARITY_POSITIVE}' or '${_chunk5WBPX342cjs.METRIC_POLARITY_NEGATIVE}'. Emitting the metric without it.`
1498
+ `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.`
1490
1499
  );
1491
1500
  }
1492
1501
  }
1493
1502
  if (options.timestamp !== void 0) {
1494
1503
  if (Number.isFinite(options.timestamp.getTime())) {
1495
- eventAttributes[_chunk5WBPX342cjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1504
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
1496
1505
  } else {
1497
1506
  _chunkWC573FCIcjs.logger.warn(
1498
1507
  `recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
@@ -1522,21 +1531,37 @@ function recordMetricImpl(options) {
1522
1531
  );
1523
1532
  text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
1524
1533
  }
1525
- eventAttributes[`${_chunk5WBPX342cjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1534
+ eventAttributes[`${_chunkGMZQ6N77cjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
1526
1535
  accepted += 1;
1527
1536
  }
1528
1537
  }
1529
- const sessionId = _nullishCoalesce(options.sessionId, () => ( resolveSessionIdFromContext()));
1530
- if (sessionId === void 0) {
1538
+ const traceId = typeof options.traceId === "string" && options.traceId !== "" ? options.traceId : void 0;
1539
+ if (traceId !== void 0) {
1540
+ eventAttributes[_chunkGMZQ6N77cjs.METRIC_TRACE_ID] = traceId;
1541
+ }
1542
+ const sessionId = _nullishCoalesce(options.sessionId, () => ( (traceId === void 0 ? resolveSessionIdFromContext() : void 0)));
1543
+ if (sessionId === void 0 && traceId === void 0) {
1531
1544
  _chunkWC573FCIcjs.logger.warn(
1532
- `recordMetric(${name}) called with no resolvable session id; the metric cannot be attributed to a conversation and is dropped. Pass options.sessionId or call inside a startSession/callWithSessionId scope.`
1545
+ `recordMetric(${name}) called with no resolvable session id or trace id; the metric cannot be attributed to a conversation and is dropped. Pass options.sessionId or options.traceId, or call inside a startSession/callWithSessionId scope.`
1533
1546
  );
1534
1547
  return;
1535
1548
  }
1549
+ const base = _api.context.active();
1550
+ const ambient = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
1551
+ const properties = { ...ambient };
1552
+ if (sessionId === void 0) {
1553
+ delete properties[_chunkGMZQ6N77cjs.SESSION_ID];
1554
+ delete properties[_chunkGMZQ6N77cjs.MESSAGE_ID];
1555
+ } else {
1556
+ properties[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
1557
+ }
1558
+ if (options.serviceName !== void 0) {
1559
+ properties[_chunkGMZQ6N77cjs.SERVICE_NAME] = options.serviceName;
1560
+ }
1536
1561
  try {
1537
- callWithProperties(
1538
- { [_chunk5WBPX342cjs.SESSION_ID]: sessionId },
1539
- () => emitEvent(_chunk5WBPX342cjs.METRIC_EVENT_NAME, eventAttributes)
1562
+ _api.context.with(
1563
+ base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, properties),
1564
+ () => emitEvent(_chunkGMZQ6N77cjs.METRIC_EVENT_NAME, eventAttributes)
1540
1565
  );
1541
1566
  } catch (error) {
1542
1567
  _chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
@@ -1544,19 +1569,19 @@ function recordMetricImpl(options) {
1544
1569
  }
1545
1570
  function startSession(sessionId, callback, extraProperties, options) {
1546
1571
  const isTitle = _optionalChain([options, 'optionalAccess', _73 => _73.mode]) === "title";
1547
- const spanName = isTitle ? _chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME : _chunk5WBPX342cjs.SESSION_SPAN_NAME;
1572
+ const spanName = isTitle ? _chunkGMZQ6N77cjs.SESSION_TITLE_SPAN_NAME : _chunkGMZQ6N77cjs.SESSION_SPAN_NAME;
1548
1573
  const tracer = _api.trace.getTracer("@brizz/sdk");
1549
1574
  return tracer.startActiveSpan(spanName, (span) => {
1550
- span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.SESSION_ID}`, sessionId);
1575
+ span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.SESSION_ID}`, sessionId);
1551
1576
  if (extraProperties) {
1552
1577
  for (const [key, value] of Object.entries(extraProperties)) {
1553
- span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
1578
+ span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
1554
1579
  }
1555
1580
  }
1556
1581
  const session = new Session(sessionId, span);
1557
- const contextProperties = { [_chunk5WBPX342cjs.SESSION_ID]: sessionId };
1582
+ const contextProperties = { [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId };
1558
1583
  if (isTitle) {
1559
- contextProperties[_chunk5WBPX342cjs.SESSION_TITLE_GENERATION] = "true";
1584
+ contextProperties[_chunkGMZQ6N77cjs.SESSION_TITLE_GENERATION] = "true";
1560
1585
  }
1561
1586
  if (extraProperties) {
1562
1587
  for (const [key, value] of Object.entries(extraProperties)) {
@@ -1564,7 +1589,7 @@ function startSession(sessionId, callback, extraProperties, options) {
1564
1589
  }
1565
1590
  }
1566
1591
  return callWithProperties(contextProperties, () => {
1567
- const sessionCtx = _api.context.active().setValue(_chunk5WBPX342cjs.SESSION_OBJECT_CONTEXT_KEY, session);
1592
+ const sessionCtx = _api.context.active().setValue(_chunkGMZQ6N77cjs.SESSION_OBJECT_CONTEXT_KEY, session);
1568
1593
  return _api.context.with(sessionCtx, () => {
1569
1594
  try {
1570
1595
  const result = callback(session);
@@ -1594,14 +1619,14 @@ function startSession(sessionId, callback, extraProperties, options) {
1594
1619
  function startSessionTitle(callback, options) {
1595
1620
  const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _74 => _74.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _75 => _75(), 'optionalAccess', _76 => _76.sessionId])));
1596
1621
  const tracer = _api.trace.getTracer("@brizz/sdk");
1597
- return tracer.startActiveSpan(_chunk5WBPX342cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1622
+ return tracer.startActiveSpan(_chunkGMZQ6N77cjs.SESSION_TITLE_SPAN_NAME, (span) => {
1598
1623
  if (resolvedSessionId) {
1599
- span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${_chunk5WBPX342cjs.SESSION_ID}`, resolvedSessionId);
1624
+ span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.SESSION_ID}`, resolvedSessionId);
1600
1625
  }
1601
1626
  const sessionTitle = new SessionTitle(span);
1602
- const properties = { [_chunk5WBPX342cjs.SESSION_TITLE_GENERATION]: "true" };
1627
+ const properties = { [_chunkGMZQ6N77cjs.SESSION_TITLE_GENERATION]: "true" };
1603
1628
  if (resolvedSessionId) {
1604
- properties[_chunk5WBPX342cjs.SESSION_ID] = resolvedSessionId;
1629
+ properties[_chunkGMZQ6N77cjs.SESSION_ID] = resolvedSessionId;
1605
1630
  }
1606
1631
  return callWithProperties(properties, () => {
1607
1632
  try {
@@ -2068,10 +2093,10 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
2068
2093
  if (maskingConfig) {
2069
2094
  maskLog(logRecord, maskingConfig);
2070
2095
  }
2071
- const associationProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
2096
+ const associationProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2072
2097
  if (associationProperties) {
2073
2098
  for (const [key, value] of Object.entries(associationProperties)) {
2074
- logRecord.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
2099
+ logRecord.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2075
2100
  }
2076
2101
  }
2077
2102
  super.onEmit(logRecord);
@@ -2088,10 +2113,10 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
2088
2113
  if (maskingConfig) {
2089
2114
  maskLog(logRecord, maskingConfig);
2090
2115
  }
2091
- const associationProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
2116
+ const associationProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2092
2117
  if (associationProperties) {
2093
2118
  for (const [key, value] of Object.entries(associationProperties)) {
2094
- logRecord.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
2119
+ logRecord.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2095
2120
  }
2096
2121
  }
2097
2122
  super.onEmit(logRecord);
@@ -2118,7 +2143,7 @@ function maskLog(logRecord, config) {
2118
2143
  newAttributes[key] = value;
2119
2144
  }
2120
2145
  for (const [key, value] of Object.entries(logRecord.attributes)) {
2121
- if (key.startsWith(_chunk5WBPX342cjs.INTERNAL_EVENT_PREFIX)) {
2146
+ if (key.startsWith(_chunkGMZQ6N77cjs.INTERNAL_EVENT_PREFIX)) {
2122
2147
  newAttributes[key] = value;
2123
2148
  }
2124
2149
  }
@@ -2161,7 +2186,16 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
2161
2186
  createLogExporter(config, serviceName) {
2162
2187
  if (config.customLogExporter) {
2163
2188
  _chunkWC573FCIcjs.logger.debug("Using custom log exporter");
2164
- return config.customLogExporter;
2189
+ if (serviceName === config.appName) {
2190
+ return config.customLogExporter;
2191
+ }
2192
+ const shared = config.customLogExporter;
2193
+ return {
2194
+ export: (logs, resultCallback) => shared.export(logs, resultCallback),
2195
+ forceFlush: async () => shared.forceFlush(),
2196
+ shutdown: async () => {
2197
+ }
2198
+ };
2165
2199
  }
2166
2200
  const logsUrl = config.baseUrl.replace(/\/$/, "") + "/v1/logs";
2167
2201
  _chunkWC573FCIcjs.logger.debug("Initializing default OTLP log exporter", { url: logsUrl, serviceName });
@@ -2183,7 +2217,7 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
2183
2217
  const resourceAttributes = {
2184
2218
  ...config.resourceAttributes,
2185
2219
  "service.name": serviceName,
2186
- [BRIZZ_SDK_VERSION]: _chunkEWT4TUB7cjs.getSDKVersion.call(void 0, ),
2220
+ [BRIZZ_SDK_VERSION]: _chunkJDJLJ2V2cjs.getSDKVersion.call(void 0, ),
2187
2221
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2188
2222
  };
2189
2223
  if (config.environment) {
@@ -2287,12 +2321,12 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
2287
2321
  */
2288
2322
  async shutdown() {
2289
2323
  _chunkWC573FCIcjs.logger.debug("Shutting down logging module");
2324
+ await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
2325
+ this.scopedProviders.clear();
2290
2326
  if (this.loggerProvider) {
2291
2327
  await this.loggerProvider.shutdown();
2292
2328
  this.loggerProvider = null;
2293
2329
  }
2294
- await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
2295
- this.scopedProviders.clear();
2296
2330
  this.config = null;
2297
2331
  if (_LoggingModule.instance === this) {
2298
2332
  _LoggingModule.instance = null;
@@ -2432,7 +2466,7 @@ var BrizzSpanExporter = (_class5 = class {
2432
2466
  const resourceAttrs = {
2433
2467
  ...config.resourceAttributes,
2434
2468
  "service.name": config.appName,
2435
- [BRIZZ_SDK_VERSION]: _chunkEWT4TUB7cjs.getSDKVersion.call(void 0, ),
2469
+ [BRIZZ_SDK_VERSION]: _chunkJDJLJ2V2cjs.getSDKVersion.call(void 0, ),
2436
2470
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2437
2471
  };
2438
2472
  if (config.environment) {
@@ -2446,7 +2480,7 @@ var BrizzSpanExporter = (_class5 = class {
2446
2480
  }
2447
2481
  /** The service a span reports under: its scoped override, else the configured appName. */
2448
2482
  _serviceNameOf(span) {
2449
- const value = span.attributes[_chunk5WBPX342cjs.SERVICE_NAME_ATTRIBUTE];
2483
+ const value = span.attributes[_chunkGMZQ6N77cjs.SERVICE_NAME_ATTRIBUTE];
2450
2484
  return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
2451
2485
  }
2452
2486
  _resourceFor(serviceName) {
@@ -2572,10 +2606,10 @@ var BrizzSpanExporter = (_class5 = class {
2572
2606
 
2573
2607
  var _sdktracebase = require('@opentelemetry/sdk-trace-base');
2574
2608
  function applyContextAttributes(span) {
2575
- const sessionProperties = _api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY);
2609
+ const sessionProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
2576
2610
  if (sessionProperties) {
2577
2611
  for (const [key, value] of Object.entries(sessionProperties)) {
2578
- span.setAttribute(`${_chunk5WBPX342cjs.BRIZZ}.${key}`, value);
2612
+ span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
2579
2613
  }
2580
2614
  }
2581
2615
  }
@@ -2774,7 +2808,7 @@ function newInstanceId() {
2774
2808
  return _crypto.randomUUID.call(void 0, ).replaceAll("-", "").slice(0, 8);
2775
2809
  }
2776
2810
  function activeProperties() {
2777
- return _nullishCoalesce(_api.context.active().getValue(_chunk5WBPX342cjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
2811
+ return _nullishCoalesce(_api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
2778
2812
  }
2779
2813
  function encodeToken(agent) {
2780
2814
  const payload = {
@@ -2800,7 +2834,7 @@ function agentHandle(id, parentId, name) {
2800
2834
  parentId,
2801
2835
  name,
2802
2836
  traceparent: currentTraceparent(),
2803
- sessionId: _nullishCoalesce(activeProperties()[_chunk5WBPX342cjs.SESSION_ID], () => ( ""))
2837
+ sessionId: _nullishCoalesce(activeProperties()[_chunkGMZQ6N77cjs.SESSION_ID], () => ( ""))
2804
2838
  };
2805
2839
  return {
2806
2840
  ...opened,
@@ -2836,7 +2870,7 @@ function resolveAgent(agent) {
2836
2870
  let parentContext = _api.context.active();
2837
2871
  if (options.token === void 0) {
2838
2872
  id = options.id || newInstanceId();
2839
- parentId = options.parentId || activeProperties()[_chunk5WBPX342cjs.AGENT_ID] || "";
2873
+ parentId = options.parentId || activeProperties()[_chunkGMZQ6N77cjs.AGENT_ID] || "";
2840
2874
  name = _nullishCoalesce(options.name, () => ( ""));
2841
2875
  } else {
2842
2876
  const decoded = decodeToken(options.token);
@@ -2855,12 +2889,12 @@ function resolveAgent(agent) {
2855
2889
  }
2856
2890
  }
2857
2891
  }
2858
- const properties = { [_chunk5WBPX342cjs.AGENT_ID]: id, [_chunk5WBPX342cjs.AGENT_NAME]: name };
2892
+ const properties = { [_chunkGMZQ6N77cjs.AGENT_ID]: id, [_chunkGMZQ6N77cjs.AGENT_NAME]: name };
2859
2893
  if (parentId) {
2860
- properties[_chunk5WBPX342cjs.AGENT_PARENT_ID] = parentId;
2894
+ properties[_chunkGMZQ6N77cjs.AGENT_PARENT_ID] = parentId;
2861
2895
  }
2862
2896
  if (sessionId) {
2863
- properties[_chunk5WBPX342cjs.SESSION_ID] = sessionId;
2897
+ properties[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
2864
2898
  }
2865
2899
  return { id, parentId, name, properties, parentContext };
2866
2900
  }
@@ -2923,7 +2957,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2923
2957
  */
2924
2958
  setupInstrumentation(options) {
2925
2959
  const registry = InstrumentationRegistry.getInstance();
2926
- _chunkEWT4TUB7cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
2960
+ _chunkJDJLJ2V2cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
2927
2961
  patchInstalledCallbackManager();
2928
2962
  if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
2929
2963
  registry.setManualModules(options.instrumentModules);
@@ -2947,7 +2981,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2947
2981
  const resourceAttributes = {
2948
2982
  ...resolvedConfig.resourceAttributes,
2949
2983
  "service.name": resolvedConfig.appName,
2950
- [BRIZZ_SDK_VERSION]: _chunkEWT4TUB7cjs.getSDKVersion.call(void 0, ),
2984
+ [BRIZZ_SDK_VERSION]: _chunkJDJLJ2V2cjs.getSDKVersion.call(void 0, ),
2951
2985
  [BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
2952
2986
  };
2953
2987
  if (resolvedConfig.environment) {
@@ -2959,7 +2993,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
2959
2993
  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));
2960
2994
  this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
2961
2995
  resource,
2962
- spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunk3IGBYXLRcjs.InterruptPropagator)(), getSpanProcessor()]
2996
+ spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkELLCNMLIcjs.InterruptPropagator)(), getSpanProcessor()]
2963
2997
  });
2964
2998
  this._tracerProvider.register();
2965
2999
  this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });