@brizz/sdk 0.1.46 → 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/README.md +20 -5
- package/dist/{chunk-APOYOP7D.js → chunk-3OMB2F7B.js} +1 -1
- package/dist/{chunk-3IGBYXLR.cjs → chunk-ELLCNMLI.cjs} +4 -4
- package/dist/{chunk-AOT5NJDV.js → chunk-FVVRWMPV.js} +2 -0
- package/dist/{chunk-5WBPX342.cjs → chunk-GMZQ6N77.cjs} +3 -1
- package/dist/{chunk-VFWTFL7E.cjs → chunk-JDJLJ2V2.cjs} +8 -8
- package/dist/{chunk-USYGGHMA.js → chunk-L4P4RJT5.js} +2 -2
- package/dist/index.cjs +192 -151
- package/dist/index.js +65 -24
- package/dist/{interrupt-A6O7N72X.js → interrupt-YO3ID433.js} +2 -2
- package/dist/interrupt-YQHEXVES.cjs +12 -0
- package/dist/{mcp-M3WRCR7G.cjs → mcp-3E34LCRM.cjs} +12 -12
- package/dist/{mcp-YHBVF7QU.js → mcp-RLTZLXHY.js} +2 -2
- package/dist/types/cjs/internal/semantic-conventions.d.ts +1 -0
- package/dist/types/cjs/internal/trace/session.d.ts +2 -0
- package/dist/types/esm/internal/semantic-conventions.d.ts +1 -0
- package/dist/types/esm/internal/trace/session.d.ts +2 -0
- package/package.json +21 -20
- package/dist/interrupt-IKOUBQGN.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 _chunkJDJLJ2V2cjs = require('./chunk-JDJLJ2V2.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ var _chunkVFWTFL7Ecjs = require('./chunk-VFWTFL7E.cjs');
|
|
|
16
16
|
var _chunkWC573FCIcjs = require('./chunk-WC573FCI.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
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
|
-
|
|
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 =
|
|
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-
|
|
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-
|
|
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 {
|
|
@@ -693,24 +694,25 @@ var SDK_LANGUAGE = "typescript";
|
|
|
693
694
|
|
|
694
695
|
|
|
695
696
|
// src/internal/instrumentation/langchain.ts
|
|
697
|
+
var _module = require('module');
|
|
696
698
|
|
|
697
699
|
var SCOPE_NAME = "@arizeai/openinference-instrumentation-langchain";
|
|
698
700
|
var PATCHED_MARKER = /* @__PURE__ */ Symbol.for("brizz.langchain.callbackManagerPatched");
|
|
699
701
|
var OMITTED_KEYS = /* @__PURE__ */ new Set([
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
702
|
+
_chunkGMZQ6N77cjs.USER_EMAIL,
|
|
703
|
+
_chunkGMZQ6N77cjs.USER_NAME,
|
|
704
|
+
_chunkGMZQ6N77cjs.ORGANIZATION_NAME,
|
|
705
|
+
_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN
|
|
704
706
|
]);
|
|
705
707
|
function runMetadataFromContext() {
|
|
706
|
-
const bag = _api.context.active().getValue(
|
|
708
|
+
const bag = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
707
709
|
if (!bag) {
|
|
708
710
|
return void 0;
|
|
709
711
|
}
|
|
710
712
|
const metadata = {};
|
|
711
713
|
for (const [name, value] of Object.entries(bag)) {
|
|
712
714
|
if (!OMITTED_KEYS.has(name)) {
|
|
713
|
-
metadata[`${
|
|
715
|
+
metadata[`${_chunkGMZQ6N77cjs.BRIZZ}.${name}`] = String(value);
|
|
714
716
|
}
|
|
715
717
|
}
|
|
716
718
|
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
@@ -751,6 +753,12 @@ function patchInstalledCallbackManager() {
|
|
|
751
753
|
} catch (error) {
|
|
752
754
|
_chunkWC573FCIcjs.logger.debug(`LangChain callback manager not patched: ${String(error)}`);
|
|
753
755
|
}
|
|
756
|
+
try {
|
|
757
|
+
const requireFromSdk = _module.createRequire.call(void 0, __filename);
|
|
758
|
+
patchCallbackManagerModule(requireFromSdk("@langchain/core/callbacks/manager"));
|
|
759
|
+
} catch (error) {
|
|
760
|
+
_chunkWC573FCIcjs.logger.debug(`LangChain CJS callback manager not patched: ${String(error)}`);
|
|
761
|
+
}
|
|
754
762
|
})();
|
|
755
763
|
}
|
|
756
764
|
function restampLangChainSpan(span) {
|
|
@@ -761,7 +769,7 @@ function restampLangChainSpan(span) {
|
|
|
761
769
|
}
|
|
762
770
|
const attrs = span.attributes;
|
|
763
771
|
const metadata = attrs["metadata"];
|
|
764
|
-
if (typeof metadata !== "string" || !metadata.includes(`"${
|
|
772
|
+
if (typeof metadata !== "string" || !metadata.includes(`"${_chunkGMZQ6N77cjs.BRIZZ}.`)) {
|
|
765
773
|
return;
|
|
766
774
|
}
|
|
767
775
|
const parsed = JSON.parse(metadata);
|
|
@@ -769,7 +777,7 @@ function restampLangChainSpan(span) {
|
|
|
769
777
|
return;
|
|
770
778
|
}
|
|
771
779
|
for (const [key, value] of Object.entries(parsed)) {
|
|
772
|
-
if (key.startsWith(`${
|
|
780
|
+
if (key.startsWith(`${_chunkGMZQ6N77cjs.BRIZZ}.`) && value !== null && value !== void 0) {
|
|
773
781
|
attrs[key] = String(value);
|
|
774
782
|
}
|
|
775
783
|
}
|
|
@@ -907,7 +915,7 @@ var InstrumentationRegistry = (_class = class _InstrumentationRegistry {construc
|
|
|
907
915
|
const mcpModules = this.manualModules.mcp;
|
|
908
916
|
void (async () => {
|
|
909
917
|
try {
|
|
910
|
-
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-
|
|
918
|
+
const { MCPInstrumentation } = await Promise.resolve().then(() => _interopRequireWildcard(require("./mcp-3E34LCRM.cjs")));
|
|
911
919
|
const instrumentation = new MCPInstrumentation({ exceptionLogger: exceptionLogger2 });
|
|
912
920
|
instrumentation.manuallyInstrument(mcpModules);
|
|
913
921
|
_chunkWC573FCIcjs.logger.debug("Manual instrumentation enabled for MCP");
|
|
@@ -958,16 +966,16 @@ function setCurrentSpanCustomProperties(properties) {
|
|
|
958
966
|
}
|
|
959
967
|
for (const [key, value] of Object.entries(properties)) {
|
|
960
968
|
try {
|
|
961
|
-
current.setAttribute(`${
|
|
969
|
+
current.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
|
|
962
970
|
} catch (e3) {
|
|
963
971
|
}
|
|
964
972
|
}
|
|
965
973
|
}
|
|
966
974
|
function callWithProperties(properties, fn, thisArg, ...args) {
|
|
967
975
|
const base = _api.context.active();
|
|
968
|
-
const prev = base.getValue(
|
|
976
|
+
const prev = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
969
977
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
970
|
-
const next = base.setValue(
|
|
978
|
+
const next = base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, merged);
|
|
971
979
|
return _api.context.with(next, fn, thisArg, ...args);
|
|
972
980
|
}
|
|
973
981
|
function withProperties(properties, fn, thisArg) {
|
|
@@ -988,25 +996,25 @@ function propagatePropertiesImperatively(properties, base = _api.context.active(
|
|
|
988
996
|
if (!store || typeof store.enterWith !== "function") {
|
|
989
997
|
return;
|
|
990
998
|
}
|
|
991
|
-
const prev = base.getValue(
|
|
999
|
+
const prev = base.getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
992
1000
|
const merged = prev ? { ...prev, ...properties } : properties;
|
|
993
|
-
store.enterWith(base.setValue(
|
|
1001
|
+
store.enterWith(base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, merged));
|
|
994
1002
|
} catch (e4) {
|
|
995
1003
|
}
|
|
996
1004
|
}
|
|
997
1005
|
function setUser(user) {
|
|
998
|
-
const properties = { [
|
|
1006
|
+
const properties = { [_chunkGMZQ6N77cjs.USER_ID]: user.id };
|
|
999
1007
|
if (user.email !== void 0) {
|
|
1000
|
-
properties[
|
|
1008
|
+
properties[_chunkGMZQ6N77cjs.USER_EMAIL] = user.email;
|
|
1001
1009
|
}
|
|
1002
1010
|
if (user.name !== void 0) {
|
|
1003
|
-
properties[
|
|
1011
|
+
properties[_chunkGMZQ6N77cjs.USER_NAME] = user.name;
|
|
1004
1012
|
}
|
|
1005
1013
|
if (user.role !== void 0) {
|
|
1006
|
-
properties[
|
|
1014
|
+
properties[_chunkGMZQ6N77cjs.USER_ROLE] = user.role;
|
|
1007
1015
|
}
|
|
1008
1016
|
if (user.plan !== void 0) {
|
|
1009
|
-
properties[
|
|
1017
|
+
properties[_chunkGMZQ6N77cjs.USER_PLAN] = user.plan;
|
|
1010
1018
|
}
|
|
1011
1019
|
if (user.traits) {
|
|
1012
1020
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
@@ -1020,15 +1028,15 @@ function setUser(user) {
|
|
|
1020
1028
|
propagatePropertiesImperatively(properties);
|
|
1021
1029
|
}
|
|
1022
1030
|
function setOrganization(org) {
|
|
1023
|
-
const properties = { [
|
|
1031
|
+
const properties = { [_chunkGMZQ6N77cjs.ORGANIZATION_ID]: org.id };
|
|
1024
1032
|
if (org.name !== void 0) {
|
|
1025
|
-
properties[
|
|
1033
|
+
properties[_chunkGMZQ6N77cjs.ORGANIZATION_NAME] = org.name;
|
|
1026
1034
|
}
|
|
1027
1035
|
if (org.plan !== void 0) {
|
|
1028
|
-
properties[
|
|
1036
|
+
properties[_chunkGMZQ6N77cjs.ORGANIZATION_PLAN] = org.plan;
|
|
1029
1037
|
}
|
|
1030
1038
|
if (org.domain !== void 0) {
|
|
1031
|
-
properties[
|
|
1039
|
+
properties[_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN] = org.domain;
|
|
1032
1040
|
}
|
|
1033
1041
|
if (org.traits) {
|
|
1034
1042
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
@@ -1042,35 +1050,36 @@ function setOrganization(org) {
|
|
|
1042
1050
|
propagatePropertiesImperatively(properties);
|
|
1043
1051
|
}
|
|
1044
1052
|
function setMessageId(id) {
|
|
1045
|
-
const properties = { [
|
|
1053
|
+
const properties = { [_chunkGMZQ6N77cjs.MESSAGE_ID]: id };
|
|
1046
1054
|
setCurrentSpanCustomProperties(properties);
|
|
1047
1055
|
propagatePropertiesImperatively(properties);
|
|
1048
1056
|
}
|
|
1049
1057
|
function setSessionId(id) {
|
|
1050
|
-
const properties = { [
|
|
1058
|
+
const properties = { [_chunkGMZQ6N77cjs.SESSION_ID]: id };
|
|
1051
1059
|
setCurrentSpanCustomProperties(properties);
|
|
1052
1060
|
propagatePropertiesImperatively(properties);
|
|
1053
1061
|
}
|
|
1054
1062
|
var SERVICE_NAME_MAX_BYTES = 256;
|
|
1055
|
-
function
|
|
1063
|
+
function serviceNameProblem(name) {
|
|
1056
1064
|
if (typeof name !== "string" || name === "") {
|
|
1057
|
-
|
|
1058
|
-
return {};
|
|
1065
|
+
return "must be a non-empty string";
|
|
1059
1066
|
}
|
|
1060
1067
|
if (/[\r\n\0]/.test(name)) {
|
|
1061
|
-
|
|
1062
|
-
`Service name ${JSON.stringify(name)} contains CR, LF, or NUL; keeping the configured appName.`
|
|
1063
|
-
);
|
|
1064
|
-
return {};
|
|
1068
|
+
return `${JSON.stringify(name)} contains CR, LF, or NUL`;
|
|
1065
1069
|
}
|
|
1066
1070
|
const byteLength = new globalThis.TextEncoder().encode(name).length;
|
|
1067
1071
|
if (byteLength > SERVICE_NAME_MAX_BYTES) {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
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.`);
|
|
1071
1080
|
return {};
|
|
1072
1081
|
}
|
|
1073
|
-
return { [
|
|
1082
|
+
return { [_chunkGMZQ6N77cjs.SERVICE_NAME]: name };
|
|
1074
1083
|
}
|
|
1075
1084
|
function setServiceName(name) {
|
|
1076
1085
|
const properties = serviceNameProperties(name);
|
|
@@ -1084,22 +1093,22 @@ function withServiceName(name, fn, thisArg) {
|
|
|
1084
1093
|
return withProperties(serviceNameProperties(name), fn, thisArg);
|
|
1085
1094
|
}
|
|
1086
1095
|
function resolveServiceNameFromContext() {
|
|
1087
|
-
const props = _api.context.active().getValue(
|
|
1088
|
-
return _optionalChain([props, 'optionalAccess', _56 => _56[
|
|
1096
|
+
const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
1097
|
+
return _optionalChain([props, 'optionalAccess', _56 => _56[_chunkGMZQ6N77cjs.SERVICE_NAME]]);
|
|
1089
1098
|
}
|
|
1090
1099
|
function userProperties(user) {
|
|
1091
|
-
const properties = { [
|
|
1100
|
+
const properties = { [_chunkGMZQ6N77cjs.USER_ID]: user.id };
|
|
1092
1101
|
if (user.email !== void 0) {
|
|
1093
|
-
properties[
|
|
1102
|
+
properties[_chunkGMZQ6N77cjs.USER_EMAIL] = user.email;
|
|
1094
1103
|
}
|
|
1095
1104
|
if (user.name !== void 0) {
|
|
1096
|
-
properties[
|
|
1105
|
+
properties[_chunkGMZQ6N77cjs.USER_NAME] = user.name;
|
|
1097
1106
|
}
|
|
1098
1107
|
if (user.role !== void 0) {
|
|
1099
|
-
properties[
|
|
1108
|
+
properties[_chunkGMZQ6N77cjs.USER_ROLE] = user.role;
|
|
1100
1109
|
}
|
|
1101
1110
|
if (user.plan !== void 0) {
|
|
1102
|
-
properties[
|
|
1111
|
+
properties[_chunkGMZQ6N77cjs.USER_PLAN] = user.plan;
|
|
1103
1112
|
}
|
|
1104
1113
|
if (user.traits) {
|
|
1105
1114
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
@@ -1112,15 +1121,15 @@ function userProperties(user) {
|
|
|
1112
1121
|
return properties;
|
|
1113
1122
|
}
|
|
1114
1123
|
function organizationProperties(org) {
|
|
1115
|
-
const properties = { [
|
|
1124
|
+
const properties = { [_chunkGMZQ6N77cjs.ORGANIZATION_ID]: org.id };
|
|
1116
1125
|
if (org.name !== void 0) {
|
|
1117
|
-
properties[
|
|
1126
|
+
properties[_chunkGMZQ6N77cjs.ORGANIZATION_NAME] = org.name;
|
|
1118
1127
|
}
|
|
1119
1128
|
if (org.plan !== void 0) {
|
|
1120
|
-
properties[
|
|
1129
|
+
properties[_chunkGMZQ6N77cjs.ORGANIZATION_PLAN] = org.plan;
|
|
1121
1130
|
}
|
|
1122
1131
|
if (org.domain !== void 0) {
|
|
1123
|
-
properties[
|
|
1132
|
+
properties[_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN] = org.domain;
|
|
1124
1133
|
}
|
|
1125
1134
|
if (org.traits) {
|
|
1126
1135
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
@@ -1145,32 +1154,32 @@ function withOrganization(org, fn, thisArg) {
|
|
|
1145
1154
|
return withProperties(organizationProperties(org), fn, thisArg);
|
|
1146
1155
|
}
|
|
1147
1156
|
function callWithMessageId(id, fn, thisArg, ...args) {
|
|
1148
|
-
return callWithProperties({ [
|
|
1157
|
+
return callWithProperties({ [_chunkGMZQ6N77cjs.MESSAGE_ID]: id }, fn, thisArg, ...args);
|
|
1149
1158
|
}
|
|
1150
1159
|
function withMessageId(id, fn, thisArg) {
|
|
1151
|
-
return withProperties({ [
|
|
1160
|
+
return withProperties({ [_chunkGMZQ6N77cjs.MESSAGE_ID]: id }, fn, thisArg);
|
|
1152
1161
|
}
|
|
1153
1162
|
function inheritedMuteTools() {
|
|
1154
|
-
const properties = _api.context.active().getValue(
|
|
1155
|
-
return _optionalChain([properties, 'optionalAccess', _57 => _57[
|
|
1163
|
+
const properties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
1164
|
+
return _optionalChain([properties, 'optionalAccess', _57 => _57[_chunkGMZQ6N77cjs.MUTE_TOOLS]]);
|
|
1156
1165
|
}
|
|
1157
1166
|
function muteProperties(options) {
|
|
1158
1167
|
const { input = true, output = true, tools = output } = options;
|
|
1159
1168
|
const properties = {};
|
|
1160
1169
|
if (input) {
|
|
1161
|
-
properties[
|
|
1170
|
+
properties[_chunkGMZQ6N77cjs.MUTE_INPUT] = "true";
|
|
1162
1171
|
}
|
|
1163
1172
|
if (output) {
|
|
1164
|
-
properties[
|
|
1173
|
+
properties[_chunkGMZQ6N77cjs.MUTE_OUTPUT] = "true";
|
|
1165
1174
|
}
|
|
1166
1175
|
if (tools !== output) {
|
|
1167
|
-
properties[
|
|
1176
|
+
properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = String(tools);
|
|
1168
1177
|
} else {
|
|
1169
1178
|
const inherited = inheritedMuteTools();
|
|
1170
1179
|
if (tools && inherited === "false") {
|
|
1171
|
-
properties[
|
|
1180
|
+
properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = "true";
|
|
1172
1181
|
} else if (options.tools === false && inherited === "true") {
|
|
1173
|
-
properties[
|
|
1182
|
+
properties[_chunkGMZQ6N77cjs.MUTE_TOOLS] = "false";
|
|
1174
1183
|
}
|
|
1175
1184
|
}
|
|
1176
1185
|
return properties;
|
|
@@ -1182,11 +1191,11 @@ function withMute(options, fn, thisArg) {
|
|
|
1182
1191
|
return withProperties(muteProperties(options), fn, thisArg);
|
|
1183
1192
|
}
|
|
1184
1193
|
function withSessionId(sessionId, fn, thisArg, extraProperties) {
|
|
1185
|
-
const properties = { [
|
|
1194
|
+
const properties = { [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId, ...extraProperties };
|
|
1186
1195
|
return withProperties(properties, fn, thisArg);
|
|
1187
1196
|
}
|
|
1188
1197
|
function callWithSessionId(sessionId, fn, thisArg, ...args) {
|
|
1189
|
-
return callWithProperties({ [
|
|
1198
|
+
return callWithProperties({ [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId }, fn, thisArg, ...args);
|
|
1190
1199
|
}
|
|
1191
1200
|
var Session = (_class2 = class {
|
|
1192
1201
|
|
|
@@ -1214,8 +1223,8 @@ var Session = (_class2 = class {
|
|
|
1214
1223
|
setInput(text, context7) {
|
|
1215
1224
|
this.inputs.push(text);
|
|
1216
1225
|
this.inputContexts.push(_nullishCoalesce(context7, () => ( {})));
|
|
1217
|
-
this.span.setAttribute(
|
|
1218
|
-
this.span.setAttribute(
|
|
1226
|
+
this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_INPUT, JSON.stringify(this.inputs));
|
|
1227
|
+
this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
|
|
1219
1228
|
}
|
|
1220
1229
|
/**
|
|
1221
1230
|
* Append an assistant turn to session output tracking.
|
|
@@ -1230,8 +1239,8 @@ var Session = (_class2 = class {
|
|
|
1230
1239
|
setOutput(text, context7) {
|
|
1231
1240
|
this.outputs.push(text);
|
|
1232
1241
|
this.outputContexts.push(_nullishCoalesce(context7, () => ( {})));
|
|
1233
|
-
this.span.setAttribute(
|
|
1234
|
-
this.span.setAttribute(
|
|
1242
|
+
this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_OUTPUT, JSON.stringify(this.outputs));
|
|
1243
|
+
this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
|
|
1235
1244
|
}
|
|
1236
1245
|
/**
|
|
1237
1246
|
* Set the session title on the span.
|
|
@@ -1239,7 +1248,7 @@ var Session = (_class2 = class {
|
|
|
1239
1248
|
* @param title - The generated title string
|
|
1240
1249
|
*/
|
|
1241
1250
|
setTitle(title) {
|
|
1242
|
-
this.span.setAttribute(
|
|
1251
|
+
this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_TITLE, title);
|
|
1243
1252
|
}
|
|
1244
1253
|
/**
|
|
1245
1254
|
* Update custom properties on the session span.
|
|
@@ -1249,7 +1258,7 @@ var Session = (_class2 = class {
|
|
|
1249
1258
|
*/
|
|
1250
1259
|
updateProperties(properties) {
|
|
1251
1260
|
for (const [key, value] of Object.entries(properties)) {
|
|
1252
|
-
this.span.setAttribute(`${
|
|
1261
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
|
|
1253
1262
|
}
|
|
1254
1263
|
}
|
|
1255
1264
|
/**
|
|
@@ -1261,21 +1270,21 @@ var Session = (_class2 = class {
|
|
|
1261
1270
|
setUser(user) {
|
|
1262
1271
|
if (user.traits) {
|
|
1263
1272
|
for (const [key, value] of Object.entries(user.traits)) {
|
|
1264
|
-
this.span.setAttribute(`${
|
|
1273
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.user.${key}`, value);
|
|
1265
1274
|
}
|
|
1266
1275
|
}
|
|
1267
|
-
this.span.setAttribute(`${
|
|
1276
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_ID}`, user.id);
|
|
1268
1277
|
if (user.email !== void 0) {
|
|
1269
|
-
this.span.setAttribute(`${
|
|
1278
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_EMAIL}`, user.email);
|
|
1270
1279
|
}
|
|
1271
1280
|
if (user.name !== void 0) {
|
|
1272
|
-
this.span.setAttribute(`${
|
|
1281
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_NAME}`, user.name);
|
|
1273
1282
|
}
|
|
1274
1283
|
if (user.role !== void 0) {
|
|
1275
|
-
this.span.setAttribute(`${
|
|
1284
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_ROLE}`, user.role);
|
|
1276
1285
|
}
|
|
1277
1286
|
if (user.plan !== void 0) {
|
|
1278
|
-
this.span.setAttribute(`${
|
|
1287
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.USER_PLAN}`, user.plan);
|
|
1279
1288
|
}
|
|
1280
1289
|
}
|
|
1281
1290
|
/**
|
|
@@ -1287,18 +1296,18 @@ var Session = (_class2 = class {
|
|
|
1287
1296
|
setOrganization(org) {
|
|
1288
1297
|
if (org.traits) {
|
|
1289
1298
|
for (const [key, value] of Object.entries(org.traits)) {
|
|
1290
|
-
this.span.setAttribute(`${
|
|
1299
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.organization.${key}`, value);
|
|
1291
1300
|
}
|
|
1292
1301
|
}
|
|
1293
|
-
this.span.setAttribute(`${
|
|
1302
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_ID}`, org.id);
|
|
1294
1303
|
if (org.name !== void 0) {
|
|
1295
|
-
this.span.setAttribute(`${
|
|
1304
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_NAME}`, org.name);
|
|
1296
1305
|
}
|
|
1297
1306
|
if (org.plan !== void 0) {
|
|
1298
|
-
this.span.setAttribute(`${
|
|
1307
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_PLAN}`, org.plan);
|
|
1299
1308
|
}
|
|
1300
1309
|
if (org.domain !== void 0) {
|
|
1301
|
-
this.span.setAttribute(`${
|
|
1310
|
+
this.span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.ORGANIZATION_DOMAIN}`, org.domain);
|
|
1302
1311
|
}
|
|
1303
1312
|
}
|
|
1304
1313
|
/**
|
|
@@ -1328,30 +1337,30 @@ var SessionTitle = class {
|
|
|
1328
1337
|
* @param title - The generated title string
|
|
1329
1338
|
*/
|
|
1330
1339
|
setTitle(title) {
|
|
1331
|
-
this.span.setAttribute(
|
|
1340
|
+
this.span.setAttribute(_chunkGMZQ6N77cjs.SESSION_TITLE, title);
|
|
1332
1341
|
}
|
|
1333
1342
|
};
|
|
1334
1343
|
function getActiveSession() {
|
|
1335
|
-
return _api.context.active().getValue(
|
|
1344
|
+
return _api.context.active().getValue(_chunkGMZQ6N77cjs.SESSION_OBJECT_CONTEXT_KEY);
|
|
1336
1345
|
}
|
|
1337
1346
|
function resolveSessionIdFromContext() {
|
|
1338
1347
|
const active = getActiveSession();
|
|
1339
1348
|
if (active) {
|
|
1340
1349
|
return active.sessionId;
|
|
1341
1350
|
}
|
|
1342
|
-
const props = _api.context.active().getValue(
|
|
1343
|
-
return _optionalChain([props, 'optionalAccess', _60 => _60[
|
|
1351
|
+
const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
1352
|
+
return _optionalChain([props, 'optionalAccess', _60 => _60[_chunkGMZQ6N77cjs.SESSION_ID]]);
|
|
1344
1353
|
}
|
|
1345
1354
|
function resolveMessageIdFromContext() {
|
|
1346
|
-
const props = _api.context.active().getValue(
|
|
1347
|
-
return _optionalChain([props, 'optionalAccess', _61 => _61[
|
|
1355
|
+
const props = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
1356
|
+
return _optionalChain([props, 'optionalAccess', _61 => _61[_chunkGMZQ6N77cjs.MESSAGE_ID]]);
|
|
1348
1357
|
}
|
|
1349
1358
|
function emitExternalLink(sessionId, url, title, linkType) {
|
|
1350
1359
|
try {
|
|
1351
|
-
emitEventWithSessionId(sessionId,
|
|
1352
|
-
[
|
|
1353
|
-
[
|
|
1354
|
-
[
|
|
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"))
|
|
1355
1364
|
});
|
|
1356
1365
|
} catch (error) {
|
|
1357
1366
|
_chunkWC573FCIcjs.logger.warn("addExternalLink: failed to emit external link", error);
|
|
@@ -1368,22 +1377,22 @@ function addExternalLink(url, options) {
|
|
|
1368
1377
|
emitExternalLink(sessionId, url, _optionalChain([options, 'optionalAccess', _63 => _63.title]), _optionalChain([options, 'optionalAccess', _64 => _64.linkType]));
|
|
1369
1378
|
}
|
|
1370
1379
|
function recordFeedback(type, options) {
|
|
1371
|
-
const eventAttributes = { [
|
|
1380
|
+
const eventAttributes = { [_chunkGMZQ6N77cjs.FEEDBACK_TYPE]: type };
|
|
1372
1381
|
if (_optionalChain([options, 'optionalAccess', _65 => _65.score]) !== void 0) {
|
|
1373
|
-
eventAttributes[
|
|
1382
|
+
eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_SCORE] = options.score;
|
|
1374
1383
|
}
|
|
1375
1384
|
if (_optionalChain([options, 'optionalAccess', _66 => _66.reason]) !== void 0) {
|
|
1376
|
-
eventAttributes[
|
|
1385
|
+
eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_REASON] = options.reason;
|
|
1377
1386
|
}
|
|
1378
1387
|
if (_optionalChain([options, 'optionalAccess', _67 => _67.comment]) !== void 0) {
|
|
1379
|
-
eventAttributes[
|
|
1388
|
+
eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_COMMENT] = options.comment;
|
|
1380
1389
|
}
|
|
1381
1390
|
if (_optionalChain([options, 'optionalAccess', _68 => _68.source]) !== void 0) {
|
|
1382
|
-
eventAttributes[
|
|
1391
|
+
eventAttributes[_chunkGMZQ6N77cjs.FEEDBACK_SOURCE] = options.source;
|
|
1383
1392
|
}
|
|
1384
1393
|
if (_optionalChain([options, 'optionalAccess', _69 => _69.attributes])) {
|
|
1385
1394
|
for (const [key, value] of Object.entries(options.attributes)) {
|
|
1386
|
-
const k = `${
|
|
1395
|
+
const k = `${_chunkGMZQ6N77cjs.FEEDBACK_ATTR_PREFIX}${key}`;
|
|
1387
1396
|
if (eventAttributes[k] === void 0) {
|
|
1388
1397
|
eventAttributes[k] = value;
|
|
1389
1398
|
}
|
|
@@ -1398,16 +1407,16 @@ function recordFeedback(type, options) {
|
|
|
1398
1407
|
}
|
|
1399
1408
|
const anchor = {};
|
|
1400
1409
|
if (messageId !== void 0) {
|
|
1401
|
-
anchor[
|
|
1410
|
+
anchor[_chunkGMZQ6N77cjs.MESSAGE_ID] = messageId;
|
|
1402
1411
|
}
|
|
1403
1412
|
if (sessionId !== void 0) {
|
|
1404
|
-
anchor[
|
|
1413
|
+
anchor[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
|
|
1405
1414
|
}
|
|
1406
1415
|
try {
|
|
1407
1416
|
if (Object.keys(anchor).length === 0) {
|
|
1408
|
-
emitEvent(
|
|
1417
|
+
emitEvent(_chunkGMZQ6N77cjs.FEEDBACK_EVENT_NAME, eventAttributes);
|
|
1409
1418
|
} else {
|
|
1410
|
-
callWithProperties(anchor, () => emitEvent(
|
|
1419
|
+
callWithProperties(anchor, () => emitEvent(_chunkGMZQ6N77cjs.FEEDBACK_EVENT_NAME, eventAttributes));
|
|
1411
1420
|
}
|
|
1412
1421
|
} catch (error) {
|
|
1413
1422
|
_chunkWC573FCIcjs.logger.warn("recordFeedback: failed to emit feedback event", error);
|
|
@@ -1432,7 +1441,7 @@ function recordMetricImpl(options) {
|
|
|
1432
1441
|
);
|
|
1433
1442
|
return;
|
|
1434
1443
|
}
|
|
1435
|
-
if (
|
|
1444
|
+
if (_chunkGMZQ6N77cjs.RESERVED_METRIC_NAMES.has(name)) {
|
|
1436
1445
|
_chunkWC573FCIcjs.logger.warn(
|
|
1437
1446
|
`recordMetric called with the reserved name ${JSON.stringify(name)}; metric dropped. Brizz computes this metric itself \u2014 pick a different name.`
|
|
1438
1447
|
);
|
|
@@ -1450,18 +1459,25 @@ function recordMetricImpl(options) {
|
|
|
1450
1459
|
);
|
|
1451
1460
|
return;
|
|
1452
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
|
+
}
|
|
1453
1469
|
const eventAttributes = {
|
|
1454
|
-
[
|
|
1455
|
-
[
|
|
1470
|
+
[_chunkGMZQ6N77cjs.METRIC_NAME]: name,
|
|
1471
|
+
[_chunkGMZQ6N77cjs.METRIC_VALUE]: numericValue
|
|
1456
1472
|
};
|
|
1457
1473
|
if (options.unit !== void 0) {
|
|
1458
|
-
eventAttributes[
|
|
1474
|
+
eventAttributes[_chunkGMZQ6N77cjs.METRIC_UNIT] = options.unit;
|
|
1459
1475
|
}
|
|
1460
1476
|
if (options.minValue !== void 0) {
|
|
1461
|
-
eventAttributes[
|
|
1477
|
+
eventAttributes[_chunkGMZQ6N77cjs.METRIC_MIN] = options.minValue;
|
|
1462
1478
|
}
|
|
1463
1479
|
if (options.maxValue !== void 0) {
|
|
1464
|
-
eventAttributes[
|
|
1480
|
+
eventAttributes[_chunkGMZQ6N77cjs.METRIC_MAX] = options.maxValue;
|
|
1465
1481
|
}
|
|
1466
1482
|
if (options.comment !== void 0) {
|
|
1467
1483
|
let comment = options.comment;
|
|
@@ -1471,21 +1487,21 @@ function recordMetricImpl(options) {
|
|
|
1471
1487
|
);
|
|
1472
1488
|
comment = comment.slice(0, METRIC_COMMENT_MAX_LEN);
|
|
1473
1489
|
}
|
|
1474
|
-
eventAttributes[
|
|
1490
|
+
eventAttributes[_chunkGMZQ6N77cjs.METRIC_COMMENT] = comment;
|
|
1475
1491
|
}
|
|
1476
1492
|
if (options.polarity !== void 0) {
|
|
1477
1493
|
const polarity = options.polarity;
|
|
1478
|
-
if (polarity ===
|
|
1479
|
-
eventAttributes[
|
|
1494
|
+
if (polarity === _chunkGMZQ6N77cjs.METRIC_POLARITY_POSITIVE || polarity === _chunkGMZQ6N77cjs.METRIC_POLARITY_NEGATIVE) {
|
|
1495
|
+
eventAttributes[_chunkGMZQ6N77cjs.METRIC_POLARITY] = polarity;
|
|
1480
1496
|
} else {
|
|
1481
1497
|
_chunkWC573FCIcjs.logger.warn(
|
|
1482
|
-
`recordMetric(${name}) called with an invalid polarity ${JSON.stringify(polarity)}; expected '${
|
|
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.`
|
|
1483
1499
|
);
|
|
1484
1500
|
}
|
|
1485
1501
|
}
|
|
1486
1502
|
if (options.timestamp !== void 0) {
|
|
1487
1503
|
if (Number.isFinite(options.timestamp.getTime())) {
|
|
1488
|
-
eventAttributes[
|
|
1504
|
+
eventAttributes[_chunkGMZQ6N77cjs.METRIC_TIMESTAMP] = options.timestamp.toISOString();
|
|
1489
1505
|
} else {
|
|
1490
1506
|
_chunkWC573FCIcjs.logger.warn(
|
|
1491
1507
|
`recordMetric(${name}) called with an invalid timestamp; emitting the metric without it.`
|
|
@@ -1515,21 +1531,37 @@ function recordMetricImpl(options) {
|
|
|
1515
1531
|
);
|
|
1516
1532
|
text = text.slice(0, METRIC_ATTRIBUTE_VALUE_MAX_LEN);
|
|
1517
1533
|
}
|
|
1518
|
-
eventAttributes[`${
|
|
1534
|
+
eventAttributes[`${_chunkGMZQ6N77cjs.METRIC_ATTRIBUTE_PREFIX}${normalizedKey}`] = text;
|
|
1519
1535
|
accepted += 1;
|
|
1520
1536
|
}
|
|
1521
1537
|
}
|
|
1522
|
-
const
|
|
1523
|
-
if (
|
|
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) {
|
|
1524
1544
|
_chunkWC573FCIcjs.logger.warn(
|
|
1525
|
-
`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.`
|
|
1526
1546
|
);
|
|
1527
1547
|
return;
|
|
1528
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
|
+
}
|
|
1529
1561
|
try {
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
() => emitEvent(
|
|
1562
|
+
_api.context.with(
|
|
1563
|
+
base.setValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY, properties),
|
|
1564
|
+
() => emitEvent(_chunkGMZQ6N77cjs.METRIC_EVENT_NAME, eventAttributes)
|
|
1533
1565
|
);
|
|
1534
1566
|
} catch (error) {
|
|
1535
1567
|
_chunkWC573FCIcjs.logger.warn("recordMetric: failed to emit metric event", error);
|
|
@@ -1537,19 +1569,19 @@ function recordMetricImpl(options) {
|
|
|
1537
1569
|
}
|
|
1538
1570
|
function startSession(sessionId, callback, extraProperties, options) {
|
|
1539
1571
|
const isTitle = _optionalChain([options, 'optionalAccess', _73 => _73.mode]) === "title";
|
|
1540
|
-
const spanName = isTitle ?
|
|
1572
|
+
const spanName = isTitle ? _chunkGMZQ6N77cjs.SESSION_TITLE_SPAN_NAME : _chunkGMZQ6N77cjs.SESSION_SPAN_NAME;
|
|
1541
1573
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1542
1574
|
return tracer.startActiveSpan(spanName, (span) => {
|
|
1543
|
-
span.setAttribute(`${
|
|
1575
|
+
span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.SESSION_ID}`, sessionId);
|
|
1544
1576
|
if (extraProperties) {
|
|
1545
1577
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
1546
|
-
span.setAttribute(`${
|
|
1578
|
+
span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
|
|
1547
1579
|
}
|
|
1548
1580
|
}
|
|
1549
1581
|
const session = new Session(sessionId, span);
|
|
1550
|
-
const contextProperties = { [
|
|
1582
|
+
const contextProperties = { [_chunkGMZQ6N77cjs.SESSION_ID]: sessionId };
|
|
1551
1583
|
if (isTitle) {
|
|
1552
|
-
contextProperties[
|
|
1584
|
+
contextProperties[_chunkGMZQ6N77cjs.SESSION_TITLE_GENERATION] = "true";
|
|
1553
1585
|
}
|
|
1554
1586
|
if (extraProperties) {
|
|
1555
1587
|
for (const [key, value] of Object.entries(extraProperties)) {
|
|
@@ -1557,7 +1589,7 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1557
1589
|
}
|
|
1558
1590
|
}
|
|
1559
1591
|
return callWithProperties(contextProperties, () => {
|
|
1560
|
-
const sessionCtx = _api.context.active().setValue(
|
|
1592
|
+
const sessionCtx = _api.context.active().setValue(_chunkGMZQ6N77cjs.SESSION_OBJECT_CONTEXT_KEY, session);
|
|
1561
1593
|
return _api.context.with(sessionCtx, () => {
|
|
1562
1594
|
try {
|
|
1563
1595
|
const result = callback(session);
|
|
@@ -1587,14 +1619,14 @@ function startSession(sessionId, callback, extraProperties, options) {
|
|
|
1587
1619
|
function startSessionTitle(callback, options) {
|
|
1588
1620
|
const resolvedSessionId = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _74 => _74.sessionId]), () => ( _optionalChain([getActiveSession, 'call', _75 => _75(), 'optionalAccess', _76 => _76.sessionId])));
|
|
1589
1621
|
const tracer = _api.trace.getTracer("@brizz/sdk");
|
|
1590
|
-
return tracer.startActiveSpan(
|
|
1622
|
+
return tracer.startActiveSpan(_chunkGMZQ6N77cjs.SESSION_TITLE_SPAN_NAME, (span) => {
|
|
1591
1623
|
if (resolvedSessionId) {
|
|
1592
|
-
span.setAttribute(`${
|
|
1624
|
+
span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${_chunkGMZQ6N77cjs.SESSION_ID}`, resolvedSessionId);
|
|
1593
1625
|
}
|
|
1594
1626
|
const sessionTitle = new SessionTitle(span);
|
|
1595
|
-
const properties = { [
|
|
1627
|
+
const properties = { [_chunkGMZQ6N77cjs.SESSION_TITLE_GENERATION]: "true" };
|
|
1596
1628
|
if (resolvedSessionId) {
|
|
1597
|
-
properties[
|
|
1629
|
+
properties[_chunkGMZQ6N77cjs.SESSION_ID] = resolvedSessionId;
|
|
1598
1630
|
}
|
|
1599
1631
|
return callWithProperties(properties, () => {
|
|
1600
1632
|
try {
|
|
@@ -2061,10 +2093,10 @@ var BrizzSimpleLogRecordProcessor = class extends _sdklogs.SimpleLogRecordProces
|
|
|
2061
2093
|
if (maskingConfig) {
|
|
2062
2094
|
maskLog(logRecord, maskingConfig);
|
|
2063
2095
|
}
|
|
2064
|
-
const associationProperties = _api.context.active().getValue(
|
|
2096
|
+
const associationProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
2065
2097
|
if (associationProperties) {
|
|
2066
2098
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
2067
|
-
logRecord.setAttribute(`${
|
|
2099
|
+
logRecord.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
|
|
2068
2100
|
}
|
|
2069
2101
|
}
|
|
2070
2102
|
super.onEmit(logRecord);
|
|
@@ -2081,10 +2113,10 @@ var BrizzBatchLogRecordProcessor = class extends _sdklogs.BatchLogRecordProcesso
|
|
|
2081
2113
|
if (maskingConfig) {
|
|
2082
2114
|
maskLog(logRecord, maskingConfig);
|
|
2083
2115
|
}
|
|
2084
|
-
const associationProperties = _api.context.active().getValue(
|
|
2116
|
+
const associationProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
2085
2117
|
if (associationProperties) {
|
|
2086
2118
|
for (const [key, value] of Object.entries(associationProperties)) {
|
|
2087
|
-
logRecord.setAttribute(`${
|
|
2119
|
+
logRecord.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
|
|
2088
2120
|
}
|
|
2089
2121
|
}
|
|
2090
2122
|
super.onEmit(logRecord);
|
|
@@ -2111,7 +2143,7 @@ function maskLog(logRecord, config) {
|
|
|
2111
2143
|
newAttributes[key] = value;
|
|
2112
2144
|
}
|
|
2113
2145
|
for (const [key, value] of Object.entries(logRecord.attributes)) {
|
|
2114
|
-
if (key.startsWith(
|
|
2146
|
+
if (key.startsWith(_chunkGMZQ6N77cjs.INTERNAL_EVENT_PREFIX)) {
|
|
2115
2147
|
newAttributes[key] = value;
|
|
2116
2148
|
}
|
|
2117
2149
|
}
|
|
@@ -2154,7 +2186,16 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
2154
2186
|
createLogExporter(config, serviceName) {
|
|
2155
2187
|
if (config.customLogExporter) {
|
|
2156
2188
|
_chunkWC573FCIcjs.logger.debug("Using custom log exporter");
|
|
2157
|
-
|
|
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
|
+
};
|
|
2158
2199
|
}
|
|
2159
2200
|
const logsUrl = config.baseUrl.replace(/\/$/, "") + "/v1/logs";
|
|
2160
2201
|
_chunkWC573FCIcjs.logger.debug("Initializing default OTLP log exporter", { url: logsUrl, serviceName });
|
|
@@ -2176,7 +2217,7 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
2176
2217
|
const resourceAttributes = {
|
|
2177
2218
|
...config.resourceAttributes,
|
|
2178
2219
|
"service.name": serviceName,
|
|
2179
|
-
[BRIZZ_SDK_VERSION]:
|
|
2220
|
+
[BRIZZ_SDK_VERSION]: _chunkJDJLJ2V2cjs.getSDKVersion.call(void 0, ),
|
|
2180
2221
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2181
2222
|
};
|
|
2182
2223
|
if (config.environment) {
|
|
@@ -2280,12 +2321,12 @@ var LoggingModule = (_class3 = class _LoggingModule {constructor() { _class3.pro
|
|
|
2280
2321
|
*/
|
|
2281
2322
|
async shutdown() {
|
|
2282
2323
|
_chunkWC573FCIcjs.logger.debug("Shutting down logging module");
|
|
2324
|
+
await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
|
|
2325
|
+
this.scopedProviders.clear();
|
|
2283
2326
|
if (this.loggerProvider) {
|
|
2284
2327
|
await this.loggerProvider.shutdown();
|
|
2285
2328
|
this.loggerProvider = null;
|
|
2286
2329
|
}
|
|
2287
|
-
await Promise.all([...this.scopedProviders.values()].map(async (p) => p.shutdown()));
|
|
2288
|
-
this.scopedProviders.clear();
|
|
2289
2330
|
this.config = null;
|
|
2290
2331
|
if (_LoggingModule.instance === this) {
|
|
2291
2332
|
_LoggingModule.instance = null;
|
|
@@ -2425,7 +2466,7 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2425
2466
|
const resourceAttrs = {
|
|
2426
2467
|
...config.resourceAttributes,
|
|
2427
2468
|
"service.name": config.appName,
|
|
2428
|
-
[BRIZZ_SDK_VERSION]:
|
|
2469
|
+
[BRIZZ_SDK_VERSION]: _chunkJDJLJ2V2cjs.getSDKVersion.call(void 0, ),
|
|
2429
2470
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2430
2471
|
};
|
|
2431
2472
|
if (config.environment) {
|
|
@@ -2439,7 +2480,7 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2439
2480
|
}
|
|
2440
2481
|
/** The service a span reports under: its scoped override, else the configured appName. */
|
|
2441
2482
|
_serviceNameOf(span) {
|
|
2442
|
-
const value = span.attributes[
|
|
2483
|
+
const value = span.attributes[_chunkGMZQ6N77cjs.SERVICE_NAME_ATTRIBUTE];
|
|
2443
2484
|
return typeof value === "string" && value !== "" ? value : this._defaultServiceName;
|
|
2444
2485
|
}
|
|
2445
2486
|
_resourceFor(serviceName) {
|
|
@@ -2565,10 +2606,10 @@ var BrizzSpanExporter = (_class5 = class {
|
|
|
2565
2606
|
|
|
2566
2607
|
var _sdktracebase = require('@opentelemetry/sdk-trace-base');
|
|
2567
2608
|
function applyContextAttributes(span) {
|
|
2568
|
-
const sessionProperties = _api.context.active().getValue(
|
|
2609
|
+
const sessionProperties = _api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY);
|
|
2569
2610
|
if (sessionProperties) {
|
|
2570
2611
|
for (const [key, value] of Object.entries(sessionProperties)) {
|
|
2571
|
-
span.setAttribute(`${
|
|
2612
|
+
span.setAttribute(`${_chunkGMZQ6N77cjs.BRIZZ}.${key}`, value);
|
|
2572
2613
|
}
|
|
2573
2614
|
}
|
|
2574
2615
|
}
|
|
@@ -2767,7 +2808,7 @@ function newInstanceId() {
|
|
|
2767
2808
|
return _crypto.randomUUID.call(void 0, ).replaceAll("-", "").slice(0, 8);
|
|
2768
2809
|
}
|
|
2769
2810
|
function activeProperties() {
|
|
2770
|
-
return _nullishCoalesce(_api.context.active().getValue(
|
|
2811
|
+
return _nullishCoalesce(_api.context.active().getValue(_chunkGMZQ6N77cjs.PROPERTIES_CONTEXT_KEY), () => ( {}));
|
|
2771
2812
|
}
|
|
2772
2813
|
function encodeToken(agent) {
|
|
2773
2814
|
const payload = {
|
|
@@ -2793,7 +2834,7 @@ function agentHandle(id, parentId, name) {
|
|
|
2793
2834
|
parentId,
|
|
2794
2835
|
name,
|
|
2795
2836
|
traceparent: currentTraceparent(),
|
|
2796
|
-
sessionId: _nullishCoalesce(activeProperties()[
|
|
2837
|
+
sessionId: _nullishCoalesce(activeProperties()[_chunkGMZQ6N77cjs.SESSION_ID], () => ( ""))
|
|
2797
2838
|
};
|
|
2798
2839
|
return {
|
|
2799
2840
|
...opened,
|
|
@@ -2829,7 +2870,7 @@ function resolveAgent(agent) {
|
|
|
2829
2870
|
let parentContext = _api.context.active();
|
|
2830
2871
|
if (options.token === void 0) {
|
|
2831
2872
|
id = options.id || newInstanceId();
|
|
2832
|
-
parentId = options.parentId || activeProperties()[
|
|
2873
|
+
parentId = options.parentId || activeProperties()[_chunkGMZQ6N77cjs.AGENT_ID] || "";
|
|
2833
2874
|
name = _nullishCoalesce(options.name, () => ( ""));
|
|
2834
2875
|
} else {
|
|
2835
2876
|
const decoded = decodeToken(options.token);
|
|
@@ -2848,12 +2889,12 @@ function resolveAgent(agent) {
|
|
|
2848
2889
|
}
|
|
2849
2890
|
}
|
|
2850
2891
|
}
|
|
2851
|
-
const properties = { [
|
|
2892
|
+
const properties = { [_chunkGMZQ6N77cjs.AGENT_ID]: id, [_chunkGMZQ6N77cjs.AGENT_NAME]: name };
|
|
2852
2893
|
if (parentId) {
|
|
2853
|
-
properties[
|
|
2894
|
+
properties[_chunkGMZQ6N77cjs.AGENT_PARENT_ID] = parentId;
|
|
2854
2895
|
}
|
|
2855
2896
|
if (sessionId) {
|
|
2856
|
-
properties[
|
|
2897
|
+
properties[_chunkGMZQ6N77cjs.SESSION_ID] = sessionId;
|
|
2857
2898
|
}
|
|
2858
2899
|
return { id, parentId, name, properties, parentContext };
|
|
2859
2900
|
}
|
|
@@ -2916,7 +2957,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2916
2957
|
*/
|
|
2917
2958
|
setupInstrumentation(options) {
|
|
2918
2959
|
const registry = InstrumentationRegistry.getInstance();
|
|
2919
|
-
|
|
2960
|
+
_chunkJDJLJ2V2cjs.configure.call(void 0, resolveMcpSessionTracking(options.mcpSessionTracking));
|
|
2920
2961
|
patchInstalledCallbackManager();
|
|
2921
2962
|
if (options.instrumentModules && Object.keys(options.instrumentModules).length > 0) {
|
|
2922
2963
|
registry.setManualModules(options.instrumentModules);
|
|
@@ -2940,7 +2981,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2940
2981
|
const resourceAttributes = {
|
|
2941
2982
|
...resolvedConfig.resourceAttributes,
|
|
2942
2983
|
"service.name": resolvedConfig.appName,
|
|
2943
|
-
[BRIZZ_SDK_VERSION]:
|
|
2984
|
+
[BRIZZ_SDK_VERSION]: _chunkJDJLJ2V2cjs.getSDKVersion.call(void 0, ),
|
|
2944
2985
|
[BRIZZ_SDK_LANGUAGE]: SDK_LANGUAGE
|
|
2945
2986
|
};
|
|
2946
2987
|
if (resolvedConfig.environment) {
|
|
@@ -2952,7 +2993,7 @@ var _Brizz = (_class7 = class __Brizz {constructor() { _class7.prototype.__init1
|
|
|
2952
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));
|
|
2953
2994
|
this._tracerProvider = new (0, _sdktracenode.NodeTracerProvider)({
|
|
2954
2995
|
resource,
|
|
2955
|
-
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0,
|
|
2996
|
+
spanProcessors: resolvedConfig.disableSpanExporter ? [] : [new (0, _chunkELLCNMLIcjs.InterruptPropagator)(), getSpanProcessor()]
|
|
2956
2997
|
});
|
|
2957
2998
|
this._tracerProvider.register();
|
|
2958
2999
|
this._meterProvider = new (0, _sdkmetrics.MeterProvider)({ resource, readers: [getMetricsReader()] });
|