@brizz/sdk 0.1.49 → 0.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/{chunk-3OMB2F7B.js → chunk-7PRTTYWM.js} +1 -1
- package/dist/{chunk-HTFR2LKY.js → chunk-G6GTIFEQ.js} +2 -2
- package/dist/{chunk-FVVRWMPV.js → chunk-GUKWVI53.js} +7 -1
- package/dist/{chunk-VAUO47L3.cjs → chunk-JSTTHMQ3.cjs} +8 -8
- package/dist/{chunk-ELLCNMLI.cjs → chunk-O2IBZJOJ.cjs} +4 -4
- package/dist/{chunk-GMZQ6N77.cjs → chunk-RV7JIIDG.cjs} +7 -1
- package/dist/index.cjs +208 -165
- package/dist/index.js +58 -15
- package/dist/interrupt-BYLSBXTV.cjs +12 -0
- package/dist/{interrupt-YO3ID433.js → interrupt-UKJK5WOA.js} +2 -2
- package/dist/{mcp-LIAXZGBN.js → mcp-2ZFV5BK5.js} +2 -2
- package/dist/{mcp-FWGIYACB.cjs → mcp-FCUYTDGN.cjs} +12 -12
- package/dist/types/cjs/internal/semantic-conventions.d.ts +3 -0
- package/dist/types/cjs/internal/trace/session.d.ts +1 -0
- package/dist/types/esm/internal/semantic-conventions.d.ts +3 -0
- package/dist/types/esm/internal/trace/session.d.ts +1 -0
- package/package.json +1 -1
- package/dist/interrupt-YQHEXVES.cjs +0 -12
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkUNLNNKZ7cjs = require('./chunk-UNLNNKZ7.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkJSTTHMQ3cjs = require('./chunk-JSTTHMQ3.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
|
|
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
|
-
|
|
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 =
|
|
107
|
+
var INSTRUMENTATION_VERSION = _chunkJSTTHMQ3cjs.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-
|
|
471
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-FCUYTDGN.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-
|
|
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
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
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(
|
|
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[`${
|
|
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(`"${
|
|
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(`${
|
|
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-
|
|
967
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-FCUYTDGN.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(`${
|
|
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(
|
|
1025
|
+
const prev = base.getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
1023
1026
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
1024
|
-
const next = base.setValue(
|
|
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(
|
|
1048
|
+
const prev = base.getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
1046
1049
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
1047
|
-
store.enterWith(base.setValue(
|
|
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 = { [
|
|
1055
|
+
const properties = { [_chunkRV7JIIDGcjs.USER_ID]: user.id };
|
|
1053
1056
|
if (user.email !== void 0) {
|
|
1054
|
-
properties[
|
|
1057
|
+
properties[_chunkRV7JIIDGcjs.USER_EMAIL] = user.email;
|
|
1055
1058
|
}
|
|
1056
1059
|
if (user.name !== void 0) {
|
|
1057
|
-
properties[
|
|
1060
|
+
properties[_chunkRV7JIIDGcjs.USER_NAME] = user.name;
|
|
1058
1061
|
}
|
|
1059
1062
|
if (user.role !== void 0) {
|
|
1060
|
-
properties[
|
|
1063
|
+
properties[_chunkRV7JIIDGcjs.USER_ROLE] = user.role;
|
|
1061
1064
|
}
|
|
1062
1065
|
if (user.plan !== void 0) {
|
|
1063
|
-
properties[
|
|
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 = { [
|
|
1080
|
+
const properties = { [_chunkRV7JIIDGcjs.ORGANIZATION_ID]: org.id };
|
|
1078
1081
|
if (org.name !== void 0) {
|
|
1079
|
-
properties[
|
|
1082
|
+
properties[_chunkRV7JIIDGcjs.ORGANIZATION_NAME] = org.name;
|
|
1080
1083
|
}
|
|
1081
1084
|
if (org.plan !== void 0) {
|
|
1082
|
-
properties[
|
|
1085
|
+
properties[_chunkRV7JIIDGcjs.ORGANIZATION_PLAN] = org.plan;
|
|
1083
1086
|
}
|
|
1084
1087
|
if (org.domain !== void 0) {
|
|
1085
|
-
properties[
|
|
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 = { [
|
|
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 = { [
|
|
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 { [
|
|
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(
|
|
1143
|
-
return _optionalChain([props, 'optionalAccess', _56 => _56[
|
|
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 = { [
|
|
1149
|
+
const properties = { [_chunkRV7JIIDGcjs.USER_ID]: user.id };
|
|
1147
1150
|
if (user.email !== void 0) {
|
|
1148
|
-
properties[
|
|
1151
|
+
properties[_chunkRV7JIIDGcjs.USER_EMAIL] = user.email;
|
|
1149
1152
|
}
|
|
1150
1153
|
if (user.name !== void 0) {
|
|
1151
|
-
properties[
|
|
1154
|
+
properties[_chunkRV7JIIDGcjs.USER_NAME] = user.name;
|
|
1152
1155
|
}
|
|
1153
1156
|
if (user.role !== void 0) {
|
|
1154
|
-
properties[
|
|
1157
|
+
properties[_chunkRV7JIIDGcjs.USER_ROLE] = user.role;
|
|
1155
1158
|
}
|
|
1156
1159
|
if (user.plan !== void 0) {
|
|
1157
|
-
properties[
|
|
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 = { [
|
|
1173
|
+
const properties = { [_chunkRV7JIIDGcjs.ORGANIZATION_ID]: org.id };
|
|
1171
1174
|
if (org.name !== void 0) {
|
|
1172
|
-
properties[
|
|
1175
|
+
properties[_chunkRV7JIIDGcjs.ORGANIZATION_NAME] = org.name;
|
|
1173
1176
|
}
|
|
1174
1177
|
if (org.plan !== void 0) {
|
|
1175
|
-
properties[
|
|
1178
|
+
properties[_chunkRV7JIIDGcjs.ORGANIZATION_PLAN] = org.plan;
|
|
1176
1179
|
}
|
|
1177
1180
|
if (org.domain !== void 0) {
|
|
1178
|
-
properties[
|
|
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({ [
|
|
1206
|
+
return callWithProperties({ [_chunkRV7JIIDGcjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
|
|
1204
1207
|
}
|
|
1205
1208
|
function withMessageId(id, fn, thisArg) {
|
|
1206
|
-
return withProperties({ [
|
|
1209
|
+
return withProperties({ [_chunkRV7JIIDGcjs.MESSAGE_ID]: id }, fn, thisArg);
|
|
1207
1210
|
}
|
|
1208
1211
|
function inheritedMuteTools() {
|
|
1209
|
-
const properties = _api.context.active().getValue(
|
|
1210
|
-
return _optionalChain([properties, 'optionalAccess', _57 => _57[
|
|
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[
|
|
1219
|
+
properties[_chunkRV7JIIDGcjs.MUTE_INPUT] = "true";
|
|
1217
1220
|
}
|
|
1218
1221
|
if (output) {
|
|
1219
|
-
properties[
|
|
1222
|
+
properties[_chunkRV7JIIDGcjs.MUTE_OUTPUT] = "true";
|
|
1220
1223
|
}
|
|
1221
1224
|
if (tools !== output) {
|
|
1222
|
-
properties[
|
|
1225
|
+
properties[_chunkRV7JIIDGcjs.MUTE_TOOLS] = String(tools);
|
|
1223
1226
|
} else {
|
|
1224
1227
|
const inherited = inheritedMuteTools();
|
|
1225
1228
|
if (tools && inherited === "false") {
|
|
1226
|
-
properties[
|
|
1229
|
+
properties[_chunkRV7JIIDGcjs.MUTE_TOOLS] = "true";
|
|
1227
1230
|
} else if (options.tools === false && inherited === "true") {
|
|
1228
|
-
properties[
|
|
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 = { [
|
|
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({ [
|
|
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(
|
|
1273
|
-
this.span.setAttribute(
|
|
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(
|
|
1289
|
-
this.span.setAttribute(
|
|
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(
|
|
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(`${
|
|
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(`${
|
|
1322
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.user.${key}`, value);
|
|
1320
1323
|
}
|
|
1321
1324
|
}
|
|
1322
|
-
this.span.setAttribute(`${
|
|
1325
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_ID}`, user.id);
|
|
1323
1326
|
if (user.email !== void 0) {
|
|
1324
|
-
this.span.setAttribute(`${
|
|
1327
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_EMAIL}`, user.email);
|
|
1325
1328
|
}
|
|
1326
1329
|
if (user.name !== void 0) {
|
|
1327
|
-
this.span.setAttribute(`${
|
|
1330
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_NAME}`, user.name);
|
|
1328
1331
|
}
|
|
1329
1332
|
if (user.role !== void 0) {
|
|
1330
|
-
this.span.setAttribute(`${
|
|
1333
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.USER_ROLE}`, user.role);
|
|
1331
1334
|
}
|
|
1332
1335
|
if (user.plan !== void 0) {
|
|
1333
|
-
this.span.setAttribute(`${
|
|
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(`${
|
|
1348
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.organization.${key}`, value);
|
|
1346
1349
|
}
|
|
1347
1350
|
}
|
|
1348
|
-
this.span.setAttribute(`${
|
|
1351
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.ORGANIZATION_ID}`, org.id);
|
|
1349
1352
|
if (org.name !== void 0) {
|
|
1350
|
-
this.span.setAttribute(`${
|
|
1353
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.ORGANIZATION_NAME}`, org.name);
|
|
1351
1354
|
}
|
|
1352
1355
|
if (org.plan !== void 0) {
|
|
1353
|
-
this.span.setAttribute(`${
|
|
1356
|
+
this.span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.ORGANIZATION_PLAN}`, org.plan);
|
|
1354
1357
|
}
|
|
1355
1358
|
if (org.domain !== void 0) {
|
|
1356
|
-
this.span.setAttribute(`${
|
|
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(
|
|
1389
|
+
this.span.setAttribute(_chunkRV7JIIDGcjs.SESSION_TITLE, title);
|
|
1387
1390
|
}
|
|
1388
1391
|
};
|
|
1389
1392
|
function getActiveSession() {
|
|
1390
|
-
return _api.context.active().getValue(
|
|
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(
|
|
1398
|
-
return _optionalChain([props, 'optionalAccess', _60 => _60[
|
|
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(
|
|
1402
|
-
return _optionalChain([props, 'optionalAccess', _61 => _61[
|
|
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,
|
|
1407
|
-
[
|
|
1408
|
-
[
|
|
1409
|
-
[
|
|
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 = { [
|
|
1429
|
+
const eventAttributes = { [_chunkRV7JIIDGcjs.FEEDBACK_TYPE]: type };
|
|
1427
1430
|
if (_optionalChain([options, 'optionalAccess', _65 => _65.score]) !== void 0) {
|
|
1428
|
-
eventAttributes[
|
|
1431
|
+
eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_SCORE] = options.score;
|
|
1429
1432
|
}
|
|
1430
1433
|
if (_optionalChain([options, 'optionalAccess', _66 => _66.reason]) !== void 0) {
|
|
1431
|
-
eventAttributes[
|
|
1434
|
+
eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_REASON] = options.reason;
|
|
1432
1435
|
}
|
|
1433
1436
|
if (_optionalChain([options, 'optionalAccess', _67 => _67.comment]) !== void 0) {
|
|
1434
|
-
eventAttributes[
|
|
1437
|
+
eventAttributes[_chunkRV7JIIDGcjs.FEEDBACK_COMMENT] = options.comment;
|
|
1435
1438
|
}
|
|
1436
1439
|
if (_optionalChain([options, 'optionalAccess', _68 => _68.source]) !== void 0) {
|
|
1437
|
-
eventAttributes[
|
|
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 = `${
|
|
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[
|
|
1459
|
+
anchor[_chunkRV7JIIDGcjs.MESSAGE_ID] = messageId;
|
|
1457
1460
|
}
|
|
1458
1461
|
if (sessionId !== void 0) {
|
|
1459
|
-
anchor[
|
|
1462
|
+
anchor[_chunkRV7JIIDGcjs.SESSION_ID] = sessionId;
|
|
1460
1463
|
}
|
|
1461
1464
|
try {
|
|
1462
1465
|
if (Object.keys(anchor).length === 0) {
|
|
1463
|
-
emitEvent(
|
|
1466
|
+
emitEvent(_chunkRV7JIIDGcjs.FEEDBACK_EVENT_NAME, eventAttributes);
|
|
1464
1467
|
} else {
|
|
1465
|
-
callWithProperties(anchor, () => emitEvent(
|
|
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 (
|
|
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
|
-
[
|
|
1517
|
-
[
|
|
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[
|
|
1533
|
+
eventAttributes[_chunkRV7JIIDGcjs.METRIC_UNIT] = options.unit;
|
|
1521
1534
|
}
|
|
1522
1535
|
if (options.minValue !== void 0) {
|
|
1523
|
-
eventAttributes[
|
|
1536
|
+
eventAttributes[_chunkRV7JIIDGcjs.METRIC_MIN] = options.minValue;
|
|
1524
1537
|
}
|
|
1525
1538
|
if (options.maxValue !== void 0) {
|
|
1526
|
-
eventAttributes[
|
|
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[
|
|
1549
|
+
eventAttributes[_chunkRV7JIIDGcjs.METRIC_COMMENT] = comment;
|
|
1537
1550
|
}
|
|
1538
1551
|
if (options.polarity !== void 0) {
|
|
1539
1552
|
const polarity = options.polarity;
|
|
1540
|
-
if (polarity ===
|
|
1541
|
-
eventAttributes[
|
|
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 '${
|
|
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[
|
|
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[`${
|
|
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[
|
|
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(
|
|
1619
|
+
const ambient = base.getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY);
|
|
1597
1620
|
const properties = { ...ambient };
|
|
1598
1621
|
if (sessionId === void 0) {
|
|
1599
|
-
delete properties[
|
|
1600
|
-
delete properties[
|
|
1622
|
+
delete properties[_chunkRV7JIIDGcjs.SESSION_ID];
|
|
1623
|
+
delete properties[_chunkRV7JIIDGcjs.MESSAGE_ID];
|
|
1601
1624
|
} else {
|
|
1602
|
-
properties[
|
|
1625
|
+
properties[_chunkRV7JIIDGcjs.SESSION_ID] = sessionId;
|
|
1603
1626
|
}
|
|
1604
1627
|
if (options.serviceName !== void 0) {
|
|
1605
|
-
properties[
|
|
1628
|
+
properties[_chunkRV7JIIDGcjs.SERVICE_NAME] = options.serviceName;
|
|
1606
1629
|
}
|
|
1607
1630
|
try {
|
|
1608
1631
|
_api.context.with(
|
|
1609
|
-
base.setValue(
|
|
1610
|
-
() => emitEvent(
|
|
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',
|
|
1618
|
-
const spanName = isTitle ?
|
|
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(`${
|
|
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(`${
|
|
1647
|
+
span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
|
|
1625
1648
|
}
|
|
1626
1649
|
}
|
|
1627
1650
|
const session = new Session(sessionId, span);
|
|
1628
|
-
const contextProperties = { [
|
|
1651
|
+
const contextProperties = { [_chunkRV7JIIDGcjs.SESSION_ID]: sessionId };
|
|
1629
1652
|
if (isTitle) {
|
|
1630
|
-
contextProperties[
|
|
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(
|
|
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',
|
|
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(
|
|
1691
|
+
return tracer.startActiveSpan(_chunkRV7JIIDGcjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1669
1692
|
if (resolvedSessionId) {
|
|
1670
|
-
span.setAttribute(`${
|
|
1693
|
+
span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${_chunkRV7JIIDGcjs.SESSION_ID}`, resolvedSessionId);
|
|
1671
1694
|
}
|
|
1672
1695
|
const sessionTitle = new SessionTitle(span);
|
|
1673
|
-
const properties = { [
|
|
1696
|
+
const properties = { [_chunkRV7JIIDGcjs.SESSION_TITLE_GENERATION]: "true" };
|
|
1674
1697
|
if (resolvedSessionId) {
|
|
1675
|
-
properties[
|
|
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',
|
|
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(
|
|
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(`${
|
|
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',
|
|
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(
|
|
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(`${
|
|
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(
|
|
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',
|
|
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]:
|
|
2289
|
+
[BRIZZ_SDK_VERSION]: _chunkJSTTHMQ3cjs.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]:
|
|
2538
|
+
[BRIZZ_SDK_VERSION]: _chunkJSTTHMQ3cjs.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[
|
|
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',
|
|
2643
|
-
...[...this._delegates.values()].map(async (delegate) => _optionalChain([delegate, 'access',
|
|
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,16 +2675,34 @@ 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(
|
|
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(`${
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
}
|
|
2681
|
+
span.setAttribute(`${_chunkRV7JIIDGcjs.BRIZZ}.${key}`, value);
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
var LIBRARY_ID_ATTRIBUTES = [
|
|
2686
|
+
"mcp.request.id",
|
|
2687
|
+
"mcp.session.id",
|
|
2688
|
+
"jsonrpc.request.id",
|
|
2689
|
+
"gen_ai.response.id",
|
|
2690
|
+
"ai.response.id",
|
|
2691
|
+
// Session-id aliases the streamer copies into brizz.session.id (sessionIDAliases).
|
|
2692
|
+
"session.id",
|
|
2693
|
+
"langfuse.trace.metadata.session.id",
|
|
2694
|
+
"langfuse.trace.metadata.brizz.session.id",
|
|
2695
|
+
"langsmith.metadata.thread_id",
|
|
2696
|
+
"langsmith.metadata.session_id",
|
|
2697
|
+
"langsmith.metadata.conversation_id",
|
|
2698
|
+
"langsmith.trace.session_id"
|
|
2699
|
+
];
|
|
2700
|
+
var DEFAULT_RULE_ATTRIBUTES = String.raw`^(?!brizz\.(?!session\.(?:input|output)(?:\.context)?$|session\.title$|internal\.intent$)` + `|(?:${LIBRARY_ID_ATTRIBUTES.map((key) => key.replaceAll(".", String.raw`\.`)).join("|")})$)`;
|
|
2701
|
+
var isText = (value) => typeof value === "string" || Array.isArray(value) && value.some((item) => typeof item === "string");
|
|
2662
2702
|
var DEFAULT_MASKING_RULES = [
|
|
2663
2703
|
{
|
|
2664
2704
|
mode: "partial",
|
|
2705
|
+
attributePattern: DEFAULT_RULE_ATTRIBUTES,
|
|
2665
2706
|
patterns: DEFAULT_PII_PATTERNS
|
|
2666
2707
|
}
|
|
2667
2708
|
];
|
|
@@ -2677,7 +2718,7 @@ var BrizzSimpleSpanProcessor = class extends _sdktracebase.SimpleSpanProcessor {
|
|
|
2677
2718
|
}
|
|
2678
2719
|
onEnd(span) {
|
|
2679
2720
|
restampLangChainSpan(span);
|
|
2680
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2721
|
+
const maskingConfig = _optionalChain([this, 'access', _94 => _94.config, 'access', _95 => _95.masking, 'optionalAccess', _96 => _96.spanMasking]);
|
|
2681
2722
|
if (maskingConfig) {
|
|
2682
2723
|
maskReadableSpan(span, maskingConfig);
|
|
2683
2724
|
}
|
|
@@ -2696,7 +2737,7 @@ var BrizzBatchSpanProcessor = class extends _sdktracebase.BatchSpanProcessor {
|
|
|
2696
2737
|
}
|
|
2697
2738
|
onEnd(span) {
|
|
2698
2739
|
restampLangChainSpan(span);
|
|
2699
|
-
const maskingConfig = _optionalChain([this, 'access',
|
|
2740
|
+
const maskingConfig = _optionalChain([this, 'access', _97 => _97.config, 'access', _98 => _98.masking, 'optionalAccess', _99 => _99.spanMasking]);
|
|
2700
2741
|
if (maskingConfig) {
|
|
2701
2742
|
maskReadableSpan(span, maskingConfig);
|
|
2702
2743
|
}
|
|
@@ -2708,17 +2749,19 @@ function maskReadableSpan(span, config) {
|
|
|
2708
2749
|
if (!attrs || Object.keys(attrs).length === 0) {
|
|
2709
2750
|
return;
|
|
2710
2751
|
}
|
|
2711
|
-
let rules = config.rules ? [...config.rules] : [];
|
|
2712
|
-
if (!config.disableDefaultRules) {
|
|
2713
|
-
rules = [...rules, ...DEFAULT_MASKING_RULES];
|
|
2714
|
-
}
|
|
2715
2752
|
try {
|
|
2716
|
-
|
|
2753
|
+
let masked = {};
|
|
2717
2754
|
for (const [k, v] of Object.entries(attrs)) {
|
|
2718
|
-
|
|
2755
|
+
masked[k] = v;
|
|
2756
|
+
}
|
|
2757
|
+
if (_optionalChain([config, 'access', _100 => _100.rules, 'optionalAccess', _101 => _101.length])) {
|
|
2758
|
+
masked = maskAttributes(masked, config.rules);
|
|
2759
|
+
}
|
|
2760
|
+
if (!config.disableDefaultRules) {
|
|
2761
|
+
const text = Object.fromEntries(Object.entries(masked).filter(([k]) => isText(attrs[k])));
|
|
2762
|
+
Object.assign(masked, maskAttributes(text, DEFAULT_MASKING_RULES));
|
|
2719
2763
|
}
|
|
2720
|
-
const
|
|
2721
|
-
const maskedEntries = Object.entries(_nullishCoalesce(masked, () => ( {})));
|
|
2764
|
+
const maskedEntries = Object.entries(masked);
|
|
2722
2765
|
for (const [k, v] of maskedEntries) {
|
|
2723
2766
|
if (attrs[k] !== v) {
|
|
2724
2767
|
attrs[k] = v;
|
|
@@ -2783,7 +2826,7 @@ var TracingModule = (_class6 = class _TracingModule {constructor() { _class6.pro
|
|
|
2783
2826
|
}
|
|
2784
2827
|
_chunkWC573FCIcjs.logger.debug("Initializing span processor", {
|
|
2785
2828
|
disableBatch: config.disableBatch,
|
|
2786
|
-
hasMasking: !!_optionalChain([config, 'access',
|
|
2829
|
+
hasMasking: !!_optionalChain([config, 'access', _102 => _102.masking, 'optionalAccess', _103 => _103.spanMasking])
|
|
2787
2830
|
});
|
|
2788
2831
|
const spanProcessor = config.disableBatch ? new BrizzSimpleSpanProcessor(this.spanExporter, config) : new BrizzBatchSpanProcessor(this.spanExporter, config);
|
|
2789
2832
|
_chunkWC573FCIcjs.logger.debug("Span processor initialized successfully");
|
|
@@ -2854,7 +2897,7 @@ function newInstanceId() {
|
|
|
2854
2897
|
return _crypto.randomUUID.call(void 0, ).replaceAll("-", "").slice(0, 8);
|
|
2855
2898
|
}
|
|
2856
2899
|
function activeProperties() {
|
|
2857
|
-
return _nullishCoalesce(_api.context.active().getValue(
|
|
2900
|
+
return _nullishCoalesce(_api.context.active().getValue(_chunkRV7JIIDGcjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
|
|
2858
2901
|
}
|
|
2859
2902
|
function encodeToken(agent) {
|
|
2860
2903
|
const payload = {
|
|
@@ -2880,7 +2923,7 @@ function agentHandle(id, parentId, name) {
|
|
|
2880
2923
|
parentId,
|
|
2881
2924
|
name,
|
|
2882
2925
|
traceparent: currentTraceparent(),
|
|
2883
|
-
sessionId: _nullishCoalesce(activeProperties()[
|
|
2926
|
+
sessionId: _nullishCoalesce(activeProperties()[_chunkRV7JIIDGcjs.SESSION_ID], () => ( ""))
|
|
2884
2927
|
};
|
|
2885
2928
|
return {
|
|
2886
2929
|
...opened,
|
|
@@ -2916,7 +2959,7 @@ function resolveAgent(agent) {
|
|
|
2916
2959
|
let parentContext = _api.context.active();
|
|
2917
2960
|
if (options.token === void 0) {
|
|
2918
2961
|
id = options.id || newInstanceId();
|
|
2919
|
-
parentId = options.parentId || activeProperties()[
|
|
2962
|
+
parentId = options.parentId || activeProperties()[_chunkRV7JIIDGcjs.AGENT_ID] || "";
|
|
2920
2963
|
name = _nullishCoalesce(options.name, () => ( ""));
|
|
2921
2964
|
} else {
|
|
2922
2965
|
const decoded = decodeToken(options.token);
|
|
@@ -2935,12 +2978,12 @@ function resolveAgent(agent) {
|
|
|
2935
2978
|
}
|
|
2936
2979
|
}
|
|
2937
2980
|
}
|
|
2938
|
-
const properties = { [
|
|
2981
|
+
const properties = { [_chunkRV7JIIDGcjs.AGENT_ID]: id, [_chunkRV7JIIDGcjs.AGENT_NAME]: name };
|
|
2939
2982
|
if (parentId) {
|
|
2940
|
-
properties[
|
|
2983
|
+
properties[_chunkRV7JIIDGcjs.AGENT_PARENT_ID] = parentId;
|
|
2941
2984
|
}
|
|
2942
2985
|
if (sessionId) {
|
|
2943
|
-
properties[
|
|
2986
|
+
properties[_chunkRV7JIIDGcjs.SESSION_ID] = sessionId;
|
|
2944
2987
|
}
|
|
2945
2988
|
return { id, parentId, name, properties, parentContext };
|
|
2946
2989
|
}
|
|
@@ -3003,7 +3046,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3003
3046
|
*/
|
|
3004
3047
|
setupInstrumentation(options) {
|
|
3005
3048
|
const registry = InstrumentationRegistry.getInstance();
|
|
3006
|
-
|
|
3049
|
+
_chunkJSTTHMQ3cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
|
|
3007
3050
|
patchInstalledCallbackManager();
|
|
3008
3051
|
patchInstalledLangGraph();
|
|
3009
3052
|
if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
|
|
@@ -3028,7 +3071,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3028
3071
|
const resourceAttributes = {
|
|
3029
3072
|
...resolvedConfig.resourceAttributes,
|
|
3030
3073
|
"service.name": resolvedConfig.appName,
|
|
3031
|
-
[BRIZZ_SDK_VERSION]:
|
|
3074
|
+
[BRIZZ_SDK_VERSION]: _chunkJSTTHMQ3cjs.getSDKVersion.call(void 0, ),
|
|
3032
3075
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
3033
3076
|
};
|
|
3034
3077
|
if (resolvedConfig.environment) {
|
|
@@ -3040,7 +3083,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3040
3083
|
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
3084
|
this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
|
|
3042
3085
|
resource,
|
|
3043
|
-
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0,
|
|
3086
|
+
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkO2IBZJOJcjs.InterruptPropagator)(), getSpanProcessor()]
|
|
3044
3087
|
});
|
|
3045
3088
|
this._tracerProvider.register();
|
|
3046
3089
|
this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
|
|
@@ -3176,10 +3219,10 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
3176
3219
|
}
|
|
3177
3220
|
try {
|
|
3178
3221
|
await this.shutdownModules();
|
|
3179
|
-
await _optionalChain([this, 'access',
|
|
3180
|
-
await _optionalChain([this, 'access',
|
|
3181
|
-
await _optionalChain([this, 'access',
|
|
3182
|
-
await _optionalChain([this, 'access',
|
|
3222
|
+
await _optionalChain([this, 'access', _104 => _104._tracerProvider, 'optionalAccess', _105 => _105.forceFlush, 'call', _106 => _106()]);
|
|
3223
|
+
await _optionalChain([this, 'access', _107 => _107._tracerProvider, 'optionalAccess', _108 => _108.shutdown, 'call', _109 => _109()]);
|
|
3224
|
+
await _optionalChain([this, 'access', _110 => _110._meterProvider, 'optionalAccess', _111 => _111.forceFlush, 'call', _112 => _112()]);
|
|
3225
|
+
await _optionalChain([this, 'access', _113 => _113._meterProvider, 'optionalAccess', _114 => _114.shutdown, 'call', _115 => _115()]);
|
|
3183
3226
|
this._initialized = false;
|
|
3184
3227
|
this._tracerProvider = null;
|
|
3185
3228
|
this._meterProvider = null;
|