@arizeai/openinference-instrumentation-beeai 1.0.0
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/LICENSE +201 -0
- package/README.md +80 -0
- package/dist/esm/config.d.ts +39 -0
- package/dist/esm/config.d.ts.map +1 -0
- package/dist/esm/config.js +39 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/helpers/buildTraceTree.d.ts +21 -0
- package/dist/esm/helpers/buildTraceTree.d.ts.map +1 -0
- package/dist/esm/helpers/buildTraceTree.js +71 -0
- package/dist/esm/helpers/buildTraceTree.js.map +1 -0
- package/dist/esm/helpers/create-span.d.ts +32 -0
- package/dist/esm/helpers/create-span.d.ts.map +1 -0
- package/dist/esm/helpers/create-span.js +42 -0
- package/dist/esm/helpers/create-span.js.map +1 -0
- package/dist/esm/helpers/getErrorSafe.d.ts +17 -0
- package/dist/esm/helpers/getErrorSafe.d.ts.map +1 -0
- package/dist/esm/helpers/getErrorSafe.js +24 -0
- package/dist/esm/helpers/getErrorSafe.js.map +1 -0
- package/dist/esm/helpers/getSerializedObjectSafe.d.ts +18 -0
- package/dist/esm/helpers/getSerializedObjectSafe.d.ts.map +1 -0
- package/dist/esm/helpers/getSerializedObjectSafe.js +217 -0
- package/dist/esm/helpers/getSerializedObjectSafe.js.map +1 -0
- package/dist/esm/helpers/idNameManager.d.ts +31 -0
- package/dist/esm/helpers/idNameManager.d.ts.map +1 -0
- package/dist/esm/helpers/idNameManager.js +50 -0
- package/dist/esm/helpers/idNameManager.js.map +1 -0
- package/dist/esm/helpers/traceSerializer.d.ts +19 -0
- package/dist/esm/helpers/traceSerializer.d.ts.map +1 -0
- package/dist/esm/helpers/traceSerializer.js +35 -0
- package/dist/esm/helpers/traceSerializer.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/instrumentation.d.ts +34 -0
- package/dist/esm/instrumentation.d.ts.map +1 -0
- package/dist/esm/instrumentation.js +71 -0
- package/dist/esm/instrumentation.js.map +1 -0
- package/dist/esm/middleware.d.ts +27 -0
- package/dist/esm/middleware.d.ts.map +1 -0
- package/dist/esm/middleware.js +247 -0
- package/dist/esm/middleware.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/types.d.ts +36 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +17 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esnext/config.d.ts +39 -0
- package/dist/esnext/config.d.ts.map +1 -0
- package/dist/esnext/config.js +39 -0
- package/dist/esnext/config.js.map +1 -0
- package/dist/esnext/helpers/buildTraceTree.d.ts +21 -0
- package/dist/esnext/helpers/buildTraceTree.d.ts.map +1 -0
- package/dist/esnext/helpers/buildTraceTree.js +57 -0
- package/dist/esnext/helpers/buildTraceTree.js.map +1 -0
- package/dist/esnext/helpers/create-span.d.ts +32 -0
- package/dist/esnext/helpers/create-span.d.ts.map +1 -0
- package/dist/esnext/helpers/create-span.js +37 -0
- package/dist/esnext/helpers/create-span.js.map +1 -0
- package/dist/esnext/helpers/getErrorSafe.d.ts +17 -0
- package/dist/esnext/helpers/getErrorSafe.d.ts.map +1 -0
- package/dist/esnext/helpers/getErrorSafe.js +24 -0
- package/dist/esnext/helpers/getErrorSafe.js.map +1 -0
- package/dist/esnext/helpers/getSerializedObjectSafe.d.ts +18 -0
- package/dist/esnext/helpers/getSerializedObjectSafe.d.ts.map +1 -0
- package/dist/esnext/helpers/getSerializedObjectSafe.js +165 -0
- package/dist/esnext/helpers/getSerializedObjectSafe.js.map +1 -0
- package/dist/esnext/helpers/idNameManager.d.ts +31 -0
- package/dist/esnext/helpers/idNameManager.d.ts.map +1 -0
- package/dist/esnext/helpers/idNameManager.js +50 -0
- package/dist/esnext/helpers/idNameManager.js.map +1 -0
- package/dist/esnext/helpers/traceSerializer.d.ts +19 -0
- package/dist/esnext/helpers/traceSerializer.d.ts.map +1 -0
- package/dist/esnext/helpers/traceSerializer.js +35 -0
- package/dist/esnext/helpers/traceSerializer.js.map +1 -0
- package/dist/esnext/index.d.ts +2 -0
- package/dist/esnext/index.d.ts.map +1 -0
- package/dist/esnext/index.js +2 -0
- package/dist/esnext/index.js.map +1 -0
- package/dist/esnext/instrumentation.d.ts +34 -0
- package/dist/esnext/instrumentation.d.ts.map +1 -0
- package/dist/esnext/instrumentation.js +71 -0
- package/dist/esnext/instrumentation.js.map +1 -0
- package/dist/esnext/middleware.d.ts +27 -0
- package/dist/esnext/middleware.d.ts.map +1 -0
- package/dist/esnext/middleware.js +241 -0
- package/dist/esnext/middleware.js.map +1 -0
- package/dist/esnext/tsconfig.esnext.tsbuildinfo +1 -0
- package/dist/esnext/types.d.ts +36 -0
- package/dist/esnext/types.d.ts.map +1 -0
- package/dist/esnext/types.js +17 -0
- package/dist/esnext/types.js.map +1 -0
- package/dist/examples/bee.d.ts +2 -0
- package/dist/examples/bee.d.ts.map +1 -0
- package/dist/examples/bee.js +35 -0
- package/dist/examples/bee.js.map +1 -0
- package/dist/examples/instrumentation.d.ts +2 -0
- package/dist/examples/instrumentation.d.ts.map +1 -0
- package/dist/examples/instrumentation.js +54 -0
- package/dist/examples/instrumentation.js.map +1 -0
- package/dist/src/config.d.ts +39 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +42 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/helpers/buildTraceTree.d.ts +21 -0
- package/dist/src/helpers/buildTraceTree.d.ts.map +1 -0
- package/dist/src/helpers/buildTraceTree.js +60 -0
- package/dist/src/helpers/buildTraceTree.js.map +1 -0
- package/dist/src/helpers/create-span.d.ts +32 -0
- package/dist/src/helpers/create-span.d.ts.map +1 -0
- package/dist/src/helpers/create-span.js +40 -0
- package/dist/src/helpers/create-span.js.map +1 -0
- package/dist/src/helpers/getErrorSafe.d.ts +17 -0
- package/dist/src/helpers/getErrorSafe.d.ts.map +1 -0
- package/dist/src/helpers/getErrorSafe.js +27 -0
- package/dist/src/helpers/getErrorSafe.js.map +1 -0
- package/dist/src/helpers/getSerializedObjectSafe.d.ts +18 -0
- package/dist/src/helpers/getSerializedObjectSafe.d.ts.map +1 -0
- package/dist/src/helpers/getSerializedObjectSafe.js +168 -0
- package/dist/src/helpers/getSerializedObjectSafe.js.map +1 -0
- package/dist/src/helpers/idNameManager.d.ts +31 -0
- package/dist/src/helpers/idNameManager.d.ts.map +1 -0
- package/dist/src/helpers/idNameManager.js +54 -0
- package/dist/src/helpers/idNameManager.js.map +1 -0
- package/dist/src/helpers/traceSerializer.d.ts +19 -0
- package/dist/src/helpers/traceSerializer.d.ts.map +1 -0
- package/dist/src/helpers/traceSerializer.js +38 -0
- package/dist/src/helpers/traceSerializer.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +18 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/instrumentation.d.ts +34 -0
- package/dist/src/instrumentation.d.ts.map +1 -0
- package/dist/src/instrumentation.js +76 -0
- package/dist/src/instrumentation.js.map +1 -0
- package/dist/src/middleware.d.ts +27 -0
- package/dist/src/middleware.d.ts.map +1 -0
- package/dist/src/middleware.js +254 -0
- package/dist/src/middleware.js.map +1 -0
- package/dist/src/types.d.ts +36 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +18 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +64 -0
- package/src/config.ts +48 -0
- package/src/helpers/buildTraceTree.ts +118 -0
- package/src/helpers/create-span.ts +66 -0
- package/src/helpers/getErrorSafe.ts +26 -0
- package/src/helpers/getSerializedObjectSafe.ts +325 -0
- package/src/helpers/idNameManager.ts +53 -0
- package/src/helpers/traceSerializer.ts +46 -0
- package/src/index.ts +1 -0
- package/src/instrumentation.ts +123 -0
- package/src/middleware.ts +318 -0
- package/src/types.ts +38 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 IBM Corp.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _IdNameManager_instances, _IdNameManager_idNamesCounter, _IdNameManager_idNameMap, _IdNameManager_runIdMap, _IdNameManager_spanIdGenerator;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.IdNameManager = void 0;
|
|
25
|
+
class IdNameManager {
|
|
26
|
+
constructor() {
|
|
27
|
+
_IdNameManager_instances.add(this);
|
|
28
|
+
/** Current index for each event */
|
|
29
|
+
_IdNameManager_idNamesCounter.set(this, new Map());
|
|
30
|
+
/** The new span id names and the original framework emitter event ids dictionary */
|
|
31
|
+
_IdNameManager_idNameMap.set(this, new Map());
|
|
32
|
+
/** We need to map the run tree structure with duplicities to the event tree structure */
|
|
33
|
+
_IdNameManager_runIdMap.set(this, new Map());
|
|
34
|
+
}
|
|
35
|
+
getIds({ path, id, runId, parentRunId, groupId }) {
|
|
36
|
+
__classPrivateFieldGet(this, _IdNameManager_runIdMap, "f").set(runId, id);
|
|
37
|
+
const spanId = __classPrivateFieldGet(this, _IdNameManager_instances, "m", _IdNameManager_spanIdGenerator).call(this, path);
|
|
38
|
+
__classPrivateFieldGet(this, _IdNameManager_idNameMap, "f").set(id, spanId);
|
|
39
|
+
const parentSpanId = parentRunId
|
|
40
|
+
? __classPrivateFieldGet(this, _IdNameManager_idNameMap, "f").get(__classPrivateFieldGet(this, _IdNameManager_runIdMap, "f").get(parentRunId) || "")
|
|
41
|
+
: groupId;
|
|
42
|
+
return {
|
|
43
|
+
spanId,
|
|
44
|
+
parentSpanId,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.IdNameManager = IdNameManager;
|
|
49
|
+
_IdNameManager_idNamesCounter = new WeakMap(), _IdNameManager_idNameMap = new WeakMap(), _IdNameManager_runIdMap = new WeakMap(), _IdNameManager_instances = new WeakSet(), _IdNameManager_spanIdGenerator = function _IdNameManager_spanIdGenerator(name) {
|
|
50
|
+
const count = __classPrivateFieldGet(this, _IdNameManager_idNamesCounter, "f").get(name) || 0;
|
|
51
|
+
__classPrivateFieldGet(this, _IdNameManager_idNamesCounter, "f").set(name, count + 1);
|
|
52
|
+
return `${name}-${__classPrivateFieldGet(this, _IdNameManager_idNamesCounter, "f").get(name)}`;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=idNameManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idNameManager.js","sourceRoot":"","sources":["../../../src/helpers/idNameManager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;AAUH,MAAa,aAAa;IAA1B;;QACE,mCAAmC;QACnC,wCAAkB,IAAI,GAAG,EAAkB,EAAC;QAC5C,oFAAoF;QACpF,mCAAa,IAAI,GAAG,EAAkB,EAAC;QACvC,yFAAyF;QACzF,kCAAY,IAAI,GAAG,EAAkB,EAAC;IAsBxC,CAAC;IAdC,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAe;QAC3D,uBAAA,IAAI,+BAAU,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC9B,MAAM,MAAM,GAAG,uBAAA,IAAI,gEAAiB,MAArB,IAAI,EAAkB,IAAI,CAAC,CAAC;QAE3C,uBAAA,IAAI,gCAAW,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,YAAY,GAAG,WAAW;YAC9B,CAAC,CAAC,uBAAA,IAAI,gCAAW,CAAC,GAAG,CAAC,uBAAA,IAAI,+BAAU,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YAC5D,CAAC,CAAC,OAAO,CAAC;QAEZ,OAAO;YACL,MAAM;YACN,YAAY;SACb,CAAC;IACJ,CAAC;CACF;AA5BD,sCA4BC;qPApBkB,IAAY;IAC3B,MAAM,KAAK,GAAG,uBAAA,IAAI,qCAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,uBAAA,IAAI,qCAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IAC1C,OAAO,GAAG,IAAI,IAAI,uBAAA,IAAI,qCAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 IBM Corp.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare function traceSerializer({ ignored_keys, }: {
|
|
17
|
+
ignored_keys?: string[];
|
|
18
|
+
}): (body: object) => string;
|
|
19
|
+
//# sourceMappingURL=traceSerializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceSerializer.d.ts","sourceRoot":"","sources":["../../../src/helpers/traceSerializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,wBAAgB,eAAe,CAAC,EAC9B,YAAiB,GAClB,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,UAGe,MAAM,YAcrB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 IBM Corp.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.traceSerializer = traceSerializer;
|
|
19
|
+
const DEFAULT_IGNORE_KEYS = [
|
|
20
|
+
"emitter",
|
|
21
|
+
"logger",
|
|
22
|
+
"tokens",
|
|
23
|
+
"createdBy",
|
|
24
|
+
"client",
|
|
25
|
+
];
|
|
26
|
+
function traceSerializer({ ignored_keys = [], }) {
|
|
27
|
+
const mergedIgnoreKeys = new Set([...DEFAULT_IGNORE_KEYS, ...ignored_keys]);
|
|
28
|
+
return (body) => JSON.stringify(body, (() => {
|
|
29
|
+
return (key, value) => {
|
|
30
|
+
// Ignore specific keys, all owned entities and keys starting with underscore
|
|
31
|
+
if (mergedIgnoreKeys.has(key) || key.startsWith("_")) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
};
|
|
36
|
+
})());
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=traceSerializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceSerializer.js","sourceRoot":"","sources":["../../../src/helpers/traceSerializer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAUH,0CAqBC;AA7BD,MAAM,mBAAmB,GAAG;IAC1B,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,QAAQ;CACT,CAAC;AAEF,SAAgB,eAAe,CAAC,EAC9B,YAAY,GAAG,EAAE,GAGlB;IACC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,mBAAmB,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC;IAE5E,OAAO,CAAC,IAAY,EAAE,EAAE,CACtB,IAAI,CAAC,SAAS,CACZ,IAAI,EACJ,CAAC,GAAG,EAAE;QACJ,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACpB,6EAA6E;YAC7E,IAAI,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrD,OAAO;YACT,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;IACJ,CAAC,CAAC,EAAE,CACL,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./instrumentation"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition, InstrumentationConfig } from "@opentelemetry/instrumentation";
|
|
2
|
+
import * as bee from "beeai-framework";
|
|
3
|
+
import { TraceConfigOptions } from "@arizeai/openinference-core";
|
|
4
|
+
/**
|
|
5
|
+
* function to check if instrumentation is enabled / disabled
|
|
6
|
+
*/
|
|
7
|
+
export declare function isPatched(): boolean;
|
|
8
|
+
export declare class BeeAIInstrumentation extends InstrumentationBase {
|
|
9
|
+
private oiTracer;
|
|
10
|
+
constructor({ instrumentationConfig, traceConfig, }?: {
|
|
11
|
+
/**
|
|
12
|
+
* The config for the instrumentation
|
|
13
|
+
* @see {@link InstrumentationConfig}
|
|
14
|
+
*/
|
|
15
|
+
instrumentationConfig?: InstrumentationConfig;
|
|
16
|
+
/**
|
|
17
|
+
* The OpenInference trace configuration. Can be used to mask or redact sensitive information on spans.
|
|
18
|
+
* @see {@link TraceConfigOptions}
|
|
19
|
+
*/
|
|
20
|
+
traceConfig?: TraceConfigOptions;
|
|
21
|
+
});
|
|
22
|
+
protected init(): InstrumentationNodeModuleDefinition;
|
|
23
|
+
/**
|
|
24
|
+
* Manually instruments the BeeAI module. This is needed when the module is not loaded via require (commonjs)
|
|
25
|
+
* @param {openai} module
|
|
26
|
+
*/
|
|
27
|
+
manuallyInstrument(module: typeof bee): void;
|
|
28
|
+
private patch;
|
|
29
|
+
/**
|
|
30
|
+
* Un-patches the OpenAI module's chat completions API
|
|
31
|
+
*/
|
|
32
|
+
private unpatch;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,mCAAmC,EACnC,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAY,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAW3E;;GAEG;AACH,wBAAgB,SAAS,YAExB;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;IAC3D,OAAO,CAAC,QAAQ,CAAW;gBAEf,EACV,qBAAqB,EACrB,WAAW,GACZ,GAAE;QACD;;;WAGG;QACH,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;QAC9C;;;WAGG;QACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;KAC7B;IASN,SAAS,CAAC,IAAI;IAWd;;;OAGG;IACH,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG;IAKrC,OAAO,CAAC,KAAK;IA+Bb;;OAEG;IACH,OAAO,CAAC,OAAO;CAehB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BeeAIInstrumentation = void 0;
|
|
4
|
+
exports.isPatched = isPatched;
|
|
5
|
+
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
6
|
+
const api_1 = require("@opentelemetry/api");
|
|
7
|
+
const beeai_framework_1 = require("beeai-framework");
|
|
8
|
+
const openinference_core_1 = require("@arizeai/openinference-core");
|
|
9
|
+
const middleware_1 = require("./middleware");
|
|
10
|
+
const MODULE_NAME = "beeai-framework";
|
|
11
|
+
/**
|
|
12
|
+
* Flag to check if the openai module has been patched
|
|
13
|
+
* Note: This is a fallback in case the module is made immutable (e.x. Deno, webpack, etc.)
|
|
14
|
+
*/
|
|
15
|
+
let _isOpenInferencePatched = false;
|
|
16
|
+
/**
|
|
17
|
+
* function to check if instrumentation is enabled / disabled
|
|
18
|
+
*/
|
|
19
|
+
function isPatched() {
|
|
20
|
+
return _isOpenInferencePatched;
|
|
21
|
+
}
|
|
22
|
+
class BeeAIInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
23
|
+
constructor({ instrumentationConfig, traceConfig, } = {}) {
|
|
24
|
+
super("@arizeai/openinference-instrumentation-beeai", beeai_framework_1.Version, Object.assign({}, instrumentationConfig));
|
|
25
|
+
this.oiTracer = new openinference_core_1.OITracer({ tracer: this.tracer, traceConfig });
|
|
26
|
+
}
|
|
27
|
+
init() {
|
|
28
|
+
const module = new instrumentation_1.InstrumentationNodeModuleDefinition(MODULE_NAME, ["0.*"], this.patch.bind(this), this.unpatch.bind(this));
|
|
29
|
+
return module;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Manually instruments the BeeAI module. This is needed when the module is not loaded via require (commonjs)
|
|
33
|
+
* @param {openai} module
|
|
34
|
+
*/
|
|
35
|
+
manuallyInstrument(module) {
|
|
36
|
+
api_1.diag.debug(`[BeeaiInstrumentation] Manually instrumenting ${MODULE_NAME}`);
|
|
37
|
+
this.patch(module);
|
|
38
|
+
}
|
|
39
|
+
patch(module) {
|
|
40
|
+
if (!(module === null || module === void 0 ? void 0 : module.BaseAgent)) {
|
|
41
|
+
api_1.diag.warn("[BeeaiInstrumentation] BaseAgent not found, skipping instrumentation.");
|
|
42
|
+
return module;
|
|
43
|
+
}
|
|
44
|
+
if ((module === null || module === void 0 ? void 0 : module.openInferencePatched) || _isOpenInferencePatched) {
|
|
45
|
+
return module;
|
|
46
|
+
}
|
|
47
|
+
api_1.diag.info("[BeeaiInstrumentation] Patching BaseAgent.run");
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
49
|
+
const instrumentation = this;
|
|
50
|
+
this._wrap(module.BaseAgent.prototype, "run", (original) => {
|
|
51
|
+
return function wrappedRun(...args) {
|
|
52
|
+
const returned = original.apply(this, args);
|
|
53
|
+
returned.middleware((0, middleware_1.createTelemetryMiddleware)(instrumentation.oiTracer));
|
|
54
|
+
return returned;
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
return module;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Un-patches the OpenAI module's chat completions API
|
|
61
|
+
*/
|
|
62
|
+
unpatch(moduleExports, moduleVersion) {
|
|
63
|
+
api_1.diag.debug(`Removing patch for ${MODULE_NAME}@${moduleVersion}`);
|
|
64
|
+
this._unwrap(moduleExports.BaseAgent.prototype, "run");
|
|
65
|
+
_isOpenInferencePatched = false;
|
|
66
|
+
try {
|
|
67
|
+
// This can fail if the module is made immutable via the runtime or bundler
|
|
68
|
+
moduleExports.openInferencePatched = false;
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
api_1.diag.warn(`Failed to unset ${MODULE_NAME} patched flag on the module`, e);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.BeeAIInstrumentation = BeeAIInstrumentation;
|
|
76
|
+
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";;;AAuBA,8BAEC;AAzBD,oEAIwC;AACxC,4CAA0C;AAC1C,qDAA0C;AAG1C,oEAA2E;AAC3E,6CAAyD;AAEzD,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC;;;GAGG;AACH,IAAI,uBAAuB,GAAG,KAAK,CAAC;AAEpC;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED,MAAa,oBAAqB,SAAQ,qCAAmB;IAG3D,YAAY,EACV,qBAAqB,EACrB,WAAW,MAYT,EAAE;QACJ,KAAK,CACH,8CAA8C,EAC9C,yBAAO,EACP,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,qBAAqB,CAAC,CACzC,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,IAAI,6BAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;IACrE,CAAC;IAES,IAAI;QACZ,MAAM,MAAM,GAAG,IAAI,qDAAmC,CACpD,WAAW,EACX,CAAC,KAAK,CAAC,EACP,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CACxB,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,kBAAkB,CAAC,MAAkB;QACnC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YACH,2EAA2E;YAC3E,aAAa,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAC7C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,UAAI,CAAC,IAAI,CAAC,mBAAmB,WAAW,6BAA6B,EAAE,CAAC,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;CACF;AA/FD,oDA+FC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 IBM Corp.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { OITracer } from "@arizeai/openinference-core";
|
|
17
|
+
import type { GetRunContext, RunInstance } from "beeai-framework/context";
|
|
18
|
+
export declare const activeTracesMap: Map<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* First we collect, filter and transform events from the beeai emitter to our internal framework spans in the `emitter.match("*.*"` block
|
|
21
|
+
* Some special data are collected in other `emitter.match` blocks like (history, response, rawPromt)
|
|
22
|
+
*
|
|
23
|
+
* Then we create the open telemetry spans when all data are collected. We are retroactively deleting some unnecessary internal spans
|
|
24
|
+
* see "emitter.match((event) => event.path === `${basePath}.run.${finishEventName}`" section
|
|
25
|
+
*/
|
|
26
|
+
export declare function createTelemetryMiddleware(tracer: OITracer): (context: GetRunContext<RunInstance, unknown>) => void;
|
|
27
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAWvD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAkB1E,eAAO,MAAM,eAAe,qBAA4B,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,QAAQ,aACvC,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,UAsQrD"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 IBM Corp.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.activeTracesMap = void 0;
|
|
28
|
+
exports.createTelemetryMiddleware = createTelemetryMiddleware;
|
|
29
|
+
const getSerializedObjectSafe_1 = require("./helpers/getSerializedObjectSafe");
|
|
30
|
+
const create_span_1 = require("./helpers/create-span");
|
|
31
|
+
const idNameManager_1 = require("./helpers/idNameManager");
|
|
32
|
+
const getErrorSafe_1 = require("./helpers/getErrorSafe");
|
|
33
|
+
const remeda_1 = require("remeda");
|
|
34
|
+
const errors_1 = require("beeai-framework/errors");
|
|
35
|
+
const version_1 = require("beeai-framework/version");
|
|
36
|
+
const message_1 = require("beeai-framework/backend/message");
|
|
37
|
+
const traceSerializer_1 = require("./helpers/traceSerializer");
|
|
38
|
+
const config_1 = require("./config");
|
|
39
|
+
const utils_1 = require("beeai-framework/emitter/utils");
|
|
40
|
+
const base_1 = require("beeai-framework/agents/base");
|
|
41
|
+
const api_1 = require("@opentelemetry/api");
|
|
42
|
+
const buildTraceTree_1 = require("./helpers/buildTraceTree");
|
|
43
|
+
const openinference_semantic_conventions_1 = require("@arizeai/openinference-semantic-conventions");
|
|
44
|
+
exports.activeTracesMap = new Map();
|
|
45
|
+
/**
|
|
46
|
+
* First we collect, filter and transform events from the beeai emitter to our internal framework spans in the `emitter.match("*.*"` block
|
|
47
|
+
* Some special data are collected in other `emitter.match` blocks like (history, response, rawPromt)
|
|
48
|
+
*
|
|
49
|
+
* Then we create the open telemetry spans when all data are collected. We are retroactively deleting some unnecessary internal spans
|
|
50
|
+
* see "emitter.match((event) => event.path === `${basePath}.run.${finishEventName}`" section
|
|
51
|
+
*/
|
|
52
|
+
function createTelemetryMiddleware(tracer) {
|
|
53
|
+
return (context) => {
|
|
54
|
+
var _a, _b, _c, _d;
|
|
55
|
+
if (!((_b = (_a = context.emitter) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.id)) {
|
|
56
|
+
throw new errors_1.FrameworkError(`Fatal error. Missing traceId`, [], { context });
|
|
57
|
+
}
|
|
58
|
+
const traceId = (_d = (_c = context.emitter) === null || _c === void 0 ? void 0 : _c.trace) === null || _d === void 0 ? void 0 : _d.id;
|
|
59
|
+
if (exports.activeTracesMap.has(traceId)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
exports.activeTracesMap.set(traceId, context.instance.constructor.name);
|
|
63
|
+
api_1.diag.debug("createTelemetryMiddleware", {
|
|
64
|
+
source: context.instance.constructor.name,
|
|
65
|
+
traceId: traceId,
|
|
66
|
+
});
|
|
67
|
+
const { emitter, runParams, instance } = context;
|
|
68
|
+
const basePath = (0, utils_1.createFullPath)(emitter.namespace, "");
|
|
69
|
+
let prompt = null;
|
|
70
|
+
if (instance instanceof base_1.BaseAgent) {
|
|
71
|
+
prompt = runParams[0].prompt;
|
|
72
|
+
}
|
|
73
|
+
const spansMap = new Map();
|
|
74
|
+
const parentIdsMap = new Map();
|
|
75
|
+
const spansToDeleteMap = new Map();
|
|
76
|
+
let generatedMessage = undefined;
|
|
77
|
+
let history = undefined;
|
|
78
|
+
const groupIterations = [];
|
|
79
|
+
const idNameManager = new idNameManager_1.IdNameManager();
|
|
80
|
+
const eventsIterationsMap = new Map();
|
|
81
|
+
const startTimeDate = new Date().getTime();
|
|
82
|
+
const startTimePerf = performance.now();
|
|
83
|
+
function convertDateToPerformance(date) {
|
|
84
|
+
return date.getTime() - startTimeDate + startTimePerf;
|
|
85
|
+
}
|
|
86
|
+
const serializer = (0, traceSerializer_1.traceSerializer)({
|
|
87
|
+
ignored_keys: config_1.INSTRUMENTATION_IGNORED_KEYS,
|
|
88
|
+
});
|
|
89
|
+
function cleanSpanSources({ spanId }) {
|
|
90
|
+
var _a;
|
|
91
|
+
const parentId = (_a = spansMap.get(spanId)) === null || _a === void 0 ? void 0 : _a.parent_id;
|
|
92
|
+
if (!parentId) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const spanCount = parentIdsMap.get(parentId);
|
|
96
|
+
if (!spanCount) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (spanCount > 1) {
|
|
100
|
+
// increase the span count for the parentId
|
|
101
|
+
parentIdsMap.set(parentId, spanCount - 1);
|
|
102
|
+
}
|
|
103
|
+
else if (spanCount === 1) {
|
|
104
|
+
parentIdsMap.delete(parentId);
|
|
105
|
+
// check the `spansToDelete` if the span should be deleted when it has no children's
|
|
106
|
+
if (spansToDeleteMap.has(parentId)) {
|
|
107
|
+
spansMap.delete(parentId);
|
|
108
|
+
spansToDeleteMap.delete(parentId);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create OpenTelemetry spans from collected data
|
|
114
|
+
*/
|
|
115
|
+
emitter.match((event) => event.path === `${basePath}.run.${config_1.finishLLMEventName}`, (_, meta) => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
var _a;
|
|
117
|
+
try {
|
|
118
|
+
api_1.diag.debug("run finish event", { path: meta.path, traceId: traceId });
|
|
119
|
+
if (!prompt && instance instanceof base_1.BaseAgent) {
|
|
120
|
+
prompt = (_a = (0, remeda_1.findLast)(instance.memory.messages, (message) => message.role === message_1.Role.USER)) === null || _a === void 0 ? void 0 : _a.text;
|
|
121
|
+
if (!prompt) {
|
|
122
|
+
throw new errors_1.FrameworkError("The prompt must be defined for the Agent's run", [], {
|
|
123
|
+
context,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// create tracer spans from collected data
|
|
128
|
+
(0, buildTraceTree_1.buildTraceTree)({
|
|
129
|
+
tracer,
|
|
130
|
+
data: {
|
|
131
|
+
prompt: prompt,
|
|
132
|
+
history,
|
|
133
|
+
generatedMessage,
|
|
134
|
+
spans: JSON.parse(serializer(Array.from(spansMap.values()))),
|
|
135
|
+
traceId,
|
|
136
|
+
version: version_1.Version,
|
|
137
|
+
runErrorSpanKey: `${basePath}.run.${config_1.errorLLMEventName}`,
|
|
138
|
+
startTime: startTimePerf,
|
|
139
|
+
endTime: performance.now(),
|
|
140
|
+
source: exports.activeTracesMap.get(traceId),
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
api_1.diag.warn("Instrumentation error", e);
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
exports.activeTracesMap.delete(traceId);
|
|
149
|
+
}
|
|
150
|
+
}));
|
|
151
|
+
/**
|
|
152
|
+
* This block collects all "not run category" events with their data and prepares spans for the OpenTelemetry.
|
|
153
|
+
* The huge number of `newToken` events are skipped and only the last one for each parent event is saved because of `generated_token_count` information
|
|
154
|
+
* The framework event tree structure is different from the open-telemetry tree structure and must be transformed from groupId and parentGroupId pattern via idNameManager
|
|
155
|
+
* The artificial "iteration" main tree level is computed from the `meta.groupId`
|
|
156
|
+
*/
|
|
157
|
+
emitter.match("*.*", (data, meta) => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
// allow `run.error` event due to the runtime error information
|
|
160
|
+
if (meta.path.includes(".run.") &&
|
|
161
|
+
meta.path !== `${basePath}.run.${config_1.errorLLMEventName}`) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// skip all new token events
|
|
165
|
+
if (meta.name === config_1.newTokenLLMEventName) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!((_a = meta.trace) === null || _a === void 0 ? void 0 : _a.runId)) {
|
|
169
|
+
throw new errors_1.FrameworkError(`Fatal error. Missing runId for event: ${meta.path}`, [], {
|
|
170
|
+
context,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* create groupId span level (id does not exist)
|
|
175
|
+
* I use only the top-level groups like iterations other nested groups like tokens would introduce unuseful complexity
|
|
176
|
+
*/
|
|
177
|
+
if (meta.groupId &&
|
|
178
|
+
!meta.trace.parentRunId &&
|
|
179
|
+
!groupIterations.includes(meta.groupId)) {
|
|
180
|
+
spansMap.set(meta.groupId, (0, create_span_1.createSpan)({
|
|
181
|
+
id: meta.groupId,
|
|
182
|
+
name: meta.groupId,
|
|
183
|
+
target: "groupId",
|
|
184
|
+
data: {
|
|
185
|
+
[openinference_semantic_conventions_1.SemanticConventions.OPENINFERENCE_SPAN_KIND]: "Chain",
|
|
186
|
+
},
|
|
187
|
+
startedAt: convertDateToPerformance(meta.createdAt),
|
|
188
|
+
}));
|
|
189
|
+
groupIterations.push(meta.groupId);
|
|
190
|
+
}
|
|
191
|
+
const { spanId, parentSpanId } = idNameManager.getIds({
|
|
192
|
+
path: meta.path,
|
|
193
|
+
id: meta.id,
|
|
194
|
+
runId: meta.trace.runId,
|
|
195
|
+
parentRunId: meta.trace.parentRunId,
|
|
196
|
+
groupId: meta.groupId,
|
|
197
|
+
});
|
|
198
|
+
const serializedData = (0, getSerializedObjectSafe_1.getSerializedObjectSafe)(data, meta);
|
|
199
|
+
// skip partialUpdate events with no data
|
|
200
|
+
if (meta.name === config_1.partialUpdateEventName && (0, remeda_1.isEmpty)(serializedData)) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const span = (0, create_span_1.createSpan)(Object.assign(Object.assign({ id: spanId, name: meta.name, target: meta.path }, (parentSpanId && { parent: { id: parentSpanId } })), { ctx: meta.context, data: serializedData, error: (0, getErrorSafe_1.getErrorSafe)(data), startedAt: convertDateToPerformance(meta.createdAt) }));
|
|
204
|
+
const lastIteration = groupIterations[groupIterations.length - 1];
|
|
205
|
+
// delete the `partialUpdate` event if does not have nested spans
|
|
206
|
+
const lastIterationEventSpanId = (_b = eventsIterationsMap
|
|
207
|
+
.get(lastIteration)) === null || _b === void 0 ? void 0 : _b.get(meta.name);
|
|
208
|
+
if (lastIterationEventSpanId &&
|
|
209
|
+
config_1.partialUpdateEventName === meta.name &&
|
|
210
|
+
spansMap.has(lastIterationEventSpanId)) {
|
|
211
|
+
const { context } = spansMap.get(lastIterationEventSpanId);
|
|
212
|
+
if (parentIdsMap.has(context.span_id)) {
|
|
213
|
+
spansToDeleteMap.set(lastIterationEventSpanId, undefined);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
// delete span
|
|
217
|
+
cleanSpanSources({ spanId: lastIterationEventSpanId });
|
|
218
|
+
spansMap.delete(lastIterationEventSpanId);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// create new span
|
|
222
|
+
spansMap.set(span.context.span_id, span);
|
|
223
|
+
// update number of nested spans for parent_id if exists
|
|
224
|
+
if (span.parent_id) {
|
|
225
|
+
parentIdsMap.set(span.parent_id, (parentIdsMap.get(span.parent_id) || 0) + 1);
|
|
226
|
+
}
|
|
227
|
+
// save the last event for each iteration
|
|
228
|
+
if (groupIterations.length > 0) {
|
|
229
|
+
if (eventsIterationsMap.has(lastIteration)) {
|
|
230
|
+
eventsIterationsMap
|
|
231
|
+
.get(lastIteration)
|
|
232
|
+
.set(meta.name, span.context.span_id);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
eventsIterationsMap.set(lastIteration, new Map().set(meta.name, span.context.span_id));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
// The generated response and message history are collected from the `success` agent's event
|
|
240
|
+
emitter.match((event) => event.name === config_1.successLLMEventName &&
|
|
241
|
+
event.creator instanceof base_1.BaseAgent, (data) => {
|
|
242
|
+
const { data: dataObject, memory } = data;
|
|
243
|
+
generatedMessage = {
|
|
244
|
+
role: dataObject.role,
|
|
245
|
+
text: dataObject.text,
|
|
246
|
+
};
|
|
247
|
+
history = memory.messages.map((msg) => ({
|
|
248
|
+
text: msg.text,
|
|
249
|
+
role: msg.role,
|
|
250
|
+
}));
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","source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C,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,IAAI,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;oBAC3C,mBAAmB;yBAChB,GAAG,CAAC,aAAa,CAAE;yBACnB,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC1C,CAAC;qBAAM,CAAC;oBACN,mBAAmB,CAAC,GAAG,CACrB,aAAa,EACb,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAC/C,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,4FAA4F;QAC5F,OAAO,CAAC,KAAK,CACX,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,IAAI,KAAK,4BAAmB;YAClC,KAAK,CAAC,OAAO,YAAY,gBAAS,EACpC,CAAC,IAAiD,EAAE,EAAE;YACpD,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAE1C,gBAAgB,GAAG;gBACjB,IAAI,EAAE,UAAU,CAAC,IAAI;gBACrB,IAAI,EAAE,UAAU,CAAC,IAAI;aACtB,CAAC;YACF,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBACtC,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,IAAI,EAAE,GAAG,CAAC,IAAI;aACf,CAAC,CAAC,CAAC;QACN,CAAC,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 IBM Corp.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Attributes, SpanStatus, TimeInput } from "@opentelemetry/api";
|
|
17
|
+
export interface FrameworkSpan {
|
|
18
|
+
attributes: {
|
|
19
|
+
metadata?: Attributes | null;
|
|
20
|
+
data?: Attributes | null;
|
|
21
|
+
target: string;
|
|
22
|
+
};
|
|
23
|
+
context: {
|
|
24
|
+
span_id: string;
|
|
25
|
+
};
|
|
26
|
+
end_time: TimeInput;
|
|
27
|
+
name: string;
|
|
28
|
+
parent_id?: string;
|
|
29
|
+
start_time: TimeInput;
|
|
30
|
+
status: SpanStatus;
|
|
31
|
+
}
|
|
32
|
+
export interface GeneratedResponse {
|
|
33
|
+
text: string;
|
|
34
|
+
role: string;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE;QACV,QAAQ,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 IBM Corp.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|